Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 63410aa6

Von Sven Schöling vor mehr als 7 Jahren hinzugefügt

  • ID 63410aa68c7c57655dc66eba4291592358d46cf2
  • Vorgänger cf3a8cf7
  • Nachfolger d2b58cf5

Tests: SL::Dev Änderungen übernommen

Unterschiede anzeigen:

t/background_job/create_periodic_invoices.t
22 22

  
23 23
use Carp;
24 24
use Support::TestSetup;
25
use SL::Dev::ALL;
25
use SL::Dev::ALL qw(:ALL);
26 26

  
27 27
use_ok 'SL::BackgroundJob::CreatePeriodicInvoices';
28 28
use_ok 'SL::DB::Chart';
......
54 54
  # Clean up: remove invoices, orders, parts and customers
55 55
  clear_up();
56 56

  
57
  $customer = SL::Dev::CustomerVendor::create_customer(
57
  $customer = new_customer(
58 58
    name => 'Test Customer',
59 59
    %{ $params{customer} }
60 60
  )->save;
61 61

  
62
  $part = SL::Dev::Part::create_part(
62
  $part = new_part(
63 63
    partnumber  => 'T4254',
64 64
    description => 'Fourty-two fifty-four',
65 65
    lastcost    => 222.22,
......
68 68
    %{ $params{part} }
69 69
  )->save;
70 70

  
71
  $order = SL::Dev::Record::create_sales_order(
71
  $order = create_sales_order(
72 72
    save                     => 1,
73 73
    customer                 => $customer,
74 74
    transaction_description  => '<%period_start_date%>',
t/bank/bank_transactions.t
23 23
use SL::DB::PurchaseInvoice;
24 24
use SL::DB::BankTransaction;
25 25
use SL::Controller::BankTransaction;
26
use SL::Dev::ALL;
26
use SL::Dev::ALL qw(:ALL);
27 27
use Data::Dumper;
28 28

  
29 29
my ($customer, $vendor, $currency_id, $unit, $tax, $tax7, $tax_9, $payment_terms, $bank_account);
......
117 117
    name            => SL::DB::Manager::Chart->find_by(description => 'Bank')->description,
118 118
  )->save;
119 119

  
120
  $customer = SL::Dev::CustomerVendor::create_customer(
120
  $customer = new_customer(
121 121
    name                      => 'Test Customer',
122 122
    iban                      => 'DE12500105170648489890',
123 123
    bic                       => 'TESTBIC',
......
130 130
    customernumber            => 'CUST1704',
131 131
  )->save;
132 132

  
133
  $payment_terms = SL::Dev::Payment::create_payment_terms;
133
  $payment_terms = create_payment_terms();
134 134

  
135
  $vendor = SL::Dev::CustomerVendor::create_vendor(
135
  $vendor = new_vendor(
136 136
    name           => 'Test Vendor',
137 137
    payment_id     => $payment_terms->id,
138 138
    iban           => 'DE12500105170648489890',
......
237 237

  
238 238
  $ar_transaction = test_ar_transaction(invnumber => 'salesinv1');
239 239

  
240
  my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
240
  my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
241 241

  
242 242
  $::form->{invoice_ids} = {
243 243
    $bt->id => [ $ar_transaction->id ]
......
261 261
                                        payment_id => $payment_terms->id,
262 262
                                       );
263 263

  
264
  my $bt = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
265
                                                     bank_chart_id => $bank->id,
266
                                                     amount        => $ar_transaction->amount_less_skonto
267
                                                    ) or die "Couldn't create bank_transaction";
264
  my $bt = create_bank_transaction(record        => $ar_transaction,
265
                                   bank_chart_id => $bank->id,
266
                                   amount        => $ar_transaction->amount_less_skonto
267
                                  ) or die "Couldn't create bank_transaction";
268 268

  
269 269
  $::form->{invoice_ids} = {
270 270
    $bt->id => [ $ar_transaction->id ]
......
290 290
  my $ar_transaction_1 = test_ar_transaction(invnumber => 'salesinv_1');
291 291
  my $ar_transaction_2 = test_ar_transaction(invnumber => 'salesinv_2');
292 292

  
293
  my $bt = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction_1,
294
                                                     amount        => ($ar_transaction_1->amount + $ar_transaction_2->amount),
295
                                                     purpose       => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber,
296
                                                     bank_chart_id => $bank->id,
297
                                                    ) or die "Couldn't create bank_transaction";
293
  my $bt = create_bank_transaction(record        => $ar_transaction_1,
294
                                   amount        => ($ar_transaction_1->amount + $ar_transaction_2->amount),
295
                                   purpose       => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber,
296
                                   bank_chart_id => $bank->id,
297
                                  ) or die "Couldn't create bank_transaction";
298 298

  
299 299
  my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($ar_transaction_1);
300 300
  is($agreement, 16, "points for ar_transaction_1 in test_two_invoices ok");
......
324 324
  $ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid');
325 325

  
326 326
  # amount 135 > 119
327
  my $bt = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
328
                                                     bank_chart_id => $bank->id,
329
                                                     amount        => 135
330
                                                    ) or die "Couldn't create bank_transaction";
327
  my $bt = create_bank_transaction(record        => $ar_transaction,
328
                                   bank_chart_id => $bank->id,
329
                                   amount        => 135
330
                                  ) or die "Couldn't create bank_transaction";
331 331

  
332 332
  $::form->{invoice_ids} = {
333 333
    $bt->id => [ $ar_transaction->id ]
......
354 354

  
355 355
  $ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid partial');
356 356

  
357
  my $bt_1 = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
358
                                                       bank_chart_id => $bank->id,
359
                                                       amount        =>  10
360
                                                      ) or die "Couldn't create bank_transaction";
361
  my $bt_2 = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
362
                                                       amount        => 119,
363
                                                       transdate     => DateTime->today->add(days => 5),
364
                                                       bank_chart_id => $bank->id,
365
                                                      ) or die "Couldn't create bank_transaction";
357
  my $bt_1 = create_bank_transaction(record        => $ar_transaction,
358
                                     bank_chart_id => $bank->id,
359
                                     amount        =>  10
360
                                    ) or die "Couldn't create bank_transaction";
361
  my $bt_2 = create_bank_transaction(record        => $ar_transaction,
362
                                     amount        => 119,
363
                                     transdate     => DateTime->today->add(days => 5),
364
                                     bank_chart_id => $bank->id,
365
                                    ) or die "Couldn't create bank_transaction";
366 366

  
367 367
  $::form->{invoice_ids} = {
368 368
    $bt_1->id => [ $ar_transaction->id ]
......
391 391
  $ar_transaction = test_ar_transaction(invnumber => 'salesinv partial payment');
392 392

  
393 393
  # amount 100 < 119
394
  my $bt = SL::Dev::Payment::create_bank_transaction(record        => $ar_transaction,
395
                                                     bank_chart_id => $bank->id,
396
                                                     amount        => 100
397
                                                    ) or die "Couldn't create bank_transaction";
394
  my $bt = create_bank_transaction(record        => $ar_transaction,
395
                                   bank_chart_id => $bank->id,
396
                                   amount        => 100
397
                                  ) or die "Couldn't create bank_transaction";
398 398

  
399 399
  $::form->{invoice_ids} = {
400 400
    $bt->id => [ $ar_transaction->id ]
......
414 414

  
415 415
  my $testname = 'test_credit_note';
416 416

  
417
  my $part1 = SL::Dev::Part::create_part(   partnumber => 'T4254')->save;
418
  my $part2 = SL::Dev::Part::create_service(partnumber => 'Serv1')->save;
419
  my $credit_note = SL::Dev::Record::create_credit_note(
417
  my $part1 = new_part(   partnumber => 'T4254')->save;
418
  my $part2 = new_service(partnumber => 'Serv1')->save;
419
  my $credit_note = create_credit_note(
420 420
    invnumber    => 'cn 1',
421 421
    customer     => $customer,
422 422
    taxincluded  => 0,
423
    invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
424
                      SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
423
    invoiceitems => [ create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
424
                      create_invoice_item(part => $part2, qty => 10, sellprice => 50),
425 425
                    ]
426 426
  );
427
  my $bt            = SL::Dev::Payment::create_bank_transaction(record        => $credit_note,
427
  my $bt            = create_bank_transaction(record        => $credit_note,
428 428
                                                                amount        => $credit_note->amount,
429 429
                                                                bank_chart_id => $bank->id,
430 430
                                                                transdate     => DateTime->today->add(days => 10),
......
476 476
  is($invoice->netamount, -20  , "$testname: netamount ok");
477 477
  is($invoice->amount   , -23.8, "$testname: amount ok");
478 478

  
479
  my $bt            = SL::Dev::Payment::create_bank_transaction(record        => $invoice,
480
                                                                amount        => $invoice->amount,
481
                                                                bank_chart_id => $bank->id,
482
                                                                transdate     => DateTime->today->add(days => 10),
479
  my $bt            = create_bank_transaction(record        => $invoice,
480
                                              amount        => $invoice->amount,
481
                                              bank_chart_id => $bank->id,
482
                                              transdate     => DateTime->today->add(days => 10),
483 483
                                                               );
484 484
  my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice);
485 485
  is($agreement, 15, "points for negative ap transaction ok");
......
531 531
  is($invoice->netamount, 115  , "$testname: netamount ok");
532 532
  is($invoice->amount   , 136.85, "$testname: amount ok");
533 533

  
534
  my $bt            = SL::Dev::Payment::create_bank_transaction(record        => $invoice,
535
                                                                amount        => $invoice->amount,
536
                                                                bank_chart_id => $bank->id,
537
                                                                transdate     => DateTime->today->add(days => 10),
538
                                                               );
534
  my $bt            = create_bank_transaction(record        => $invoice,
535
                                              amount        => $invoice->amount,
536
                                              bank_chart_id => $bank->id,
537
                                              transdate     => DateTime->today->add(days => 10),
538
                                             );
539 539
  $::form->{invoice_ids} = {
540 540
    $bt->id => [ $invoice->id ]
541 541
  };
......
584 584
  is($invoice->netamount, 115  , "$testname: netamount ok");
585 585
  is($invoice->amount   , 136.85, "$testname: amount ok");
586 586

  
587
  my $bt            = SL::Dev::Payment::create_bank_transaction(record        => $invoice,
588
                                                                amount        => $invoice->amount-100,
589
                                                                bank_chart_id => $bank->id,
590
                                                                transdate     => DateTime->today->add(days => 10),
591
                                                               );
587
  my $bt            = create_bank_transaction(record        => $invoice,
588
                                              amount        => $invoice->amount-100,
589
                                              bank_chart_id => $bank->id,
590
                                              transdate     => DateTime->today->add(days => 10),
591
                                             );
592 592
  $::form->{invoice_ids} = {
593 593
    $bt->id => [ $invoice->id ]
594 594
  };
......
604 604
  is($invoice->paid     ,  '36.85000', "$testname: paid ok");
605 605
  is($bt->invoice_amount, '-36.85000', "$testname: bt invoice amount for ap was assigned");
606 606

  
607
  my $bt2           = SL::Dev::Payment::create_bank_transaction(record        => $invoice,
608
                                                                amount        => 100,
609
                                                                bank_chart_id => $bank->id,
610
                                                                transdate     => DateTime->today->add(days => 10),
611
                                                               );
607
  my $bt2           = create_bank_transaction(record        => $invoice,
608
                                              amount        => 100,
609
                                              bank_chart_id => $bank->id,
610
                                              transdate     => DateTime->today->add(days => 10),
611
                                             );
612 612
  $::form->{invoice_ids} = {
613 613
    $bt2->id => [ $invoice->id ]
614 614
  };
......
630 630

  
631 631
  my $testname = 'test_neg_sales_invoice';
632 632

  
633
  my $part1 = SL::Dev::Part::create_part(   partnumber => 'Funkenhaube öhm')->save;
634
  my $part2 = SL::Dev::Part::create_service(partnumber => 'Service-Pauschale Pasch!')->save;
633
  my $part1 = new_part(   partnumber => 'Funkenhaube öhm')->save;
634
  my $part2 = new_service(partnumber => 'Service-Pauschale Pasch!')->save;
635 635

  
636
  my $neg_sales_inv = SL::Dev::Record::create_sales_invoice(
636
  my $neg_sales_inv = create_sales_invoice(
637 637
    invnumber    => '20172201',
638 638
    customer     => $customer,
639 639
    taxincluded  => 0,
640
    invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
641
                      SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => -50),
640
    invoiceitems => [ create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
641
                      create_invoice_item(part => $part2, qty => 10, sellprice => -50),
642 642
                    ]
643 643
  );
644
  my $bt            = SL::Dev::Payment::create_bank_transaction(record        => $neg_sales_inv,
644
  my $bt            = create_bank_transaction(record        => $neg_sales_inv,
645 645
                                                                amount        => $neg_sales_inv->amount,
646 646
                                                                bank_chart_id => $bank->id,
647 647
                                                                transdate     => DateTime->today,
......
667 667

  
668 668
  $ar_transaction = test_ar_transaction(invnumber => 'bt_rule1');
669 669

  
670
  my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
670
  my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
671 671

  
672 672
  $ar_transaction->load;
673 673
  $bt->load;
......
697 697

  
698 698
  $ar_transaction = test_ar_transaction(invnumber => 'sepa1');
699 699

  
700
  my $bt  = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
701
  my $se  = SL::Dev::Payment::create_sepa_export();
702
  my $sei = SL::Dev::Payment::create_sepa_export_item(
700
  my $bt  = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
701
  my $se  = create_sepa_export();
702
  my $sei = create_sepa_export_item(
703 703
    chart_id       => $bank->id,
704 704
    ar_id          => $ar_transaction->id,
705 705
    sepa_export_id => $se->id,
t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t
22 22

  
23 23
use Carp;
24 24
use Support::TestSetup;
25
use SL::Dev::ALL;
25
use SL::Dev::ALL qw(:ALL);
26 26

  
27 27
use_ok 'SL::BackgroundJob::CreatePeriodicInvoices';
28 28
use_ok 'SL::Controller::FinancialControllingReport';
......
47 47
  $unit           = SL::DB::Manager::Unit->find_by(name => 'psch')   || croak "No unit";
48 48
}
49 49

  
50
sub create_sales_order {
50
sub make_sales_order {
51 51
  my %params = @_;
52 52

  
53 53
  cleanup();
54 54

  
55 55
  $params{$_} ||= {} for qw(customer part order orderitem);
56 56

  
57
  $customer     = SL::Dev::CustomerVendor::create_customer(
57
  $customer     = new_customer(
58 58
    name        => 'Test Customer',
59 59
    %{ $params{customer} }
60 60
  )->save;
61 61

  
62
  $part = SL::Dev::Part::create_part(
62
  $part = new_part(
63 63
    partnumber         => 'T4254',
64 64
    description        => 'Fourty-two fifty-four',
65 65
    lastcost           => 222.22,
......
69 69
  )->save;
70 70
  $part->load;
71 71

  
72
  $order                     = SL::Dev::Record::create_sales_order(
72
  $order                     = create_sales_order(
73 73
    save                     => 1,
74 74
    customer                 => $customer,
75 75
    transaction_description  => '<%period_start_date%>',
76 76
    transdate                => DateTime->from_kivitendo('01.03.2014'),
77 77
    orderitems               => [
78
                                  SL::Dev::Record::create_order_item(
78
                                  create_order_item(
79 79
                                    part => $part,
80 80
                                    qty  => 1,
81 81
                                    %{ $params{orderitem} },
......
103 103
sub run_tests {
104 104
  my ($msg, $num_orders, $values, %order_params) = @_;
105 105

  
106
  create_sales_order(%order_params);
106
  make_sales_order(%order_params);
107 107

  
108 108
  is($num_orders, scalar @{ $ctrl->orders }, "${msg}, #orders");
109 109
  is_deeply([ map { ($ctrl->orders->[0]->{$_} // 0) * 1 } @columns ],
t/controllers/financial_overview/sales_orders.t
22 22

  
23 23
use Carp;
24 24
use Support::TestSetup;
25
use SL::Dev::ALL;
25
use SL::Dev::Record qw(create_sales_order create_order_item);
26
use SL::Dev::CustomerVendor qw(new_customer);
27
use SL::Dev::Part qw(new_part);
26 28

  
27 29
use_ok 'SL::BackgroundJob::CreatePeriodicInvoices';
28 30
use_ok 'SL::Controller::FinancialOverview';
......
46 48
  $unit           = SL::DB::Manager::Unit->find_by(name => 'psch')   || croak "No unit";
47 49
}
48 50

  
49
sub create_sales_order {
51
sub make_sales_order {
50 52
  my %params = @_;
51 53

  
52 54
  $params{$_} ||= {} for qw(customer part order orderitem);
......
54 56
  # Clean up: remove invoices, orders, parts and customers
55 57
  clear_up();
56 58

  
57
  $customer     = SL::Dev::CustomerVendor::create_customer(
59
  $customer     = new_customer(
58 60
    name        => 'Test Customer',
59 61
    %{ $params{customer} }
60 62
  )->save;
61 63

  
62
  $part = SL::Dev::Part::create_part(
64
  $part = new_part(
63 65
    partnumber         => 'T4254',
64 66
    description        => 'Fourty-two fifty-four',
65 67
    lastcost           => 222.22,
......
68 70
  )->save;
69 71
  $part->load;
70 72

  
71
  $order                     = SL::Dev::Record::create_sales_order(
73
  $order                     = create_sales_order(
72 74
    save                     => 1,
73 75
    customer                 => $customer,
74 76
    transaction_description  => '<%period_start_date%>',
75 77
    transdate                => DateTime->from_kivitendo('01.03.2014'),
76
    orderitems => [ SL::Dev::Record::create_order_item(part => $part, qty =>  1, %{ $params{orderitem} }) ],
78
    orderitems => [ create_order_item(part => $part, qty =>  1, %{ $params{orderitem} }) ],
77 79
    periodic_invoices_config => $params{periodic_invoices_config} ? {
78 80
      active                 => 1,
79 81
      ar_chart_id            => $ar_chart->id,
......
95 97

  
96 98
# ----------------------------------------------------------------------
97 99
# An order without periodic invoices:
98
create_sales_order();
100
make_sales_order();
99 101

  
100 102
is_deeply($ctrl->data->{$_}, { months => [ (0) x 12 ], quarters => [ 0, 0, 0, 0 ], year => 0 }, "no periodic invoices, data for $_")
101 103
  for qw(purchase_invoices purchase_orders requests_for_quotation sales_invoices sales_quotations);
......
105 107

  
106 108
# ----------------------------------------------------------------------
107 109
# order_value_periodicity=y, periodicity=q
108
create_sales_order(
110
make_sales_order(
109 111
  periodic_invoices_config  => {
110 112
    periodicity             => 'm',
111 113
    order_value_periodicity => 'y',
......
124 126

  
125 127
# ----------------------------------------------------------------------
126 128
# order_value_periodicity=y, periodicity=q, starting in previous year
127
create_sales_order(
129
make_sales_order(
128 130
  order                     => {
129 131
    transdate               => DateTime->from_kivitendo('01.03.2013'),
130 132
  },
......
146 148

  
147 149
# ----------------------------------------------------------------------
148 150
# order_value_periodicity=y, periodicity=q, starting in previous year, ending middle of year
149
create_sales_order(
151
make_sales_order(
150 152
  order                     => {
151 153
    transdate               => DateTime->from_kivitendo('01.03.2013'),
152 154
  },
......
170 172

  
171 173
# ----------------------------------------------------------------------
172 174
# order_value_periodicity=y, periodicity=q, starting and ending before current
173
create_sales_order(
175
make_sales_order(
174 176
  order                     => {
175 177
    transdate               => DateTime->from_kivitendo('01.03.2012'),
176 178
  },
t/controllers/project/project_linked_records.t
5 5
use Support::TestSetup;
6 6
use Carp;
7 7
use Test::Exception;
8
use SL::Dev::ALL;
8
use SL::Dev::ALL qw(:ALL);
9 9
use SL::DB::Part;
10 10
use SL::DB::Order;
11 11
use SL::DB::Customer;
......
20 20

  
21 21
clear_up();
22 22

  
23
my $vendor   = SL::Dev::CustomerVendor::create_vendor->save;
24
my $customer = SL::Dev::CustomerVendor::create_customer->save;
25
my $project  = SL::Dev::Record::create_project(projectnumber => 'p1', description => 'Project 1')->save;
23
my $vendor   = new_vendor()->save;
24
my $customer = new_customer()->save;
25
my $project  = create_project(projectnumber => 'p1', description => 'Project 1');
26 26

  
27
my $part1 = SL::Dev::Part::create_part(   partnumber => 'T4254')->save;
28
my $part2 = SL::Dev::Part::create_service(partnumber => 'Serv1')->save;
27
my $part1 = new_part(   partnumber => 'T4254')->save;
28
my $part2 = new_service(partnumber => 'Serv1')->save;
29 29

  
30 30
# sales order with globalproject_id and item project_ids
31
my $sales_order = SL::Dev::Record::create_sales_order(
31
my $sales_order = create_sales_order(
32 32
  save             => 1,
33 33
  customer         => $customer,
34 34
  globalproject_id => $project->id,
35 35
  taxincluded      => 0,
36
  orderitems       => [ SL::Dev::Record::create_order_item(part => $part1, qty =>  3, sellprice => 70, project_id => $project->id),
37
                        SL::Dev::Record::create_order_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
36
  orderitems       => [ create_order_item(part => $part1, qty =>  3, sellprice => 70, project_id => $project->id),
37
                        create_order_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
38 38
                      ]
39 39
);
40 40

  
41 41
# sales order with no globalproject_id but item project_ids
42
my $sales_order2 = SL::Dev::Record::create_sales_order(
42
my $sales_order2 = create_sales_order(
43 43
  save             => 1,
44 44
  customer         => $customer,
45 45
  taxincluded      => 0,
46
  orderitems       => [ SL::Dev::Record::create_order_item(part => $part1, qty =>  3, sellprice => 70, project_id => $project->id),
47
                        SL::Dev::Record::create_order_item(part => $part2, qty => 10, sellprice => 50),
46
  orderitems       => [ create_order_item(part => $part1, qty =>  3, sellprice => 70, project_id => $project->id),
47
                        create_order_item(part => $part2, qty => 10, sellprice => 50),
48 48
                      ]
49 49
);
50 50

  
51 51
# purchase order with globalproject_id and item project_ids
52
my $purchase_order = SL::Dev::Record::create_purchase_order(
52
my $purchase_order = create_purchase_order(
53 53
  save             => 1,
54 54
  vendor           => $vendor,
55 55
  globalproject_id => $project->id,
56 56
  taxincluded      => 0,
57
  orderitems       => [ SL::Dev::Record::create_order_item(part => $part1, qty =>  3, sellprice => 70, project_id => $project->id),
58
                        SL::Dev::Record::create_order_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
57
  orderitems       => [ create_order_item(part => $part1, qty =>  3, sellprice => 70, project_id => $project->id),
58
                        create_order_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
59 59
                      ]
60 60
);
61 61

  
62 62
# sales_invoice with globalproject_id, and all items with project_id
63
my $sales_invoice = SL::Dev::Record::create_sales_invoice(
63
my $sales_invoice = create_sales_invoice(
64 64
  customer         => $customer,
65 65
  globalproject_id => $project->id,
66 66
  taxincluded      => 0,
67
  invoiceitems     => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  3, sellprice => 70, project_id => $project->id),
68
                        SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
67
  invoiceitems     => [ create_invoice_item(part => $part1, qty =>  3, sellprice => 70, project_id => $project->id),
68
                        create_invoice_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
69 69
                      ]
70 70
);
71 71

  
72 72
# sales_invoice with globalproject_id, but none of the items has a project_id
73
my $sales_invoice2 = SL::Dev::Record::create_sales_invoice(
73
my $sales_invoice2 = create_sales_invoice(
74 74
  customer         => $customer,
75 75
  globalproject_id => $project->id,
76 76
  taxincluded      => 0,
77
  invoiceitems     => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
78
                        SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
77
  invoiceitems     => [ create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
78
                        create_invoice_item(part => $part2, qty => 10, sellprice => 50),
79 79
                      ]
80 80
);
81 81

  
82 82
# one of the invoice items has the project id, but there is no globalproject_id
83
my $sales_invoice4 = SL::Dev::Record::create_sales_invoice(
83
my $sales_invoice4 = create_sales_invoice(
84 84
  customer         => $customer,
85 85
  taxincluded      => 0,
86
  invoiceitems     => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
87
                        SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
86
  invoiceitems     => [ create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
87
                        create_invoice_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
88 88
                      ]
89 89
);
90 90

  
t/datev/invoices.t
6 6

  
7 7
use_ok 'Support::TestSetup';
8 8
use SL::DATEV qw(:CONSTANTS);
9
use SL::Dev::ALL;
9
use SL::Dev::ALL qw(:ALL);
10 10
use List::Util qw(sum);
11 11
use SL::DB::Buchungsgruppe;
12 12
use SL::DB::Chart;
......
24 24
my $payment_date    = DateTime->new(year => 2017, month =>  1, day => 5);
25 25
my $gldate          = DateTime->new(year => 2017, month =>  2, day => 9); # simulate bookings for Jan being made in Feb
26 26

  
27
my $part1 = SL::Dev::Part::create_part(partnumber => '19', description => 'Part 19%')->save;
28
my $part2 = SL::Dev::Part::create_part(
27
my $part1 = new_part(partnumber => '19', description => 'Part 19%')->save;
28
my $part2 = new_part(
29 29
  partnumber         => '7',
30 30
  description        => 'Part 7%',
31 31
  buchungsgruppen_id => $buchungsgruppe7->id,
32 32
)->save;
33 33

  
34
my $invoice = SL::Dev::Record::create_sales_invoice(
34
my $invoice = create_sales_invoice(
35 35
  invnumber    => "1 sales invoice",
36 36
  itime        => $gldate,
37 37
  gldate       => $gldate,
38 38
  intnotes     => 'booked in February',
39 39
  taxincluded  => 0,
40 40
  transdate    => $date,
41
  invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
42
                    SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
41
  invoiceitems => [ create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
42
                    create_invoice_item(part => $part2, qty => 10, sellprice => 50),
43 43
                  ]
44 44
);
45 45
$invoice->pay_invoice(chart_id      => $bank->id,
......
85 85
                                       ], "trans_id datev check ok";
86 86

  
87 87
my $march_9 = DateTime->new(year => 2017, month =>  3, day => 9);
88
my $invoice2 = SL::Dev::Record::create_sales_invoice(
88
my $invoice2 = create_sales_invoice(
89 89
  invnumber    => "2 sales invoice",
90 90
  itime        => $march_9,
91 91
  gldate       => $march_9,
92 92
  intnotes     => 'booked in March',
93 93
  taxincluded  => 0,
94 94
  transdate    => $date,
95
  invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  6, sellprice => 70),
96
                    SL::Dev::Record::create_invoice_item(part => $part2, qty => 20, sellprice => 50),
95
  invoiceitems => [ create_invoice_item(part => $part1, qty =>  6, sellprice => 70),
96
                    create_invoice_item(part => $part2, qty => 20, sellprice => 50),
97 97
                  ]
98 98
);
99 99

  
100
my $credit_note = SL::Dev::Record::create_credit_note(
100
my $credit_note = create_credit_note(
101 101
  invnumber    => 'Gutschrift 34',
102 102
  itime        => $gldate,
103 103
  gldate       => $gldate,
104 104
  intnotes     => 'booked in February',
105 105
  taxincluded  => 0,
106 106
  transdate    => $date,
107
  invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
108
                    SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
107
  invoiceitems => [ create_invoice_item(part => $part1, qty =>  3, sellprice => 70),
108
                    create_invoice_item(part => $part2, qty => 10, sellprice => 50),
109 109
                  ]
110 110
);
111 111

  
t/db_helper/convert_invoice.t
22 22
use SL::DB::Part;
23 23
use SL::DB::Unit;
24 24

  
25
use SL::Dev::ALL;
25
use SL::Dev::ALL qw(:ALL);
26 26

  
27 27
my ($customer, $employee, $payment_do, $unit, @parts, $department);
28 28

  
......
41 41
  clear_up();
42 42

  
43 43
  $unit     = SL::DB::Manager::Unit->find_by(name => 'kg') || die "Can't find unit 'kg'";
44
  $customer = SL::Dev::CustomerVendor::create_customer->save;
44
  $customer = new_customer()->save;
45 45

  
46 46
  $employee = SL::DB::Employee->new(
47 47
    'login' => 'testuser',
......
52 52
    'description' => 'Test Department',
53 53
  )->save;
54 54

  
55
  $payment_do = SL::Dev::Payment::create_payment_terms(
55
  $payment_do = create_payment_terms(
56 56
     'description'      => '14Tage 2%Skonto, 30Tage netto',
57 57
     '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.",
58 58
     'percent_skonto'   => '0.02',
......
62 62

  
63 63
  # two real parts
64 64
  @parts = ();
65
  push @parts, SL::Dev::Part::create_part(
65
  push @parts, new_part(
66 66
    description => "description 1",
67 67
    lastcost    => '49.95000',
68 68
    listprice   => '0.00000',
......
72 72
    weight      => '0.79',
73 73
  )->save;
74 74

  
75
  push @parts, SL::Dev::Part::create_part(
75
  push @parts, new_part(
76 76
    description => "description 2",
77 77
    lastcost    => '153.00000',
78 78
    listprice   => '0.00000',
......
89 89
reset_state();
90 90

  
91 91
# we create L20199 with two items
92
my $do1 = SL::Dev::Record::create_sales_delivery_order(
92
my $do1 = create_sales_delivery_order(
93 93
  'department_id' => $department->id,
94 94
  'donumber'      => 'L20199',
95 95
  'employee_id'   => $employee->id,
......
103 103
  'customer_id'   => $customer->id,
104 104
  'notes'         => '<ul><li><strong>fett</strong></li><li><strong>und</strong></li><li><strong>mit</strong></li><li><strong>bullets</strong></li><li>&nbsp;</li></ul>',
105 105
  orderitems => [
106
                  SL::Dev::Record::create_delivery_order_item(
106
                  create_delivery_order_item(
107 107
                    part               => $parts[0],
108 108
                    discount           => '0.25',
109 109
                    lastcost           => '49.95000',
......
113 113
                    sellprice          => '242.20000',
114 114
                    unit               => $unit->name,
115 115
                  ),
116
                  SL::Dev::Record::create_delivery_order_item(
116
                  create_delivery_order_item(
117 117
                    part            => $parts[1],
118 118
                    discount        => '0.25',
119 119
                    lastcost        => '153.00000',
t/db_helper/payment.t
10 10
use Test::Exception;
11 11
use List::Util qw(sum);
12 12

  
13
use SL::Dev::Record;
14
use SL::Dev::CustomerVendor;
15
use SL::Dev::Part;
13
use SL::Dev::Record qw(create_invoice_item create_sales_invoice create_credit_note);
14
use SL::Dev::CustomerVendor qw(new_customer new_vendor);
15
use SL::Dev::Part qw(new_part);
16 16
use SL::DB::Buchungsgruppe;
17 17
use SL::DB::Currency;
18 18
use SL::DB::Exchangerate;
......
109 109
                                             currency_id => $currency->id,
110 110
                                            )->save;
111 111

  
112
  $customer     = SL::Dev::CustomerVendor::create_customer(
112
  $customer     = new_customer(
113 113
    name        => 'Test Customer',
114 114
    currency_id => $currency_id,
115 115
    taxzone_id  => $taxzone->id,
......
134 134
    auto_calculation => 1,
135 135
  )->save;
136 136

  
137
  $vendor       = SL::Dev::CustomerVendor::create_vendor(
137
  $vendor       = new_vendor(
138 138
    name        => 'Test Vendor',
139 139
    currency_id => $currency_id,
140 140
    taxzone_id  => $taxzone->id,
......
143 143

  
144 144

  
145 145
  @parts = ();
146
  push @parts, SL::Dev::Part::create_part(
146
  push @parts, new_part(
147 147
    partnumber         => 'T4254',
148 148
    description        => 'Fourty-two fifty-four',
149 149
    lastcost           => 1.93,
......
153 153
    %{ $params{part1} }
154 154
  )->save;
155 155

  
156
  push @parts, SL::Dev::Part::create_part(
156
  push @parts, new_part(
157 157
    partnumber         => 'T0815',
158 158
    description        => 'Zero EIGHT fifteeN @ 7%',
159 159
    lastcost           => 5.473,
......
162 162
    unit               => $unit->name,
163 163
    %{ $params{part2} }
164 164
  )->save;
165
  push @parts, SL::Dev::Part::create_part(
165
  push @parts, new_part(
166 166
    partnumber         => '19%',
167 167
    description        => 'Testware 19%',
168 168
    lastcost           => 0,
......
171 171
    unit               => $unit->name,
172 172
    %{ $params{part3} }
173 173
  )->save;
174
  push @parts, SL::Dev::Part::create_part(
174
  push @parts, new_part(
175 175
    partnumber         => '7%',
176 176
    description        => 'Testware 7%',
177 177
    lastcost           => 0,
......
302 302
sub test_default_invoice_one_item_19_without_skonto() {
303 303
  reset_state() if $ALWAYS_RESET;
304 304

  
305
  my $item    = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
306
  my $invoice = SL::Dev::Record::create_sales_invoice(
305
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
306
  my $invoice = create_sales_invoice(
307 307
    taxincluded  => 0,
308 308
    invoiceitems => [ $item ],
309 309
    payment_id   => $payment_terms->id,
......
338 338
sub test_default_invoice_one_item_19_without_skonto_overpaid() {
339 339
  reset_state() if $ALWAYS_RESET;
340 340

  
341
  my $item    = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
342
  my $invoice = SL::Dev::Record::create_sales_invoice(
341
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
342
  my $invoice = create_sales_invoice(
343 343
    taxincluded  => 0,
344 344
    invoiceitems => [ $item ],
345 345
    payment_id   => $payment_terms->id,
......
379 379
sub test_default_invoice_two_items_19_7_tax_with_skonto() {
380 380
  reset_state() if $ALWAYS_RESET;
381 381

  
382
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
383
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
384
  my $invoice = SL::Dev::Record::create_sales_invoice(
382
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
383
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
384
  my $invoice = create_sales_invoice(
385 385
    taxincluded  => 0,
386 386
    invoiceitems => [ $item1, $item2 ],
387 387
    payment_id   => $payment_terms->id,
......
413 413
sub test_default_invoice_two_items_19_7_tax_with_skonto_tax_included() {
414 414
  reset_state() if $ALWAYS_RESET;
415 415

  
416
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
417
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
418
  my $invoice = SL::Dev::Record::create_sales_invoice(
416
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
417
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
418
  my $invoice = create_sales_invoice(
419 419
    taxincluded  => 1,
420 420
    invoiceitems => [ $item1, $item2 ],
421 421
    payment_id   => $payment_terms->id,
......
450 450
sub test_default_invoice_two_items_19_7_without_skonto() {
451 451
  reset_state() if $ALWAYS_RESET;
452 452

  
453
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
454
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
455
  my $invoice = SL::Dev::Record::create_sales_invoice(
453
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
454
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
455
  my $invoice = create_sales_invoice(
456 456
    taxincluded  => 0,
457 457
    invoiceitems => [ $item1, $item2 ],
458 458
    payment_id   => $payment_terms->id,
......
485 485
sub test_default_invoice_two_items_19_7_without_skonto_incomplete_payment() {
486 486
  reset_state() if $ALWAYS_RESET;
487 487

  
488
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
489
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
490
  my $invoice = SL::Dev::Record::create_sales_invoice(
488
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
489
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
490
  my $invoice = create_sales_invoice(
491 491
    taxincluded  => 0,
492 492
    invoiceitems => [ $item1, $item2 ],
493 493
    payment_id   => $payment_terms->id,
......
516 516
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments() {
517 517
  reset_state() if $ALWAYS_RESET;
518 518

  
519
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
520
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
521
  my $invoice = SL::Dev::Record::create_sales_invoice(
519
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
520
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
521
  my $invoice = create_sales_invoice(
522 522
    taxincluded  => 0,
523 523
    invoiceitems => [ $item1, $item2 ],
524 524
    payment_id   => $payment_terms->id,
......
552 552
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto() {
553 553
  reset_state() if $ALWAYS_RESET;
554 554

  
555
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
556
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
557
  my $invoice = SL::Dev::Record::create_sales_invoice(
555
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
556
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
557
  my $invoice = create_sales_invoice(
558 558
    taxincluded  => 0,
559 559
    invoiceitems => [ $item1, $item2 ],
560 560
    payment_id   => $payment_terms->id,
......
598 598
  # (11.66) rather than the 19% account (5.85).  The actual tax amount is
599 599
  # higher for the 19% case, though (1.11 compared to 0.82)
600 600

  
601
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
602
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
603
  my $invoice = SL::Dev::Record::create_sales_invoice(
601
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
602
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
603
  my $invoice = create_sales_invoice(
604 604
    taxincluded  => 0,
605 605
    invoiceitems => [ $item1, $item2 ],
606 606
    payment_id   => $payment_terms->id,
......
635 635
  reset_state() if $ALWAYS_RESET;
636 636

  
637 637
  # if there are two cents left there will be two skonto bookings, 1 cent each
638
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
639
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
640
  my $invoice = SL::Dev::Record::create_sales_invoice(
638
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
639
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
640
  my $invoice = create_sales_invoice(
641 641
    taxincluded  => 0,
642 642
    invoiceitems => [ $item1, $item2 ],
643 643
    payment_id   => $payment_terms->id,
......
671 671
sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto() {
672 672
  reset_state() if $ALWAYS_RESET;
673 673

  
674
  my $item    = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
675
  my $invoice = SL::Dev::Record::create_sales_invoice(
674
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
675
  my $invoice = create_sales_invoice(
676 676
    taxincluded  => 0,
677 677
    invoiceitems => [ $item ],
678 678
    payment_id   => $payment_terms->id,
......
712 712
sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto_1cent() {
713 713
  reset_state() if $ALWAYS_RESET;
714 714

  
715
  my $item    = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
716
  my $invoice = SL::Dev::Record::create_sales_invoice(
715
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
716
  my $invoice = create_sales_invoice(
717 717
    taxincluded  => 0,
718 718
    invoiceitems => [ $item ],
719 719
    payment_id   => $payment_terms->id,
......
857 857
sub test_default_invoice_two_items_19_7_tax_with_skonto_50_50() {
858 858
  reset_state() if $ALWAYS_RESET;
859 859

  
860
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 1);
861
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 1);
862
  my $invoice = SL::Dev::Record::create_sales_invoice(
860
  my $item1   = create_invoice_item(part => $parts[2], qty => 1);
861
  my $item2   = create_invoice_item(part => $parts[3], qty => 1);
862
  my $invoice = create_sales_invoice(
863 863
    taxincluded  => 0,
864 864
    invoiceitems => [ $item1, $item2 ],
865 865
    payment_id   => $payment_terms->id,
......
892 892
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25() {
893 893
  reset_state() if $ALWAYS_RESET;
894 894

  
895
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
896
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
897
  my $item3   = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
898
  my $item4   = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
899
  my $invoice = SL::Dev::Record::create_sales_invoice(
895
  my $item1   = create_invoice_item(part => $parts[2], qty => 0.5);
896
  my $item2   = create_invoice_item(part => $parts[3], qty => 0.5);
897
  my $item3   = create_invoice_item(part => $parts[2], qty => 0.5);
898
  my $item4   = create_invoice_item(part => $parts[3], qty => 0.5);
899
  my $invoice = create_sales_invoice(
900 900
    taxincluded  => 0,
901 901
    invoiceitems => [ $item1, $item2, $item3, $item4 ],
902 902
    payment_id   => $payment_terms->id,
......
928 928
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25_tax_included() {
929 929
  reset_state() if $ALWAYS_RESET;
930 930

  
931
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
932
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
933
  my $item3   = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
934
  my $item4   = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
935
  my $invoice = SL::Dev::Record::create_sales_invoice(
931
  my $item1   = create_invoice_item(part => $parts[2], qty => 0.5);
932
  my $item2   = create_invoice_item(part => $parts[3], qty => 0.5);
933
  my $item3   = create_invoice_item(part => $parts[2], qty => 0.5);
934
  my $item4   = create_invoice_item(part => $parts[3], qty => 0.5);
935
  my $invoice = create_sales_invoice(
936 936
    taxincluded  => 1,
937 937
    invoiceitems => [ $item1, $item2, $item3, $item4 ],
938 938
    payment_id   => $payment_terms->id,
......
966 966
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25_multiple() {
967 967
  reset_state() if $ALWAYS_RESET;
968 968

  
969
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
970
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
971
  my $item3   = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
972
  my $item4   = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
973
  my $invoice = SL::Dev::Record::create_sales_invoice(
969
  my $item1   = create_invoice_item(part => $parts[2], qty => 0.5);
970
  my $item2   = create_invoice_item(part => $parts[3], qty => 0.5);
971
  my $item3   = create_invoice_item(part => $parts[2], qty => 0.5);
972
  my $item4   = create_invoice_item(part => $parts[3], qty => 0.5);
973
  my $invoice = create_sales_invoice(
974 974
    taxincluded  => 0,
975 975
    invoiceitems => [ $item1, $item2, $item3, $item4 ],
976 976
    payment_id   => $payment_terms->id,
......
1413 1413
sub test_credit_note_two_items_19_7_tax_tax_not_included() {
1414 1414
  reset_state() if $ALWAYS_RESET;
1415 1415

  
1416
  my $item1   = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 5);
1417
  my $item2   = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 3);
1418
  my $invoice = SL::Dev::Record::create_credit_note(
1416
  my $item1   = create_invoice_item(part => $parts[0], qty => 5);
1417
  my $item2   = create_invoice_item(part => $parts[1], qty => 3);
1418
  my $invoice = create_credit_note(
1419 1419
    invnumber    => 'cn1',
1420 1420
    taxincluded  => 0,
1421 1421
    invoiceitems => [ $item1, $item2 ],
t/db_helper/price_tax_calculator.t
10 10
use List::MoreUtils qw(uniq);
11 11
use Support::TestSetup;
12 12
use Test::Exception;
13
use SL::Dev::ALL;
13
use SL::Dev::ALL qw(:ALL);
14 14

  
15 15
use SL::DB::Buchungsgruppe;
16 16
use SL::DB::Currency;
......
49 49
  $tax7            = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07)                                              || croak "No tax for 7\%";
50 50
  $taxzone         = SL::DB::Manager::TaxZone->find_by( description => 'Inland')                                           || croak "No taxzone";
51 51

  
52
  $customer     = SL::Dev::CustomerVendor::create_customer(
52
  $customer     = new_customer(
53 53
    name        => 'Test Customer',
54 54
    taxzone_id  => $taxzone->id,
55 55
    %{ $params{customer} }
56 56
  )->save;
57 57

  
58 58
  @parts = ();
59
  push @parts, SL::Dev::Part::create_part(
59
  push @parts, new_part(
60 60
    partnumber         => 'T4254',
61 61
    description        => 'Fourty-two fifty-four',
62 62
    lastcost           => 1.93,
......
66 66
    %{ $params{part1} }
67 67
  )->save;
68 68

  
69
  push @parts, SL::Dev::Part::create_part(
69
  push @parts, new_part(
70 70
    partnumber         => 'T0815',
71 71
    description        => 'Zero EIGHT fifteeN @ 7%',
72 72
    lastcost           => 5.473,
......
76 76
    %{ $params{part2} }
77 77
  )->save;
78 78

  
79
  push @parts, SL::Dev::Part::create_part(
79
  push @parts, new_part(
80 80
    partnumber         => 'T888',
81 81
    description        => 'Triple 8',
82 82
    lastcost           => 0,
......
91 91
sub new_invoice {
92 92
  my %params  = @_;
93 93

  
94
  return SL::Dev::Record::create_sales_invoice(
94
  return create_sales_invoice(
95 95
    taxzone_id  => $taxzone->id,
96 96
    %params,
97 97
  );
......
102 102

  
103 103
  my $part = delete($params{part}) || $parts[0];
104 104

  
105
  return SL::Dev::Record::create_invoice_item(
105
  return create_invoice_item(
106 106
    part => $part,
107 107
    %params,
108 108
  );
t/db_helper/with_transaction.t
10 10
use Data::Dumper;
11 11
use Support::TestSetup;
12 12
use SL::DB::Part;
13
use SL::Dev::Part;
13
use SL::Dev::Part qw(new_part);
14 14

  
15 15
Support::TestSetup::login();
16 16

  
......
21 21

  
22 22
# test simple transaction
23 23

  
24
my $part = create_part();
24
my $part = new_part();
25 25
SL::DB->client->with_transaction(sub {
26 26
  $part->save;
27 27
  ok 1, 'part saved';
......
31 31
};
32 32

  
33 33
# test failing transaction
34
my $part2 = create_part(partnumber => $part->partnumber); # woops, duplicate partnumber
34
my $part2 = new_part(partnumber => $part->partnumber); # woops, duplicate partnumber
35 35
SL::DB->client->with_transaction(sub {
36 36
  $part2->save;
37 37
  ok 0, 'part saved';
......
55 55
# TODO - not possible to test without locally adding hooks in run time
56 56

  
57 57
# test if error gets correctly stored in db->error
58
$part2 = create_part(partnumber => $part->partnumber); # woops, duplicate partnumber
58
$part2 = new_part(partnumber => $part->partnumber); # woops, duplicate partnumber
59 59
SL::DB->client->with_transaction(sub {
60 60
  $part2->save;
61 61
  ok 0, 'part saved';
t/file/filesystem.t
7 7
use Support::TestSetup;
8 8
use Test::Exception;
9 9
use SL::File;
10
use SL::Dev::File;
10
use SL::Dev::File qw(create_uploaded create_scanned create_created);
11

  
11 12

  
12 13
Support::TestSetup::login();
13 14

  
......
25 26
clear_up();
26 27
reset_state();
27 28

  
28
my $file1 = SL::Dev::File::create_uploaded( file_name => 'file1', file_contents => 'inhalt1 uploaded' );
29
my $file2 = SL::Dev::File::create_scanned(  file_name => 'file2', file_contents => 'inhalt2 scanned', file_path => $scannerfile );
30
my $file3 = SL::Dev::File::create_created(  file_name => 'file3', file_contents => 'inhalt3 created'    );
31
my $file4 = SL::Dev::File::create_created(  file_name => 'file3', file_contents => 'inhalt3 new version');
29
my $file1 = create_uploaded( file_name => 'file1', file_contents => 'inhalt1 uploaded' );
30
my $file2 = create_scanned(  file_name => 'file2', file_contents => 'inhalt2 scanned', file_path => $scannerfile );
31
my $file3 = create_created(  file_name => 'file3', file_contents => 'inhalt3 created'    );
32
my $file4 = create_created(  file_name => 'file3', file_contents => 'inhalt3 new version');
32 33

  
33
is( SL::Dev::File->get_all_count(),                    3,"total number of files created is 3");
34
is( SL::Dev::File::get_all_count(),                    3,"total number of files created is 3");
34 35
ok( $file1->file_name                        eq 'file1' ,"file has right name");
35 36
my $content1 = $file1->get_content;
36 37
ok( $$content1 eq 'inhalt1 uploaded'                    ,"file has right content");
......
42 43
my $content2 = File::Slurp::read_file($scannerfile);
43 44
ok( $content2 eq 'inhalt2 scanned'                      ,"scanned file has right content");
44 45

  
45
my @file5 = SL::Dev::File->get_all(file_name => 'file3');
46
my @file5 = SL::Dev::File::get_all(file_name => 'file3');
46 47
is(   scalar( @file5),                                 1, "one actual file found");
47 48
my $content5 = $file5[0]->get_content();
48 49
ok( $$content5 eq 'inhalt3 new version'                 ,"file has right actual content");
49 50

  
50
my @file6 = SL::Dev::File->get_all_versions(file_name => 'file3');
51
my @file6 = SL::Dev::File::get_all_versions(file_name => 'file3');
51 52
is(   scalar( @file6),                                 2,"two file versions found");
52 53
$content5 = $file6[0]->get_content;
53 54
ok( $$content5 eq 'inhalt3 new version'                 ,"file has right actual content");
......
108 109
sub clear_up {
109 110
  # Cleaning up may fail.
110 111
  eval {
111
    SL::Dev::File->delete_all();
112
    SL::Dev::File::delete_all();
112 113
    unlink($scannerfile);
113 114
  };
114 115
}
t/helper/shipped_qty.t
18 18
use SL::DB::Bin;
19 19
use SL::WH;
20 20
use SL::AM;
21
use SL::Dev::ALL;
21
use SL::Dev::ALL qw(:ALL);
22 22
use SL::Helper::ShippedQty;
23 23
use DateTime;
24 24

  
......
28 28

  
29 29
my ($customer, $vendor, @parts, $unit);
30 30

  
31
$customer = SL::Dev::CustomerVendor::create_customer(name => 'Testkunde'    )->save;
32
$vendor   = SL::Dev::CustomerVendor::create_vendor(  name => 'Testlieferant')->save;
31
$customer = new_customer(name => 'Testkunde'    )->save;
32
$vendor   = new_vendor(  name => 'Testlieferant')->save;
33 33

  
34 34
my $default_sellprice = 10;
35 35
my $default_lastcost  =  4;
36 36

  
37
my ($wh) = SL::Dev::Inventory::create_warehouse_and_bins();
37
my ($wh) = create_warehouse_and_bins();
38 38
my $bin1 = SL::DB::Manager::Bin->find_by(description => "Bin 1");
39 39
my $bin2 = SL::DB::Manager::Bin->find_by(description => "Bin 2");
40 40

  
......
46 46

  
47 47
# create 3 parts to be used in test
48 48
for my $i ( 1 .. 4 ) {
49
  SL::Dev::Part::create_part( %part_defaults, partnumber => $i, description => "part $i test" )->save;
49
  new_part( %part_defaults, partnumber => $i, description => "part $i test" )->save;
50 50
};
51 51

  
52 52
my $part1 = SL::DB::Manager::Part->find_by( partnumber => '1' );
......
63 63

  
64 64
note("testing purchases, no fill_up");
65 65

  
66
my $purchase_order = SL::Dev::Record::create_purchase_order(
66
my $purchase_order = create_purchase_order(
67 67
  save       => 1,
68
  orderitems => [ SL::Dev::Record::create_order_item(part => $part1, qty => 11),
69
                  SL::Dev::Record::create_order_item(part => $part2, qty => 12),
70
                  SL::Dev::Record::create_order_item(part => $part3, qty => 13),
68
  orderitems => [ create_order_item(part => $part1, qty => 11),
69
                  create_order_item(part => $part2, qty => 12),
70
                  create_order_item(part => $part3, qty => 13),
71 71
                ]
72 72
);
73 73

  
......
115 115
ok(!$purchase_order->items_sorted->[0]->{delivered},      "require_stock_out => 1: first purchase orderitem is not delivered");
116 116

  
117 117
# ship items from delivery order
118
SL::Dev::Inventory::transfer_purchase_delivery_order($purchase_delivery_order);
118
transfer_purchase_delivery_order($purchase_delivery_order);
119 119

  
120 120
Rose::DB::Object::Helpers::forget_related($purchase_order, 'orderitems');
121 121
$purchase_order->orderitems;
......
135 135

  
136 136
note('testing sales, no fill_up');
137 137

  
138
my $sales_order = SL::Dev::Record::create_sales_order(
138
my $sales_order = create_sales_order(
139 139
  save       => 1,
140
  orderitems => [ SL::Dev::Record::create_order_item(part => $part1, qty => 5),
141
                  SL::Dev::Record::create_order_item(part => $part2, qty => 6),
142
                  SL::Dev::Record::create_order_item(part => $part3, qty => 7),
140
  orderitems => [ create_order_item(part => $part1, qty => 5),
141
                  create_order_item(part => $part2, qty => 6),
142
                  create_order_item(part => $part3, qty => 7),
143 143
                ]
144 144
);
145 145

  
......
182 182
ok(!$sales_order->items_sorted->[0]->{delivered},      "require_stock_out => 1: first sales orderitem is not delivered");
183 183

  
184 184
# ship items from delivery order
185
SL::Dev::Inventory::transfer_sales_delivery_order($sales_delivery_order);
185
transfer_sales_delivery_order($sales_delivery_order);
186 186

  
187 187
Rose::DB::Object::Helpers::forget_related($sales_order, 'orderitems');
188 188
$sales_order->orderitems;
t/part/assembly.t
7 7
use SL::DB::Unit;
8 8
use SL::DB::Part;
9 9
use SL::DB::Assembly;
10
use SL::Dev::Part;
10
use SL::Dev::Part qw(new_assembly);
11 11
use SL::DB::Helper::ValidateAssembly;
12 12

  
13 13
Support::TestSetup::login();
......
32 32

  
33 33

  
34 34

  
35
my $assembly2_part = SL::Dev::Part::create_assembly( partnumber => '20000', assnumber => 'as2' )->save;
35
my $assembly2_part = new_assembly( partnumber => '20000', assnumber => 'as2' )->save;
36 36
my $retval = validate_assembly($assembly_part,$assembly2_part);
37 37
ok(!defined $retval, 'assembly 19000 can be child of assembly 20000' );
38 38
$assembly2_part->add_assemblies(SL::DB::Assembly->new(parts_id => $assembly_part->id, qty => 3, bom => 1));
39 39
$assembly2_part->save;
40 40

  
41
my $assembly3_part = SL::Dev::Part::create_assembly( partnumber => '30000', assnumber => 'as3' )->save;
41
my $assembly3_part = new_assembly( partnumber => '30000', assnumber => 'as3' )->save;
42 42
$retval = validate_assembly($assembly3_part,$assembly_part);
43 43
ok(!defined $retval, 'assembly 30000 can be child of assembly 19000' );
44 44

  
......
92 92
sub reset_state {
93 93
  my %params = @_;
94 94

  
95
  my $assembly = SL::Dev::Part::create_assembly( assnumber => '19000', partnumber => '19000' )->save;
95
  my $assembly = new_assembly( assnumber => '19000', partnumber => '19000' )->save;
96 96
};
97 97

  
98 98
1;
t/part/assortment.t
6 6
use Carp;
7 7
use Test::Exception;
8 8
use SL::DB::Part;
9
use SL::Dev::Part;
9
use SL::Dev::Part qw(new_assortment);
10 10

  
11 11
Support::TestSetup::login();
12 12

  
13 13
clear_up();
14 14

  
15
my $assortment = SL::Dev::Part::create_assortment( assnumber       => 'aso1',
16
                                                   description     => "Assortment 1",
17
                                                   number_of_parts => 10,
15
my $assortment = new_assortment( assnumber       => 'aso1',
16
                                 description     => "Assortment 1",
17
                                 number_of_parts => 10,
18 18
                                                 )->save;
19 19

  
20 20
is( SL::DB::Manager::Part->get_all_count(), 11,  "total number of parts created is 11");
t/part/stock.t
6 6
use Carp;
7 7
use Test::Exception;
8 8
use SL::DB::Part;
9
use SL::Dev::Part;
10
use SL::Dev::Inventory;
9
use SL::Dev::Part qw(new_part);
10
use SL::Dev::Inventory qw(create_warehouse_and_bins set_stock transfer_stock);
11 11

  
12 12
Support::TestSetup::login();
13 13

  
14 14
clear_up();
15 15

  
16
my ($wh1, $bin1_1) = SL::Dev::Inventory::create_warehouse_and_bins(
16
my ($wh1, $bin1_1) = create_warehouse_and_bins(
17 17
  warehouse_description => 'Testlager',
18 18
  bin_description       => 'Testlagerplatz',
19 19
  number_of_bins        => 2,
20 20
);
21 21
my $bin1_2 = $wh1->bins->[1];
22
my ($wh2, $bin2_1) = SL::Dev::Inventory::create_warehouse_and_bins(
22
my ($wh2, $bin2_1) = create_warehouse_and_bins(
23 23
  warehouse_description => 'Testlager 2',
24 24
  bin_description       => 'Testlagerplatz 2',
25 25
  number_of_bins        => 2,
......
28 28
my $today     = DateTime->today;
29 29
my $yesterday = $today->clone->add(days => -1);
30 30

  
31
my $part = SL::Dev::Part::create_part->save;
32
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, qty => 7, shippingdate => $yesterday);
33
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, qty => 5);
34
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, abs_qty => 8); # apply -4 to get qty 8 in bin1_1
35
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_2->id, qty => 9);
36

  
37
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin2_1->id, abs_qty => 10);
38
SL::Dev::Inventory::transfer_stock(part     => $part,
39
                                   from_bin => $wh2->bins->[0],
40
                                   to_bin   => $wh2->bins->[1],
41
                                   qty      => 2,
42
                                  );
31
my $part = new_part()->save;
32
set_stock(part => $part, bin_id => $bin1_1->id, qty => 7, shippingdate => $yesterday);
33
set_stock(part => $part, bin_id => $bin1_1->id, qty => 5);
34
set_stock(part => $part, bin_id => $bin1_1->id, abs_qty => 8); # apply -4 to get qty 8 in bin1_1
35
set_stock(part => $part, bin_id => $bin1_2->id, qty => 9);
36

  
37
set_stock(part => $part, bin_id => $bin2_1->id, abs_qty => 10);
38
transfer_stock(part     => $part,
39
               from_bin => $wh2->bins->[0],
40
               to_bin   => $wh2->bins->[1],
41
               qty      => 2,
42
              );
43 43

  
44 44
is( SL::DB::Manager::Part->get_all_count(), 1,  "total number of parts created is 1");
45 45
is( $part->get_stock == 27                                     , 1 , "total stock of part is 27");
t/wh/transfer.t
3 3

  
4 4
use lib 't';
5 5

  
6
use SL::Dev::Part;
6
use SL::Dev::Part qw(new_part);
7 7

  
8 8
use_ok 'Support::TestSetup';
9 9
use_ok 'SL::DB::Bin';
......
28 28
SL::DB::Manager::Warehouse->delete_all(where => [ description => NAME() ]);
29 29

  
30 30
# Create test data
31
$part = SL::Dev::Part::create_part(unit => 'mg', description => NAME(), partnumber => NAME())->save();
31
$part = new_part(unit => 'mg', description => NAME(), partnumber => NAME())->save();
32 32

  
33 33
is(ref($part), 'SL::DB::Part', 'loading a part to test with id ' . $part->id);
34 34

  

Auch abrufbar als: Unified diff