Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 57814206

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

  • ID 578142061d9297223f05c2a9ac021d3d8e3ca0cb
  • Vorgänger da35c4e7
  • Nachfolger 51504ef4

price_tax_calculator.t - in 2020 das Jahr 2019 nehmen

Unterschiede anzeigen:

t/db_helper/price_tax_calculator.t
24 24
use SL::DB::TaxZone;
25 25

  
26 26
my ($customer, @parts, $buchungsgruppe, $buchungsgruppe7, $unit, $employee, $tax, $tax7, $taxzone);
27
my ($transdate);
27 28

  
28 29
sub clear_up {
29 30
  SL::DB::Manager::Order->delete_all(all => 1);
......
92 93
  my %params  = @_;
93 94

  
94 95
  return create_sales_invoice(
96
    transdate   => $transdate,
95 97
    taxzone_id  => $taxzone->id,
96 98
    %params,
97 99
  );
......
117 119
    invoiceitems => [ $item ],
118 120
  );
119 121

  
120
  my $taxkey = $item->part->get_taxkey(date => DateTime->today_local, is_sales => 1, taxzone => $invoice->taxzone_id);
122
  my $taxkey = $item->part->get_taxkey(date => $transdate, is_sales => 1, taxzone => $invoice->taxzone_id);
121 123

  
122 124
  # sellprice 2.34 * qty 2.5 = 5.85
123 125
  # 19%(5.85) = 1.1115; rounded = 1.11
......
181 183
    invoiceitems => [ $item1, $item2 ],
182 184
  );
183 185

  
184
  my $taxkey1 = $item1->part->get_taxkey(date => DateTime->today_local, is_sales => 1, taxzone => $invoice->taxzone_id);
185
  my $taxkey2 = $item2->part->get_taxkey(date => DateTime->today_local, is_sales => 1, taxzone => $invoice->taxzone_id);
186
  my $taxkey1 = $item1->part->get_taxkey(date => $transdate, is_sales => 1, taxzone => $invoice->taxzone_id);
187
  my $taxkey2 = $item2->part->get_taxkey(date => $transdate, is_sales => 1, taxzone => $invoice->taxzone_id);
186 188

  
187 189
  # item 1:
188 190
  # sellprice 2.34 * qty 2.5 = 5.85
......
275 277
    invoiceitems => [ $item1, $item2, $item3 ],
276 278
  );
277 279

  
278
  my %taxkeys = map { ($_->id => $_->get_taxkey(date => DateTime->today_local, is_sales => 1, taxzone => $invoice->taxzone_id)) } uniq map { $_->part } ($item1, $item2, $item3);
280
  my %taxkeys = map { ($_->id => $_->get_taxkey(date => $transdate, is_sales => 1, taxzone => $invoice->taxzone_id)) } uniq map { $_->part } ($item1, $item2, $item3);
279 281

  
280 282
  # item 1:
281 283
  # discount = sellprice 5.55 * discount (0.05) = 0.2775; rounded 0.28
......
385 387
    invoiceitems => [ $item ],
386 388
  );
387 389

  
388
  my %taxkeys = map { ($_->id => $_->get_taxkey(date => DateTime->today_local, is_sales => 1, taxzone => $invoice->taxzone_id)) } uniq map { $_->part } ($item);
390
  my %taxkeys = map { ($_->id => $_->get_taxkey(date => $transdate, is_sales => 1, taxzone => $invoice->taxzone_id)) } uniq map { $_->part } ($item);
389 391

  
390 392
  # 6 parts for 0.60 with 3% discount
391 393
  #
......
444 446
    invoiceitems => [ $item ],
445 447
  );
446 448

  
447
  my %taxkeys = map { ($_->id => $_->get_taxkey(date => DateTime->today_local, is_sales => 1, taxzone => $invoice->taxzone_id)) } uniq map { $_->part } ($item);
449
  my %taxkeys = map { ($_->id => $_->get_taxkey(date => $transdate, is_sales => 1, taxzone => $invoice->taxzone_id)) } uniq map { $_->part } ($item);
448 450

  
449 451
  my $title = 'default invoice, one item, 19% tax not included, rounding, discount, huge qty';
450 452
  my %data  = $invoice->calculate_prices_and_taxes;
......
497 499
    invoiceitems => [ $item ],
498 500
  );
499 501

  
500
  my %taxkeys = map { ($_->id => $_->get_taxkey(date => DateTime->today_local, is_sales => 1, taxzone => $invoice->taxzone_id)) } uniq map { $_->part } ($item);
502
  my %taxkeys = map { ($_->id => $_->get_taxkey(date => $transdate, is_sales => 1, taxzone => $invoice->taxzone_id)) } uniq map { $_->part } ($item);
501 503

  
502 504
  # item 1:
503 505
  # discount = sellprice 0.007 * discount (0.035) = 0.000245; rounded 0.00
......
555 557

  
556 558
Support::TestSetup::login();
557 559

  
560
$transdate = DateTime->today_local;
561
$transdate->set_year(2019) if $transdate->year == 2020; # use year 2019 in 2020, because of tax rate change in Germany
562

  
558 563
test_default_invoice_one_item_19_tax_not_included();
559 564
test_default_invoice_two_items_19_7_tax_not_included();
560 565
test_default_invoice_three_items_sellprice_rounding_discount();

Auch abrufbar als: Unified diff