Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3ed17038

Von G. Richardson vor mehr als 4 Jahren hinzugefügt

  • ID 3ed1703890abcd350af3604740ad86a7d28ba232
  • Vorgänger 4858eee4
  • Nachfolger 1b112bd3

Konjunkturprogramm - t/tax/tax.t mit Skontozahlung testen

Unterschiede anzeigen:

t/tax/tax.t
1
use Test::More tests => 38;
1
use Test::More tests => 46;
2 2
use Test::Deep qw(cmp_deeply);
3 3

  
4 4
use strict;
......
13 13
use SL::DB::Vendor;
14 14
use SL::DB::Invoice;
15 15
use SL::DB::GLTransaction;
16
use SL::DB::AccTransaction;
16 17
use SL::DB::Part;
17 18
use SL::DB::PaymentTerm;
18 19
use SL::DBUtils qw(selectall_hashref_query);
......
25 26
Support::TestSetup::login();
26 27
my $dbh = SL::DB->client->dbh;
27 28

  
28
my $test_kontenrahmen = 'skr03';
29

  
30 29
clear_up();
31 30

  
32 31
# TODOs: Storno muß noch korrekt funktionieren
......
50 49
my ($ar_accno, $ap_accno);
51 50
my ($chart_reisekosten_accno, $chart_cash_accno, $chart_bank_accno);
52 51

  
52
my ($skonto_5, $skonto_16, $skonto_7, $skonto_19); # store acc_trans entries during tests
53

  
54
my $test_kontenrahmen = $::instance_conf->get_coa eq 'Germany-DATEV-SKR04EU' ? 'skr04' : 'skr03';
53 55

  
54 56
if ( $test_kontenrahmen eq 'skr03' ) {
55 57

  
56 58
  is(SL::DB::Default->get->coa, 'Germany-DATEV-SKR03EU', "coa SKR03 ok");
57 59

  
58
  $chart_vst_19 = '1776';
59
  $chart_vst_16 = '1775';
60
  $chart_vst_5  = '1773';
61
  $chart_vst_7  = '1771';
60
  $chart_ust_19 = '1776';
61
  $chart_ust_16 = '1775';
62
  $chart_ust_5  = '1773';
63
  $chart_ust_7  = '1771';
62 64

  
63
  $chart_ust_19 = '1576';
64
  $chart_ust_16 = '1575';
65
  $chart_ust_5  = '1568';
66
  $chart_ust_7  = '1571';
65
  $chart_vst_19 = '1576';
66
  $chart_vst_16 = '1575';
67
  $chart_vst_5  = '1568';
68
  $chart_vst_7  = '1571';
67 69

  
68 70
  $income_19_accno = '8400';
69 71
  $income_7_accno  = '8300';
70 72

  
71 73
  $chart_reisekosten_accno = 4660;
72 74
  $chart_cash_accno        = 1000;
75
  $chart_bank_accno        = 1200;
73 76

  
74 77
  $ar_accno = 1400;
75 78
  $ap_accno = 1600;
76 79

  
77 80
} elsif ( $test_kontenrahmen eq 'skr04') { # skr04 - test can be ran manually by running t/000setup_database.t with coa for SKR04
78 81
  is(SL::DB::Default->get->coa, 'Germany-DATEV-SKR04EU', "coa SKR04 ok");
79
  $chart_ust_19 = '1406';
80
  $chart_ust_16 = '1405';
81
  $chart_ust_5  = '1403';
82
  $chart_ust_7  = '1401';
82
  $chart_vst_19 = '1406';
83
  $chart_vst_16 = '1405';
84
  $chart_vst_5  = '1403';
85
  $chart_vst_7  = '1401';
83 86

  
84
  $chart_vst_19 = '3806';
85
  $chart_vst_16 = '3805';
86
  $chart_vst_5  = '3803';
87
  $chart_vst_7  = '3801';
87
  $chart_ust_19 = '3806';
88
  $chart_ust_16 = '3805';
89
  $chart_ust_5  = '3803';
90
  $chart_ust_7  = '3801';
88 91

  
89 92
  $income_19_accno = '4400';
90 93
  $income_7_accno  = '4300';
91 94

  
92 95
  $chart_reisekosten_accno = 6650;
93 96
  $chart_cash_accno        = 1600;
97
  $chart_bank_accno        = 1800;
94 98

  
95 99
  $ar_accno = 1200;
96 100
  $ap_accno = 3300;
......
111 115

  
112 116
my $chart_reisekosten = SL::DB::Manager::Chart->find_by(accno => $chart_reisekosten_accno) or die;
113 117
my $chart_cash        = SL::DB::Manager::Chart->find_by(accno => $chart_cash_accno) or die;
118
my $chart_bank        = SL::DB::Manager::Chart->find_by(accno => $chart_bank_accno) or die;
119

  
120
my $payment_terms = create_payment_terms();
114 121

  
115 122
is(defined SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.05), 1, "tax for taxkey 2 with 5% was created ok");
116
is(defined SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.16, chart_id => $tax_vst_16->id), 1, "new sales tax for taxkey 3 with 16% exists ok");
117
is(defined SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19, chart_id => $tax_vst_19->id), 1, "old sales tax for taxkey 3 with 19% exists ok");
118
is(defined SL::DB::Manager::Tax->find_by(taxkey => 5, rate => 0.16, chart_id => $tax_vst_16->id), 1, "new sales tax for taxkey 5 with 16% exists ok");
123
is(defined SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.16, chart_id => $tax_ust_16->id), 1, "new sales tax for taxkey 3 with 16% exists ok");
124
is(defined SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19, chart_id => $tax_ust_19->id), 1, "old sales tax for taxkey 3 with 19% exists ok");
125
is(defined SL::DB::Manager::Tax->find_by(taxkey => 5, rate => 0.16, chart_id => $tax_ust_16->id), 1, "new sales tax for taxkey 5 with 16% exists ok");
119 126

  
120
is(defined SL::DB::Manager::Tax->find_by(taxkey => 7, rate => 0.16, chart_id => $tax_ust_16->id), 1, "old purchase tax for taxkey 7 with 16% exists ok");
121
# is(defined SL::DB::Manager::Tax->find_by(taxkey => 8, rate => 0.07, chart_id => $tax_ust_16->id), 1, "old purchase tax for taxkey 7 with 16% exists ok");
122
is(defined SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.19, chart_id => $tax_ust_19->id), 1, "old purchase tax for taxkey 9 with 19% exists ok");
123
is(defined SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.16, chart_id => $tax_ust_16->id), 1, "new purchase tax for taxkey 9 with 16% exists ok");
127
# is(defined SL::DB::Manager::Tax->find_by(taxkey => 7, rate => 0.16, chart_id => $tax_ust_16->id), 1, "old purchase tax for taxkey 7 with 16% exists ok");
128
is(defined SL::DB::Manager::Tax->find_by(taxkey => 8, rate => 0.07, chart_id => $tax_vst_7->id ), 1, "purchase tax for taxkey 8 with 7% exists ok");
129
is(defined SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.19, chart_id => $tax_vst_19->id), 1, "old purchase tax for taxkey 9 with 19% exists ok");
130
is(defined SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.16, chart_id => $tax_vst_16->id), 1, "new purchase tax for taxkey 9 with 16% exists ok");
124 131

  
125
my $vendor   = new_vendor(  name => 'Testvendor')->save;
126
my $customer = new_customer(name => 'Testcustomer')->save;
132
my $vendor   = new_vendor(  name => 'Testvendor',   payment_id => $payment_terms->id)->save;
133
my $customer = new_customer(name => 'Testcustomer', payment_id => $payment_terms->id)->save;
127 134

  
128 135
# cmp_ok($chart_income_7->get_active_taxkey($date_2020_1)->tax->rate, '==', 0.07, "get_active_taxkey rate for 8300 in 2020_1 ok");
129 136
# cmp_ok($chart_income_7->get_active_taxkey($date_2020_2)->tax->rate, '==', 0.05, "get_active_taxkey rate for 8300 in 2020_2 ok");
......
238 245
# would select the entries from the dropdown, as they may differ from the
239 246
# default, so we have to pass the tax we want to create_ap_transaction
240 247

  
241
my $tax_9_16_old = SL::DB::Manager::Tax->find_by(taxkey => 7, rate => 0.16, chart_id => $tax_ust_16->id);
242
my $tax_9_19     = SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.19, chart_id => $tax_ust_19->id);
243
my $tax_9_16     = SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.16, chart_id => $tax_ust_16->id);
244
my $tax_8_7      = SL::DB::Manager::Tax->find_by(taxkey => 8, rate => 0.07, chart_id => $tax_ust_7->id);
245
my $tax_8_5      = SL::DB::Manager::Tax->find_by(taxkey => 8, rate => 0.05, chart_id => $tax_ust_5->id);
248
my $tax_9_16_old = SL::DB::Manager::Tax->find_by(taxkey => 7, rate => 0.16, chart_id => $tax_vst_16->id);
249
my $tax_9_19     = SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.19, chart_id => $tax_vst_19->id) or die "missing 9_19";
250
my $tax_9_16     = SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.16, chart_id => $tax_vst_16->id) or die "missing 9_16";
251
my $tax_8_7      = SL::DB::Manager::Tax->find_by(taxkey => 8, rate => 0.07, chart_id => $tax_vst_7->id)  or die "missing 8_7";
252
my $tax_8_5      = SL::DB::Manager::Tax->find_by(taxkey => 8, rate => 0.05, chart_id => $tax_vst_5->id)  or die "missing 8_5";
246 253

  
247 254
# simulate user selecting the "correct" taxes in dropdown:
248 255
my $ap_transaction_2006   = create_ap_transaction_for_date('2006',   $date_2006,   undef, $tax_9_16_old, $tax_8_7);
......
317 324
my $result = &get_account_balances;
318 325
# print Dumper($result);
319 326
is_deeply( &get_account_balances,
320
 [
327
        [
321 328
          # {
322 329
          #   'accno' => '1000',
323 330
          #   # 'description' => 'Kasse',
......
392 399
        'account balances after invoices'
393 400
);
394 401

  
402
note('testing payments with skonto');
403

  
404
my %params = ( chart_id     => $chart_bank->id,
405
               payment_type => 'with_skonto_pt',
406
             );
407

  
408
$sales_invoice_2020_2->pay_invoice( %params,
409
                                    amount    => $sales_invoice_2020_2->amount_less_skonto,
410
                                    transdate => $date_2020_2->to_kivitendo,
411
                                  );
412

  
413

  
414
$skonto_5 = SL::DB::Manager::AccTransaction->find_by(trans_id => $sales_invoice_2020_2->id, amount => -5.25);
415
like($skonto_5->chart->description, qr/Skonti.*5/, "sales_invoice 2020_2 paid in 2020_2 - skonto 5% ok");
416
$skonto_16 = SL::DB::Manager::AccTransaction->find_by(trans_id => $sales_invoice_2020_2->id, amount => -5.80);
417
like($skonto_16->chart->description, qr/Skonti.*16/, "sales_invoice 2020_2 paid in 2020_2 - skonto 16% ok");
418

  
419
$sales_invoice_2020_1->pay_invoice( %params,
420
                                    amount    => $sales_invoice_2020_1->amount_less_skonto,
421
                                    transdate => $date_2020_2->to_kivitendo,
422
                                  );
423
$skonto_7 = SL::DB::Manager::AccTransaction->find_by(trans_id => $sales_invoice_2020_1->id, amount => -5.35);
424
like($skonto_7->chart->description, qr/Skonti.*7/, "sales_invoice 2020_1 paid with skonto in 2020_2 - skonto 7% ok");
425
$skonto_19 = SL::DB::Manager::AccTransaction->find_by(trans_id => $sales_invoice_2020_1->id, amount => -5.95);
426
like($skonto_19->chart->description, qr/Skonti.*19/, "sales_invoice 2020_1 paid with skonto in 2020_2 - skonto 19% ok");
427

  
428
$ap_transaction_2020_1->pay_invoice( %params,
429
                                     amount    => $ap_transaction_2020_1->amount_less_skonto,
430
                                     transdate => $date_2020_2->to_kivitendo,
431
                                   );
432
$skonto_7 = SL::DB::Manager::AccTransaction->find_by(trans_id => $ap_transaction_2020_1->id, amount => 5.35);
433
like($skonto_7->chart->description, qr/Skonti.*7/, "ap transaction 2020_1 paid with skonto in 2020_2 - skonto 7% ok");
434
$skonto_19 = SL::DB::Manager::AccTransaction->find_by(trans_id => $ap_transaction_2020_1->id, amount => 5.95);
435
like($skonto_19->chart->description, qr/Skonti.*19/, "ap transaction 2020_1 paid with skonto in 2020_2 - skonto 19% ok");
436

  
437

  
438
$ap_transaction_2020_2->pay_invoice( %params,
439
                                     amount    => $ap_transaction_2020_2->amount_less_skonto,
440
                                     transdate => $date_2021->to_kivitendo,
441
                                   );
442
$skonto_5 = SL::DB::Manager::AccTransaction->find_by(trans_id => $ap_transaction_2020_2->id, amount => 5.25);
443
like($skonto_5->chart->description, qr/Skonti.*5/, "ap transaction 2020_2 paid in 2021 - skonto 5% ok");
444

  
445
$skonto_16 = SL::DB::Manager::AccTransaction->find_by(trans_id => $ap_transaction_2020_2->id, amount => 5.80);
446
like($skonto_16->chart->description, qr/Skonti.*16/, "sales_invoice 2020_2 paid in 2021 - skonto 16% ok");
447

  
395 448
clear_up();
396 449

  
397 450
done_testing();
......
408 461
    transdate    => $transdate,
409 462
    customer     => $customer,
410 463
    deliverydate => $deliverydate,
464
    payment_terms => $payment_terms,
411 465
    taxincluded  => 0,
412 466
    invoiceitems => [ create_invoice_item(part => $part1, qty => 10, sellprice => 10),
413 467
                      create_invoice_item(part => $part2, qty => 10, sellprice => 10),
......
451 505
    taxincluded  => 0,
452 506
    transdate    => $transdate,
453 507
    deliverydate => $deliverydate,
508
    payment_id   => $payment_terms->id,
454 509
    ap_chart     => SL::DB::Manager::Chart->find_by(accno => $ap_accno), # pass ap_chart, as it is hardcoded for SKR03 in SL::Dev::Record
455 510
    bookings     => [
456 511
                     {
......
539 594
  SL::DB::Manager::Part->delete_all(all => 1);
540 595
  SL::DB::Manager::Customer->delete_all(all => 1);
541 596
  SL::DB::Manager::Vendor->delete_all(all => 1);
597
  SL::DB::Manager::PaymentTerm->delete_all(all => 1);
542 598
};
543 599

  
544 600
1;

Auch abrufbar als: Unified diff