use Data::Dumper;
my ($customer, $vendor, $currency_id, $unit, $tax, $tax0, $tax7, $tax_9, $payment_terms, $bank_account);
-my ($transdate1, $transdate2, $currency);
+my ($currency);
my ($ar_chart,$bank,$ar_amount_chart, $ap_chart, $ap_amount_chart);
my ($ar_transaction, $ap_transaction);
+my $dt = DateTime->new(year => 2019, month => 1, day => 12);
+my $dt_5 = DateTime->new(year => 2019, month => 1, day => 17);
+my $dt_10 = DateTime->new(year => 2019, month => 1, day => 22);
+
sub clear_up {
SL::DB::Manager::BankTransactionAccTrans->delete_all(all => 1);
clear_up();
- $transdate1 = DateTime->today;
- $transdate2 = DateTime->today->add(days => 5);
$tax = SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19, %{ $params{tax} }) || croak "No tax";
$tax7 = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07) || croak "No tax for 7\%";
iban => 'DE12500105170648489890',
bic => 'TESTBIC',
account_number => '648489890',
- mandate_date_of_signature => $transdate1,
+ mandate_date_of_signature => $dt,
mandator_id => 'foobar',
bank => 'Geizkasse',
bank_code => 'G1235',
invnumber => $params{invnumber} || undef, # let it use its own invnumber
amount => $amount,
netamount => $netamount,
- transdate => $transdate1,
+ transdate => $dt,
taxincluded => $params{taxincluded } || 0,
customer_id => $customer->id,
taxzone_id => $customer->taxzone_id,
invnumber => $params{invnumber} || $testname,
amount => $amount,
netamount => $netamount,
- transdate => $transdate1,
+ transdate => $dt,
taxincluded => 0,
vendor_id => $vendor->id,
taxzone_id => $vendor->taxzone_id,
$ar_transaction = test_ar_transaction(invnumber => 'salesinv1');
- my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction,
+ transdate => $dt,
+ valutadate => $dt) or die "Couldn't create bank_transaction";
$::form->{invoice_ids} = {
$bt->id => [ $ar_transaction->id ]
my $bt = create_bank_transaction(record => $ar_transaction,
bank_chart_id => $bank->id,
+ transdate => $dt,
+ valutadate => $dt,
amount => $ar_transaction->amount_less_skonto
) or die "Couldn't create bank_transaction";
my $bt = create_bank_transaction(record => $ar_transaction,
bank_chart_id => $bank->id,
+ transdate => $dt,
+ valutadate => $dt,
amount => 160.15,
) or die "Couldn't create bank_transaction";
$::form->{invoice_ids} = {
my $bt = create_bank_transaction(record => $ar_transaction_1,
amount => ($ar_transaction_1->amount + $ar_transaction_2->amount),
purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber,
+ transdate => $dt,
+ valutadate => $dt,
bank_chart_id => $bank->id,
) or die "Couldn't create bank_transaction";
my $bt = create_bank_transaction(record => $ar_transaction_1,
bank_chart_id => $bank->id,
+ transdate => $dt,
+ valutadate => $dt,
amount => $ar_transaction_1->amount_less_skonto * 2 + $ar_transaction_3->amount
) or die "Couldn't create bank_transaction";
# amount 135 > 119
my $bt = create_bank_transaction(record => $ar_transaction,
bank_chart_id => $bank->id,
+ transdate => $dt,
+ valutadate => $dt,
amount => 135
) or die "Couldn't create bank_transaction";
my $bt_1 = create_bank_transaction(record => $ar_transaction,
bank_chart_id => $bank->id,
+ transdate => $dt,
+ valutadate => $dt,
amount => 10
) or die "Couldn't create bank_transaction";
my $bt_2 = create_bank_transaction(record => $ar_transaction,
amount => 119,
- transdate => DateTime->today->add(days => 5),
+ transdate => $dt_5,
+ valutadate => $dt_5,
bank_chart_id => $bank->id,
) or die "Couldn't create bank_transaction";
# amount 100 < 119
my $bt = create_bank_transaction(record => $ar_transaction,
bank_chart_id => $bank->id,
+ transdate => $dt,
+ valutadate => $dt,
amount => 100
) or die "Couldn't create bank_transaction";
my $credit_note = create_credit_note(
invnumber => 'cn 1',
customer => $customer,
+ transdate => $dt,
taxincluded => 0,
invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70),
create_invoice_item(part => $part2, qty => 10, sellprice => 50),
my $bt = create_bank_transaction(record => $credit_note,
amount => $credit_note->amount,
bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
+ transdate => $dt_10,
);
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($credit_note);
is($agreement, 13, "points for credit note ok");
invnumber => $params{invnumber} || 'test_neg_ap_transaction',
amount => $amount,
netamount => $netamount,
- transdate => $transdate1,
+ transdate => $dt,
taxincluded => 0,
vendor_id => $vendor->id,
taxzone_id => $vendor->taxzone_id,
my $bt = create_bank_transaction(record => $invoice,
amount => $invoice->amount,
bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
+ transdate => $dt_10,
);
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice);
invnumber => 'test_neg_ap_transaction',
amount => $amount,
netamount => $netamount,
- transdate => $transdate1,
+ transdate => $dt,
taxincluded => 0,
vendor_id => $vendor->id,
taxzone_id => $vendor->taxzone_id,
invnumber => 'test_neg_ap_transaction_two',
amount => $amount_two,
netamount => $netamount_two,
- transdate => $transdate1,
+ transdate => $dt,
taxincluded => 0,
vendor_id => $vendor->id,
taxzone_id => $vendor->taxzone_id,
my $bt = create_bank_transaction(record => $invoice_two,
amount => $invoice_two->amount + $invoice->amount,
bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
+ transdate => $dt_10,
);
# my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice_two);
# is($agreement, 15, "points for negative ap transaction ok");
invnumber => $params{invnumber} || $testname,
amount => $amount,
netamount => $netamount,
- transdate => $transdate1,
+ transdate => $dt,
taxincluded => 0,
vendor_id => $vendor->id,
taxzone_id => $vendor->taxzone_id,
my $bt = create_bank_transaction(record => $invoice,
amount => $invoice->amount,
bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
+ transdate => $dt_10,
);
$::form->{invoice_ids} = {
$bt->id => [ $invoice->id ]
invnumber => $params{invnumber} || $testname,
amount => $amount,
netamount => $netamount,
- transdate => $transdate1,
+ transdate => $dt,
taxincluded => 0,
vendor_id => $vendor->id,
taxzone_id => $vendor->taxzone_id,
my $bt = create_bank_transaction(record => $invoice,
amount => $invoice->amount-100,
bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
+ transdate => $dt_10,
);
$::form->{invoice_ids} = {
$bt->id => [ $invoice->id ]
my $bt2 = create_bank_transaction(record => $invoice,
amount => 100,
bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
+ transdate => $dt_10,
);
$::form->{invoice_ids} = {
$bt2->id => [ $invoice->id ]
invnumber => '20172201',
customer => $customer,
taxincluded => 0,
+ transdate => $dt,
invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70),
create_invoice_item(part => $part2, qty => 10, sellprice => -50),
]
my $bt = create_bank_transaction(record => $neg_sales_inv,
amount => $neg_sales_inv->amount,
bank_chart_id => $bank->id,
- transdate => DateTime->today,
+ transdate => $dt,
+ valutadate => $dt,
);
$::form->{invoice_ids} = {
$bt->id => [ $neg_sales_inv->id ]
my $testname = 'test_bt_rule1';
- $ar_transaction = test_ar_transaction(invnumber => 'bt_rule1');
+ $ar_transaction = test_ar_transaction(invnumber => 'bt_rule1', transdate => $dt);
- my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction, transdate => $dt) or die "Couldn't create bank_transaction";
$ar_transaction->load;
$bt->load;
my $testname = 'test_sepa_export';
- $ar_transaction = test_ar_transaction(invnumber => 'sepa1');
+ $ar_transaction = test_ar_transaction(invnumber => 'sepa1', transdate => $dt);
- my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction, transdate => $dt) or die "Couldn't create bank_transaction";
my $se = create_sepa_export();
my $sei = create_sepa_export_item(
chart_id => $bank->id,
my $bt1 = create_bank_transaction(record => $ar_transaction_1,
amount => $ar_transaction_1->amount,
purpose => "Rechnung10000 beinahe",
+ transdate => $dt,
bank_chart_id => $bank->id,
) or die "Couldn't create bank_transaction";
my $bt2 = create_bank_transaction(record => $ar_transaction_1,
amount => $ar_transaction_1->amount + 0.01,
purpose => "sicher salesinv20000 vielleicht",
+ transdate => $dt,
bank_chart_id => $bank->id,
) or die "Couldn't create bank_transaction";
my $bt3 = create_bank_transaction(record => $ar_transaction_3,
amount => $ar_transaction_3->amount,
purpose => "sicher Rechnung10000 vielleicht",
+ transdate => $dt,
bank_chart_id => $bank->id,
) or die "Couldn't create bank_transaction";