X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fcontrollers%2Fcsvimport%2Fartransactions.t;h=6c902c33e9bb158c8ff2319ce8c36b616a44ae1d;hb=4ae9f9c0f08ee5d7d1324535498b592c0ad4d989;hp=c4df0a78be77ae578c9972d3651311267b0db334;hpb=cdc396f5543250ac2cd9ad5b9b45bd2806c8e6c5;p=kivitendo-erp.git diff --git a/t/controllers/csvimport/artransactions.t b/t/controllers/csvimport/artransactions.t index c4df0a78b..6c902c33e 100644 --- a/t/controllers/csvimport/artransactions.t +++ b/t/controllers/csvimport/artransactions.t @@ -26,11 +26,16 @@ use SL::DB::Chart; use SL::DB::AccTransaction; my ($customer, $currency_id, $employee, $taxzone, $project, $department); +my ($transdate, $transdate_string); sub reset_state { # Create test data my %params = @_; + $transdate = DateTime->today_local; + $transdate->set_year(2019) if $transdate->year == 2020; # hardcode for 2019 in 2020, because of tax rate change in Germany + $transdate_string = $transdate->to_kivitendo; + $params{$_} ||= {} for qw(buchungsgruppe customer tax); clear_up(); @@ -70,7 +75,7 @@ sub test_import { ); $controller->load_default_profile; $controller->profile->set( - encoding => 'utf-8', + charset => 'utf-8', sep_char => ',', quote_char => '"', numberformat => $::myconfig{numberformat}, @@ -86,7 +91,7 @@ sub test_import { ); # $csv_artransactions_import->init_vc_by; - $csv_artransactions_import->run({test => 0}); + $csv_artransactions_import->run(test => 0); # don't try and save objects that have errors $csv_artransactions_import->save_objects unless scalar @{$csv_artransactions_import->controller->data->[0]->{errors}}; @@ -96,6 +101,7 @@ sub test_import { ##### manually create an ar transaction from scratch, testing the methods $::myconfig{numberformat} = '1000.00'; +$::myconfig{dateformat} = 'dd.mm.yyyy'; my $old_locale = $::locale; # set locale to en so we can match errors $::locale = Locale->new('en'); @@ -109,7 +115,7 @@ my $ar = SL::DB::Invoice->new( currency_id => $currency_id, taxincluded => 'f', customer_id => $customer->id, - transdate => DateTime->today, + transdate => $transdate, employee_id => SL::DB::Manager::Employee->current->id, transactions => [], ); @@ -138,7 +144,7 @@ is scalar @{$ar->transactions}, 3, 'manual invoice has 3 acc_trans entries'; $ar->pay_invoice( chart_id => SL::DB::Manager::Chart->find_by(accno => '1200')->id, # bank amount => $ar->open_amount, - transdate => DateTime->now->to_kivitendo, + transdate => $transdate, payment_type => 'without_skonto', # default if not specified ); $result = $ar->validate_acc_trans(debug => 0); @@ -152,10 +158,10 @@ my ($entries, $entry, $file); # to debug errors in certain tests, run after test_import: # die Dumper($entry->{errors}); ##### basic test -$file = \<{object}->amount, '189.78', 'ar amount tax not included is 189.78'; is $entry->{object}->netamount, '159.48', 'ar netamount tax not included is 159.48'; ##### test for duplicate invnumber -$file = \<{object}->validate_acc_trans; is $entry->{errors}->[0], 'Error: invnumber already exists', 'detects verify_amount differences'; ##### test for no invnumber given -$file = \<{object}->validate_acc_trans; is $entry->{object}->invnumber =~ /^\d+$/, 1, 'invnumber assigned automatically'; ##### basic test without amounts in Rechnung, only specified in AccTransaction -$file = \<round_amount($entry->{object}->transactions->[0]->amount, 2), '159.4 is $::form->round_amount($entry->{object}->transactions->[0]->amount, 2), 159.48, 'invoice 1 ar amount is 159.48'; ##### basic test: credit_note -$file = \<{object}->amount, '-189.78', 'credit note amount tax not included is is $entry->{object}->netamount, '-159.48', 'credit note netamount tax not included is 159.48'; #### verify_amount differs: max_amount_diff = 0.02, 189.80 is ok, 189.81 is not -$file = \<[0]; is $entry->{errors}->[0], 'Amounts differ too much', 'detects verify_amount differences'; ##### direct debit -$file = \<{object}->validate_acc_trans; is $entry->{object}->direct_debit, '1', 'direct debit'; #### tax included -$file = \<round_amount($entry->{object}->netamount, 2), '159.48', 'taxincluded is $::form->round_amount($entry->{object}->transactions->[0]->amount, 2), '159.48', 'taxincluded acc_trans netamount'; #### multiple tax included -$file = \<