Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2c5a1cef

Von Jan Büren vor mehr als 7 Jahren hinzugefügt

  • ID 2c5a1cefe12c923fce743e46d42702570978edfb
  • Vorgänger 82a65b84
  • Nachfolger 0e04ddd7

behebt #242 Negative Verkaufsrechnungen mit Bankbewegung verknüpfen

Es ist möglich negative Verkaufsrechnungen zu erstellen. Bei
Bankbewegung verbuchen, ist dieser Fall nicht berücksichtigt.
Entsprechend den Fall berücksichtigt. Den Test erweitert und
Hinweise im Ticket erstellt.

Unterschiede anzeigen:

SL/Controller/BankTransaction.pm
669 669
      } else {
670 670
        # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary
671 671

  
672
        if ( $invoice->is_sales && $invoice->invoice_type eq 'credit_note' ) {
672
        # this catches credit_notes and negative sales invoices
673
        if ( $invoice->is_sales && $invoice->amount < 0 ) {
673 674
          # $invoice->open_amount     is negative for credit_notes
674 675
          # $bank_transaction->amount is negative for outgoing transactions
675 676
          # so $amount_of_transaction is negative but needs positive
t/bank/bank_transactions.t
1
use Test::More tests => 100;
1
use Test::More tests => 105;
2 2

  
3 3
use strict;
4 4

  
......
77 77
test_neg_ap_transaction();
78 78
test_ap_payment_transaction();
79 79
test_ap_payment_part_transaction();
80
test_neg_sales_invoice();
80 81

  
81 82
# remove all created data at end of test
82 83
clear_up();
......
620 621
  return $invoice;
621 622
};
622 623

  
624
sub test_neg_sales_invoice {
625

  
626
  my $testname = 'test_neg_sales_invoice';
627

  
628
  my $part1 = SL::Dev::Part::create_part(   partnumber => 'Funkenhaube öhm')->save;
629
  my $part2 = SL::Dev::Part::create_service(partnumber => 'Service-Pauschale Pasch!')->save;
630

  
631
  my $neg_sales_inv = SL::Dev::Record::create_sales_invoice(
632
    invnumber    => '20172201',
633
    customer     => $customer,
634
    taxincluded  => 0,
635
    invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
636
                      SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => -50),
637
                    ]
638
  );
639
  my $bt            = SL::Dev::Payment::create_bank_transaction(record        => $neg_sales_inv,
640
                                                                amount        => $neg_sales_inv->amount,
641
                                                                bank_chart_id => $bank->id,
642
                                                                transdate     => DateTime->today,
643
                                                               );
644
  $::form->{invoice_ids} = {
645
    $bt->id => [ $neg_sales_inv->id ]
646
  };
647

  
648
  save_btcontroller_to_string();
649

  
650
  $neg_sales_inv->load;
651
  $bt->load;
652
  is($neg_sales_inv->amount   , '-345.10000', "$testname: amount ok");
653
  is($neg_sales_inv->netamount, '-290.00000', "$testname: netamount ok");
654
  is($neg_sales_inv->paid     , '-345.10000', "$testname: paid ok");
655
  is($bt->amount              , '-345.10000', "$testname: bt amount ok");
656
  is($bt->invoice_amount      , '-345.10000', "$testname: bt invoice_amount ok");
657
}
658

  
623 659
1;

Auch abrufbar als: Unified diff