]> wagnertech.de Git - mfinanz.git/blobdiff - t/bank/bank_transactions.t
Testfall: closedto für bank_transactions angepasst
[mfinanz.git] / t / bank / bank_transactions.t
index 067270b7b370f3ab726c0997ceb28bf4150acaf4..8b38424ec9e8b0903f585393542bf696739e5700 100644 (file)
@@ -1,4 +1,4 @@
-use Test::More tests => 282;
+use Test::More tests => 289;
 
 use strict;
 
@@ -15,6 +15,7 @@ use SL::DB::BankTransactionAccTrans;
 use SL::DB::Buchungsgruppe;
 use SL::DB::Currency;
 use SL::DB::Customer;
+use SL::DB::Default;
 use SL::DB::Vendor;
 use SL::DB::Invoice;
 use SL::DB::Unit;
@@ -50,6 +51,7 @@ sub clear_up {
   SL::DB::Manager::BankAccount->delete_all(all => 1);
   SL::DB::Manager::PaymentTerm->delete_all(all => 1);
   SL::DB::Manager::Currency->delete_all(where => [ name => 'CUR' ]);
+  # SL::DB::Manager::Default->delete_all(all => 1);
 };
 
 my $bt_controller;
@@ -92,7 +94,6 @@ test_two_neg_ap_transaction();
 test_one_inv_and_two_invoices_with_skonto_exact();
 test_bt_error();
 test_full_workflow_ar_multiple_inv_skonto_reconciliate_and_undo();
-
 reset_state();
 test_sepa_export();
 
@@ -101,6 +102,7 @@ test_bt_rule1();
 reset_state();
 test_two_banktransactions();
 # remove all created data at end of test
+test_closedto();
 clear_up();
 
 done_testing();
@@ -1171,6 +1173,37 @@ sub test_two_banktransactions {
   # is(scalar(@$proposals)         , 1  , "$testname: one proposal");
 
 };
+sub test_closedto {
+
+  my $testname = 'closedto';
 
+  my $ar_transaction_1 = test_ar_transaction(invnumber => 'salesinv10000' , amount => 2912.00 );
+  my $bt1 = create_bank_transaction(record        => $ar_transaction_1,
+                                    amount        => $ar_transaction_1->amount,
+                                    purpose       => "Rechnung10000 beinahe",
+                                    bank_chart_id => $bank->id,
+                                  ) or die "Couldn't create bank_transaction";
+
+  $bt1->valutadate(DateTime->new(year => 2019, month => 12, day => 30));
+  $bt1->save();
+
+  is($bt1->closed_period, 0, "$testname undefined closedto");
+
+  my $defaults = SL::DB::Manager::Default->get_all(limit => 1)->[0];
+  $defaults->closedto(DateTime->new(year => 2019, month => 12, day => 31));
+  $defaults->save();
+  $::instance_conf->reload->data;
+  $bt1->load();
+  is($bt1->closed_period, 1, "$testname defined and next date closedto");
+
+  $bt1->valutadate(DateTime->new(year => 2020, month => 1, day => 1));
+  $bt1->save();
+  $bt1->load();
+
+  is($bt1->closed_period, 0, "$testname defined closedto and next date valuta");
+  $defaults->closedto(undef);
+  $defaults->save();
+
+}
 
 1;