Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b6f37661

Von Martin Helmling martin.helmling@octosoft.eu vor mehr als 7 Jahren hinzugefügt

  • ID b6f37661d8b244fb55f27f9d77cfab6ed6a165e6
  • Vorgänger 543b7743
  • Nachfolger 661daf00

BankTransaction: "Kontoauszug verbuchen" überarbeitet für ap_transaction und credit_note

sowie Test erweitert

Unterschiede anzeigen:

t/bank/bank_transactions.t
1
use Test::More tests => 88;
1
use Test::More tests => 100;
2 2

  
3 3
use strict;
4 4

  
......
66 66
reset_state(); # initialise customers/vendors/bank/currency/...
67 67

  
68 68
test1();
69

  
69 70
test_overpayment_with_partialpayment();
70 71
test_overpayment();
71 72
test_skonto_exact();
72 73
test_two_invoices();
73 74
test_partial_payment();
74 75
test_credit_note();
75
test_neg_ap_transaction();
76 76
test_ap_transaction();
77
test_neg_ap_transaction();
77 78
test_ap_payment_transaction();
79
test_ap_payment_part_transaction();
80

  
78 81
# remove all created data at end of test
79 82
clear_up();
80 83

  
......
118 121
    bank                      => 'Geizkasse',
119 122
    bank_code                 => 'G1235',
120 123
    depositor                 => 'Test Customer',
124
    customernumber            => 'CUST1704',
121 125
  )->save;
122 126

  
123 127
  $payment_terms = SL::Dev::Payment::create_payment_terms;
......
131 135
    bank           => 'Geizkasse',
132 136
    bank_code      => 'G1235',
133 137
    depositor      => 'Test Vendor',
138
    vendornumber   => 'VEND1704',
134 139
  )->save;
135 140

  
136 141
  $ar_chart        = SL::DB::Manager::Chart->find_by( accno => '1400' ); # Forderungen
