use SL::DB::Part;
use SL::DB::Unit;
-use SL::Dev::ALL;
+use SL::Dev::ALL qw(:ALL);
my ($customer, $employee, $payment_do, $unit, @parts, $department);
+my ($transdate);
my $VISUAL_TEST = 0; # just a sleep to click around
clear_up();
+ $transdate = DateTime->today_local;
+ $transdate->set_year(2019) if $transdate->year == 2020; # use year 2019 in 2020, because of tax rate change in Germany
+
$unit = SL::DB::Manager::Unit->find_by(name => 'kg') || die "Can't find unit 'kg'";
- $customer = SL::Dev::CustomerVendor::create_customer->save;
+ $customer = new_customer()->save;
$employee = SL::DB::Employee->new(
'login' => 'testuser',
'description' => 'Test Department',
)->save;
- $payment_do = SL::Dev::Payment::create_payment_terms(
+ $payment_do = create_payment_terms(
'description' => '14Tage 2%Skonto, 30Tage netto',
'description_long' => "Innerhalb von 14 Tagen abzüglich 2 % Skonto, innerhalb von 30 Tagen rein netto.|Bei einer Zahlung bis zum <%skonto_date%> gewähren wir 2 % Skonto (EUR <%skonto_amount%>) entspricht EUR <%total_wo_skonto%>.Bei einer Zahlung bis zum <%netto_date%> ist der fällige Betrag in Höhe von <%total%> <%currency%> zu überweisen.",
'percent_skonto' => '0.02',
# two real parts
@parts = ();
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
description => "description 1",
lastcost => '49.95000',
listprice => '0.00000',
weight => '0.79',
)->save;
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
description => "description 2",
lastcost => '153.00000',
listprice => '0.00000',
reset_state();
# we create L20199 with two items
-my $do1 = SL::Dev::Record::create_sales_delivery_order(
+my $do1 = create_sales_delivery_order(
'department_id' => $department->id,
+ 'transdate' => $transdate,
'donumber' => 'L20199',
'employee_id' => $employee->id,
'intnotes' => 'some intnotes',
'customer_id' => $customer->id,
'notes' => '<ul><li><strong>fett</strong></li><li><strong>und</strong></li><li><strong>mit</strong></li><li><strong>bullets</strong></li><li> </li></ul>',
orderitems => [
- SL::Dev::Record::create_delivery_order_item(
+ create_delivery_order_item(
part => $parts[0],
discount => '0.25',
lastcost => '49.95000',
sellprice => '242.20000',
unit => $unit->name,
),
- SL::Dev::Record::create_delivery_order_item(
+ create_delivery_order_item(
part => $parts[1],
discount => '0.25',
lastcost => '153.00000',
# convert this do to invoice
-my $invoice = $do1->convert_to_invoice();
+my $invoice = $do1->convert_to_invoice(transdate => $transdate);
sleep (300) if $VISUAL_TEST; # we can do a real visual test via gui login
# test invoice afterwards
ok(($do1->closed) , 'Delivery Order is closed after conversion');
is($invoice->payment_terms->description, "14Tage 2%Skonto, 30Tage netto", 'payment term description check');
-# some test data from original client invoice console (!)
-# my $invoice3 = SL::DB::Manager::Invoice->find_by( ordnumber => 'A16399' );
-# which will fail due to PTC Calculation differs from GUI-Calculation, see issue: http://redmine.kivitendo-premium.de/issues/82
-# pp $invoice3
-# values from gui should be:
-#ok($invoice->amount == 1354.20000, 'amount check');
-#ok($invoice->marge_percent == 50.88666, 'marge percent check');
-#ok($invoice->marge_total == 579.08000, 'marge total check');
-#ok($invoice->netamount == 1137.98000, 'netamount check');
-
-
-# the values change if one reloads the object
-# without reloading we get this failures
-#not ok 17 - amount check
-# Failed test 'amount check'
-# at t/db_helper/convert_invoice.t line 272.
-# got: '1354.17'
-# expected: '1354.17000'
-#not ok 18 - marge percent check
-# Failed test 'marge percent check'
-# at t/db_helper/convert_invoice.t line 273.
-# got: '50.8857956342929'
-# expected: '50.88580'
-#not ok 19 - marge total check
-# Failed test 'marge total check'
-# at t/db_helper/convert_invoice.t line 274.
-# got: '579.06'
-# expected: '579.06000'
-#not ok 20 - netamount check
-# Failed test 'netamount check'
-# at t/db_helper/convert_invoice.t line 275.
-# got: '1137.96'
-# expected: '1137.96000'
-
$invoice->load;
is($invoice->cusordnumber , 'b84da' , 'cusordnumber check');
is($invoice->department->description , "Test Department" , 'department description ok');
-is($invoice->amount , '1354.17000' , 'amount check');
-is($invoice->marge_percent , '50.88580' , 'marge percent check');
-is($invoice->marge_total , '579.06000' , 'marge total check');
-is($invoice->netamount , '1137.96000' , 'netamount check');
+is($invoice->amount , '1354.20000' , 'amount check');
+is($invoice->marge_percent , '50.88666' , 'marge percent check');
+is($invoice->marge_total , '579.08000' , 'marge total check');
+is($invoice->netamount , '1137.98000' , 'netamount check');
# some item checks
is($invoice->items_sorted->[0]->parts_id , $parts[0]->id , 'invoiceitem 1 linked with part');
clear_up();
1;
+
+# vim: ft=perl
+# set emacs to perl mode
+# Local Variables:
+# mode: perl
+# End: