Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 578a40ba

Von G. Richardson vor fast 5 Jahren hinzugefügt

  • ID 578a40baf127dc22ef07841cbf7bca3ee0c7304d
  • Vorgänger 5a260a84
  • Nachfolger df183815

t/datev/invoices.t nutzt Dev create_ap_transaction

Anstatt die acc_trans-Einträge manuell zusammenzubauen.

Unterschiede anzeigen:

t/datev/invoices.t
243 243
$datev_lines = $datev->generate_datev_lines;
244 244

  
245 245
note('testing purchase invoice');
246
my $purchase_invoice = new_purchase_invoice();
246
my $purchase_invoice = create_ap_transaction(
247
  vendor      => $vendor,
248
  invnumber   => 'ap1',
249
  amount      => '226',
250
  netamount   => '200',
251
  transdate   => $date,
252
  gldate      => $date,
253
  itime       => $date, # make sure itime is 1.1., as gldatefrom tests for itime!
254
  taxincluded => 0,
255
  bookings    => [
256
                   {
257
                     chart  => SL::DB::Manager::Chart->find_by(accno => '3400'),
258
                     amount => 100,
259
                   },
260
                   {
261
                     chart  => SL::DB::Manager::Chart->find_by(accno => '3300'),
262
                     amount => 100,
263
                   },
264
                 ],
265
);
266

  
247 267
$datev1 = SL::DATEV->new(
248 268
  dbh        => $purchase_invoice->db->dbh,
249 269
  trans_id   => $purchase_invoice->id,
......
302 322
                                       ], "trans_id datev check purchase_invoice use_pk ok";
303 323

  
304 324
note('testing gldatefrom');
325
# test an order with transdate in january, but that was booked in march
326
# gldatefrom in DATEV.pm checks for itime, not gldate!!!
305 327
$datev = SL::DATEV->new(
306 328
  dbh        => $dbh,
307 329
  from       => $startdate,
......
323 345
done_testing();
324 346
clear_up();
325 347

  
326
sub new_purchase_invoice {
327
  # manually create a Kreditorenbuchung from scratch, ap + acc_trans bookings, as no helper exists yet, like $invoice->post.
328
  # arap-Booking must come last in the acc_trans order
329
  # this function was essentially copied from t/db_helper/payment.t, refactor once $purchase_invoice->post exists
330
  my $currency_id = $::instance_conf->get_currency_id;
331
  my $employee    = SL::DB::Manager::Employee->current                          || die "No employee";
332
  my $taxzone     = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || die "No taxzone";
333

  
334
  my $purchase_invoice = SL::DB::PurchaseInvoice->new(
335
    amount      => '226',
336
    currency_id => $currency_id,
337
    employee_id => $employee->id,
338
    gldate      => $date,
339
    invnumber   => "ap1",
340
    invoice     => 0,
341
    itime       => $date,
342
    mtime       => $date,
343
    netamount   => '200',
344
    paid        => '0',
345
    taxincluded => 0,
346
    taxzone_id  => $taxzone->id,
347
    transdate   => $date,
348
    type        => 'invoice',
349
    vendor_id   => $vendor->id,
350
  )->save;
351

  
352
  my $expense_chart  = SL::DB::Manager::Chart->find_by(accno => '3400');
353
  my $expense_chart_booking= SL::DB::AccTransaction->new(
354
    amount     => '-100',
355
    chart_id   => $expense_chart->id,
356
    chart_link => $expense_chart->link,
357
    itime      => $date,
358
    mtime      => $date,
359
    source     => '',
360
    tax_id     => SL::DB::Manager::Tax->find_by(taxkey => 9)->id,
361
    taxkey     => 9,
362
    transdate  => $date,
363
    trans_id   => $purchase_invoice->id,
364
  );
365
  $expense_chart_booking->save;
366

  
367
  my $tax_chart  = SL::DB::Manager::Chart->find_by(accno => '1576');
368
  my $tax_chart_booking= SL::DB::AccTransaction->new(
369
    amount     => '-19',
370
    chart_id   => $tax_chart->id,
371
    chart_link => $tax_chart->link,
372
    itime      => $date,
373
    mtime      => $date,
374
    source     => '',
375
    tax_id     => SL::DB::Manager::Tax->find_by(taxkey => 9)->id,
376
    taxkey     => 0,
377
    transdate  => $date,
378
    trans_id   => $purchase_invoice->id,
379
  );
380
  $tax_chart_booking->save;
381
  $expense_chart  = SL::DB::Manager::Chart->find_by(accno => '3300');
382
  $expense_chart_booking= SL::DB::AccTransaction->new(
383
    amount     => '-100',
384
    chart_id   => $expense_chart->id,
385
    chart_link => $expense_chart->link,
386
    itime      => $date,
387
    mtime      => $date,
388
    source     => '',
389
    tax_id     => SL::DB::Manager::Tax->find_by(taxkey => 8)->id,
390
    taxkey     => 8,
391
    transdate  => $date,
392
    trans_id   => $purchase_invoice->id,
393
  );
394
  $expense_chart_booking->save;
395

  
396
  $tax_chart  = SL::DB::Manager::Chart->find_by(accno => '1571');
397
  $tax_chart_booking= SL::DB::AccTransaction->new(
398
    trans_id   => $purchase_invoice->id,
399
    chart_id   => $tax_chart->id,
400
    chart_link => $tax_chart->link,
401
    amount     => '-7',
402
    transdate  => $date,
403
    itime      => $date,
404
    mtime      => $date,
405
    source     => '',
406
    taxkey     => 0,
407
    tax_id     => SL::DB::Manager::Tax->find_by(taxkey => 8)->id,
408
  );
409
  $tax_chart_booking->save;
410
  my $arap_chart  = SL::DB::Manager::Chart->find_by(accno => '1600');
411
  my $arap_booking= SL::DB::AccTransaction->new(
412
    trans_id   => $purchase_invoice->id,
413
    chart_id   => $arap_chart->id,
414
    chart_link => $arap_chart->link,
415
    amount     => '226',
416
    transdate  => $date,
417
    itime      => $date,
418
    mtime      => $date,
419
    source     => '',
420
    taxkey     => 0,
421
    tax_id     => SL::DB::Manager::Tax->find_by(taxkey => 0)->id,
422
  );
423
  $arap_booking->save;
424

  
425
  return $purchase_invoice;
426
}
427

  
428 348
sub clear_up {
429 349
  SL::DB::Manager::AccTransaction->delete_all(all => 1);
430 350
  SL::DB::Manager::InvoiceItem->delete_all(   all => 1);

Auch abrufbar als: Unified diff