X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fdb_helper%2Fpayment.t;h=26880f4a102ee4b7aee317124c324bdf8dd90c0b;hb=15b67fd51a4e9d274205f59a9f50c4ce86b5e176;hp=0d29156b249bc51dbd1f2f5e8f26fa281040d9b7;hpb=6d5743899631690b4a82190a977a075c66eb4a0d;p=kivitendo-erp.git diff --git a/t/db_helper/payment.t b/t/db_helper/payment.t index 0d29156b2..26880f4a1 100644 --- a/t/db_helper/payment.t +++ b/t/db_helper/payment.t @@ -83,7 +83,8 @@ sub reset_state { description_long => 'payment', terms_netto => '30', terms_skonto => '5', - percent_skonto => '0.05' + percent_skonto => '0.05', + auto_calculation => 1, )->save; $vendor = SL::DB::Vendor->new( @@ -256,11 +257,11 @@ sub new_item { } sub number_of_payments { - my $transactions = shift; + my $invoice = shift; my $number_of_payments; my $paid_amount; - foreach my $transaction ( @$transactions ) { + foreach my $transaction ( @{ $invoice->transactions } ) { if ( $transaction->chart_link =~ /(AR_paid|AP_paid)/ ) { $paid_amount += $transaction->amount ; $number_of_payments++; @@ -270,9 +271,9 @@ sub number_of_payments { }; sub total_amount { - my $transactions = shift; + my $invoice = shift; - my $total = sum map { $_->amount } @$transactions; + my $total = sum map { $_->amount } @{ $invoice->transactions }; return $::form->round_amount($total, 5); @@ -304,8 +305,8 @@ sub test_default_invoice_one_item_19_without_skonto() { $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, one item, 19% tax, without_skonto'; @@ -344,8 +345,8 @@ sub test_default_invoice_one_item_19_without_skonto_overpaid() { $params{amount} = '-10.00'; $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, one item, 19% tax, without_skonto'; @@ -382,8 +383,8 @@ sub test_default_invoice_two_items_19_7_tax_with_skonto() { $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax with_skonto_pt'; @@ -417,8 +418,8 @@ sub test_default_invoice_two_items_19_7_tax_with_skonto_tax_included() { $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax with_skonto_pt'; @@ -455,8 +456,8 @@ sub test_default_invoice_two_items_19_7_without_skonto() { $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax without skonto'; @@ -487,8 +488,8 @@ sub test_default_invoice_two_items_19_7_without_skonto_incomplete_payment() { transdate => DateTime->today_local->to_kivitendo, ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax without skonto incomplete payment'; @@ -523,8 +524,8 @@ sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments() { transdate => DateTime->today_local->to_kivitendo ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax not included'; @@ -566,8 +567,8 @@ sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_fin transdate => DateTime->today_local->to_kivitendo ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax not included'; @@ -608,8 +609,8 @@ sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_fi transdate => DateTime->today_local->to_kivitendo ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax not included'; @@ -646,8 +647,8 @@ sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_fi transdate => DateTime->today_local->to_kivitendo ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax not included'; @@ -688,8 +689,8 @@ sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto $params{payment_type} = 'difference_as_skonto'; $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, one item, 19% tax, without_skonto'; @@ -726,8 +727,8 @@ sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto $params{payment_type} = 'difference_as_skonto'; $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, one item, 19% tax, without_skonto'; @@ -755,8 +756,8 @@ sub test_default_purchase_invoice_two_charts_19_7_without_skonto() { $purchase_invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice->transactions); - my $total = total_amount($purchase_invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice); + my $total = total_amount($purchase_invoice); my $title = 'default invoice, two items, 19/7% tax without skonto'; @@ -780,8 +781,8 @@ sub test_default_purchase_invoice_two_charts_19_7_with_skonto() { $purchase_invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice->transactions); - my $total = total_amount($purchase_invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice); + my $total = total_amount($purchase_invoice); my $title = 'default invoice, two items, 19/7% tax without skonto'; @@ -801,8 +802,8 @@ sub test_default_purchase_invoice_two_charts_19_7_tax_partial_unrounded_payment_ chart_id => $bank_account->chart_id, transdate => DateTime->today_local->to_kivitendo ); - my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice->transactions); - my $total = total_amount($purchase_invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice); + my $total = total_amount($purchase_invoice); my $title = 'default purchase_invoice, two charts, 19/7% tax multiple payments with final difference as skonto'; @@ -836,8 +837,8 @@ sub test_default_purchase_invoice_two_charts_19_7_tax_without_skonto_multiple_pa transdate => DateTime->today_local->to_kivitendo ); - my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice->transactions); - my $total = total_amount($purchase_invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice); + my $total = total_amount($purchase_invoice); my $title = 'default purchase_invoice, two charts, 19/7% tax multiple payments with final difference as skonto'; @@ -870,8 +871,8 @@ sub test_default_invoice_two_items_19_7_tax_with_skonto_50_50() { $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, two items, 19/7% tax with_skonto_pt 50/50'; @@ -908,8 +909,8 @@ sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25() { $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25'; @@ -945,8 +946,8 @@ sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25_tax_included() { $invoice->pay_invoice( %params ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25'; @@ -984,8 +985,8 @@ sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25_multiple() { transdate => DateTime->today_local->to_kivitendo ); - my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions); - my $total = total_amount($invoice->transactions); + my ($number_of_payments, $paid_amount) = number_of_payments($invoice); + my $total = total_amount($invoice); my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25';