Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0d0c160c

Von Bernd Bleßmann vor etwa 6 Jahren hinzugefügt

  • ID 0d0c160c76a1c747ca1295cf9cefeff76661dbb3
  • Vorgänger ebcd0a69
  • Nachfolger dbcaeb6a

PTC-Tests: ein weiterer Test mit großen Mengen und kleinen Preisen

Unterschiede anzeigen:

t/db_helper/price_tax_calculator.t
471 471
  }, "${title}: calculated data");
472 472
}
473 473

  
474
sub test_default_invoice_one_item_19_tax_not_included_rounding_discount_big_qty_low_sellprice() {
475
  reset_state();
476

  
477
  my $item   = new_item(qty => 10001, sellprice => 0.007, discount => 0.035);
478
  my $invoice = new_invoice(
479
    taxincluded  => 0,
480
    invoiceitems => [ $item ],
481
  );
482

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

  
485
  # item 1:
486
  # discount = sellprice 0.007 * discount (0.035) = 0.000245; rounded 0.00
487
  # sellprice = sellprice 0.007 - discount 0.00 = 0.007
488
  # linetotal = sellprice 0.007 * qty 10001 * (1 - 0.035) = 67.556755; rounded 67.56
489
  # 19%(67.56) = 12.8364; rounded = 12.84
490
  # total rounded = 80.40
491

  
492
  # lastcost 1.93 * qty 10001 = 19301.93; rounded 19301.93
493
  # line marge_total = 67.56-19301.93 = -19234.37
494
  # line marge_percent = 100*-19234.37/67.56 = -28470.0562462996
495

  
496
  my $title = 'default invoice one item 19 tax not included rounding discount big qty low sellprice';
497
  my %data  = $invoice->calculate_prices_and_taxes;
498

  
499
  is($invoice->netamount,                 67.56,    "${title}: netamount");
500

  
501
  is($invoice->amount,                    80.40,    "${title}: amount");
502

  
503
  is($invoice->marge_total,           -19234.37,    "${title}: marge_total");
504
  is($invoice->marge_percent, -28470.0562462996,    "${title}: marge_percent");
505

  
506
  is_deeply(\%data, {
507
    allocated                                    => {},
508
    amounts                                      => {
509
      $buchungsgruppe->income_accno_id($taxzone) => {
510
        amount                                   => 67.56,
511
        tax_id                                   => $tax->id,
512
        taxkey                                   => 3,
513
      },
514
    },
515
    amounts_cogs                                 => {},
516
    assembly_items                               => [
517
      [],
518
    ],
519
    exchangerate                                 => 1,
520
    taxes                                        => {
521
      $tax->chart_id                             => 12.84,
522
    },
523
    items                                        => [
524
      { linetotal                                => 67.56,
525
        linetotal_cost                           => 19301.93,
526
        sellprice                                => 0.007,
527
        tax_amount                               => 12.8364,
528
        taxkey_id                                => $taxkeys{$item->parts_id}->id,
529
      },
530
    ],
531
    rounding                                    =>  0,
532
  }, "${title}: calculated data");
533
}
534

  
535

  
474 536
Support::TestSetup::login();
475 537

  
476 538
test_default_invoice_one_item_19_tax_not_included();
......
478 540
test_default_invoice_three_items_sellprice_rounding_discount();
479 541
test_default_invoice_one_item_19_tax_not_included_rounding_discount();
480 542
test_default_invoice_one_item_19_tax_not_included_rounding_discount_huge_qty();
543
test_default_invoice_one_item_19_tax_not_included_rounding_discount_big_qty_low_sellprice();
481 544

  
482 545
clear_up();
483 546
done_testing();

Auch abrufbar als: Unified diff