From df1838155963d6de56cfb001365982a292820f45 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Thu, 31 Oct 2019 15:06:44 +0100 Subject: [PATCH] =?utf8?q?add=5F{ap|ar}=5Famount=5Frow=20ber=C3=BCcksichti?= =?utf8?q?gen=20gldate?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ansonsten konnte gldate in ar/ap und acc_trans abweichen, wenn gldate explizit gesetzt war und nicht dem aktuellen Tag entsprach. --- SL/DB/Invoice.pm | 2 ++ SL/DB/PurchaseInvoice.pm | 2 ++ t/ar/ar.t | 15 ++++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 0e27f8adf..38ec9c0f7 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -362,6 +362,7 @@ sub add_ar_amount_row { chart_id => $params{chart}->id, chart_link => $params{chart}->link, transdate => $self->transdate, + gldate => $self->gldate, taxkey => $tax->taxkey, tax_id => $tax->id, project_id => $params{project_id}, @@ -376,6 +377,7 @@ sub add_ar_amount_row { chart_id => $tax->chart_id, chart_link => $tax->chart->link, transdate => $self->transdate, + gldate => $self->gldate, taxkey => $tax->taxkey, tax_id => $tax->id, ); diff --git a/SL/DB/PurchaseInvoice.pm b/SL/DB/PurchaseInvoice.pm index 93fc1fe30..a50884cb1 100644 --- a/SL/DB/PurchaseInvoice.pm +++ b/SL/DB/PurchaseInvoice.pm @@ -182,6 +182,7 @@ sub add_ap_amount_row { chart_id => $params{chart}->id, chart_link => $params{chart}->link, transdate => $self->transdate, + gldate => $self->gldate, taxkey => $tax->taxkey, tax_id => $tax->id, project_id => $params{project_id}, @@ -196,6 +197,7 @@ sub add_ap_amount_row { chart_id => $tax->chart_id, chart_link => $tax->chart->link, transdate => $self->transdate, + gldate => $self->gldate, taxkey => $tax->taxkey, tax_id => $tax->id, project_id => $params{project_id}, diff --git a/t/ar/ar.t b/t/ar/ar.t index dfb875644..c5583f17a 100644 --- a/t/ar/ar.t +++ b/t/ar/ar.t @@ -1,5 +1,5 @@ use strict; -use Test::More tests => 6; +use Test::More tests => 7; use lib 't'; use Support::TestSetup; @@ -56,6 +56,7 @@ if ( $inv ) { is($number_of_acc_trans , 5 , "number of transactions"); is($inv->datepaid->to_kivitendo , DateTime->today->to_kivitendo , "datepaid"); is($inv->amount - $inv->paid , 0 , "paid = amount "); + is($inv->gldate->to_kivitendo, $inv->transactions->[0]->gldate->to_kivitendo, "gldate matches in ar and acc_trans"); } else { ok 0, "couldn't find first invoice"; } @@ -92,7 +93,8 @@ sub _ar { my $amount = $params{amount} || croak "ar needs param amount"; my $customer = $params{customer} || croak "ar needs param customer"; - my $date = $params{date} || DateTime->today; + my $transdate = $params{transdate} || DateTime->today; + my $gldate = $params{gldate} || DateTime->today->add(days => 1); my $with_payment = $params{with_payment} || 0; # SL::DB::Invoice has a _before_save_set_invnumber hook, so we don't need to pass invnumber @@ -100,7 +102,8 @@ sub _ar { invoice => 0, amount => $amount, netamount => $amount, - transdate => $date, + transdate => $transdate, + gldate => $gldate, taxincluded => 'f', customer_id => $customer->id, taxzone_id => $customer->taxzone_id, @@ -144,14 +147,16 @@ sub _ar_with_tax { my $amount = $params{amount} || croak "ar needs param amount"; my $customer = $params{customer} || croak "ar needs param customer"; - my $date = $params{date} || DateTime->today; + my $transdate = $params{transdate} || DateTime->today; + my $gldate = $params{gldate} || DateTime->today->add(days => 1); my $with_payment = $params{with_payment} || 0; my $invoice = SL::DB::Invoice->new( invoice => 0, amount => $amount, netamount => $amount, - transdate => $date, + transdate => $transdate, + gldate => $gldate, taxincluded => 'f', customer_id => $customer->id, taxzone_id => $customer->taxzone_id, -- 2.20.1