......
181 186

  
182 187
sub test_ap_transaction {
183 188
  my (%params) = @_;
189
  my $testname = 'test_ap_transaction';
190

  
184 191
  my $netamount = 100;
185 192
  my $amount    = $::form->round_amount($netamount * 1.19,2);
186 193
  my $invoice   = SL::DB::PurchaseInvoice->new(
187 194
    invoice      => 0,
188
    invnumber    => $params{invnumber} || 'test_ap_transaction',
195
    invnumber    => $params{invnumber} || $testname,
189 196
    amount       => $amount,
190 197
    netamount    => $netamount,
191 198
    transdate    => $transdate1,
......
205 212
  $invoice->create_ap_row(chart => $ap_chart);
206 213
  $invoice->save;
207 214

  
208
  is($invoice->currency_id , $currency_id , 'currency_id has been saved');
209
  is($invoice->netamount   , 100          , 'ap amount has been converted');
210
  is($invoice->amount      , 119          , 'ap amount has been converted');
211
  is($invoice->taxincluded , 0            , 'ap transaction doesn\'t have taxincluded');
215
  is($invoice->currency_id , $currency_id , "$testname: currency_id has been saved");
216
  is($invoice->netamount   , 100          , "$testname: ap amount has been converted");
217
  is($invoice->amount      , 119          , "$testname: ap amount has been converted");
218
  is($invoice->taxincluded , 0            , "$testname: ap transaction doesn\'t have taxincluded");
212 219

  
213 220
  is(SL::DB::Manager::AccTransaction->find_by(chart_id => $ap_amount_chart->id , trans_id => $invoice->id)->amount , '-100.00000' , $ap_amount_chart->accno . ': has been converted for currency');
214 221
  is(SL::DB::Manager::AccTransaction->find_by(chart_id => $ap_chart->id        , trans_id => $invoice->id)->amount , '119.00000'  , $ap_chart->accno . ': has been converted for currency');
......
490 497

  
491 498
sub test_ap_payment_transaction {
492 499
  my (%params) = @_;
493
  my $testname = 'test_ap_two_transaction';
500
  my $testname = 'test_ap_payment_transaction';
494 501
  my $netamount = 115;
495 502
  my $amount    = $::form->round_amount($netamount * 1.19,2);
496 503
  my $invoice   = SL::DB::PurchaseInvoice->new(
497 504
    invoice      => 0,
498
    invnumber    => $params{invnumber} || 'test_ap_two_transaction',
505
    invnumber    => $params{invnumber} || $testname,
499 506
    amount       => $amount,
500 507
    netamount    => $netamount,
501 508
    transdate    => $transdate1,
......
504 511
    taxzone_id   => $vendor->taxzone_id,
505 512
    currency_id  => $currency_id,
506 513
    transactions => [],
507
    notes        => 'test_ap_transaction',
514
    notes        => $testname,
508 515
  );
509 516
  $invoice->add_ap_amount_row(
510 517
    amount     => $invoice->netamount,
......
540 547

  
541 548
  return $invoice;
542 549
};
550

  
551
sub test_ap_payment_part_transaction {
552
  my (%params) = @_;
553
  my $testname = 'test_ap_payment_p_transaction';
554
  my $netamount = 115;
555
  my $amount    = $::form->round_amount($netamount * 1.19,2);
556
  my $invoice   = SL::DB::PurchaseInvoice->new(
557
    invoice      => 0,
558
    invnumber    => $params{invnumber} || $testname,
559
    amount       => $amount,
560
    netamount    => $netamount,
561
    transdate    => $transdate1,
562
    taxincluded  => 0,
563
    vendor_id    => $vendor->id,
564
    taxzone_id   => $vendor->taxzone_id,
565
    currency_id  => $currency_id,
566
    transactions => [],
567
    notes        => $testname,
568
  );
569
  $invoice->add_ap_amount_row(
570
    amount     => $invoice->netamount,
571
    chart      => $ap_amount_chart,
572
    tax_id     => $tax_9->id,
573
  );
574

  
575
  $invoice->create_ap_row(chart => $ap_chart);
576
  $invoice->save;
577

  
578
  is($invoice->netamount, 115  , "$testname: netamount ok");
579
  is($invoice->amount   , 136.85, "$testname: amount ok");
580

  
581
  my $bt            = SL::Dev::Payment::create_bank_transaction(record        => $invoice,
582
                                                                amount        => $invoice->amount-100,
583
                                                                bank_chart_id => $bank->id,
584
                                                                transdate     => DateTime->today->add(days => 10),
585
                                                               );
586
  $::form->{invoice_ids} = {
587
    $bt->id => [ $invoice->id ]
588
  };
589

  
590
  save_btcontroller_to_string();
591

  
592
  $invoice->load;
593
  $bt->load;
594

  
595
  is($invoice->amount   , '136.85000', "$testname: amount ok");
596
  is($invoice->netamount, '115.00000', "$testname: netamount ok");
597
  is($bt->amount,         '-36.85000', "$testname: bt amount ok");
598
  is($invoice->paid     ,  '36.85000', "$testname: paid ok");
599
  is($bt->invoice_amount, '-36.85000', "$testname: bt invoice amount for ap was assigned");
600

  
601
  my $bt2           = SL::Dev::Payment::create_bank_transaction(record        => $invoice,
602
                                                                amount        => 100,
603
                                                                bank_chart_id => $bank->id,
604
                                                                transdate     => DateTime->today->add(days => 10),
605
                                                               );
606
  $::form->{invoice_ids} = {
607
    $bt2->id => [ $invoice->id ]
608
  };
609

  
610
  save_btcontroller_to_string();
611
  $invoice->load;
612
  $bt2->load;
613

  
614
  is($invoice->amount   , '136.85000', "$testname: amount ok");
615
  is($invoice->netamount, '115.00000', "$testname: netamount ok");
616
  is($bt2->amount,        '-100.00000',"$testname: bt amount ok");
617
  is($invoice->paid     , '136.85000', "$testname: paid ok");
618
  is($bt2->invoice_amount,'-100.00000', "$testname: bt invoice amount for ap was assigned");
619

  
620
  return $invoice;
621
};
622

  
543 623
1;

Auch abrufbar als: Unified diff