use Carp;
use Support::TestSetup;
-use SL::Dev::ALL;
+use SL::Dev::ALL qw(:ALL);
use_ok 'SL::BackgroundJob::CreatePeriodicInvoices';
use_ok 'SL::DB::Chart';
# Clean up: remove invoices, orders, parts and customers
clear_up();
- $customer = SL::Dev::CustomerVendor::create_customer(
+ $customer = new_customer(
name => 'Test Customer',
%{ $params{customer} }
)->save;
- $part = SL::Dev::Part::create_part(
+ $part = new_part(
partnumber => 'T4254',
description => 'Fourty-two fifty-four',
lastcost => 222.22,
%{ $params{part} }
)->save;
- $order = SL::Dev::Record::create_sales_order(
+ $order = create_sales_order(
save => 1,
customer => $customer,
transaction_description => '<%period_start_date%>',
use SL::DB::PurchaseInvoice;
use SL::DB::BankTransaction;
use SL::Controller::BankTransaction;
-use SL::Dev::ALL;
+use SL::Dev::ALL qw(:ALL);
use Data::Dumper;
my ($customer, $vendor, $currency_id, $unit, $tax, $tax7, $tax_9, $payment_terms, $bank_account);
name => SL::DB::Manager::Chart->find_by(description => 'Bank')->description,
)->save;
- $customer = SL::Dev::CustomerVendor::create_customer(
+ $customer = new_customer(
name => 'Test Customer',
iban => 'DE12500105170648489890',
bic => 'TESTBIC',
customernumber => 'CUST1704',
)->save;
- $payment_terms = SL::Dev::Payment::create_payment_terms;
+ $payment_terms = create_payment_terms();
- $vendor = SL::Dev::CustomerVendor::create_vendor(
+ $vendor = new_vendor(
name => 'Test Vendor',
payment_id => $payment_terms->id,
iban => 'DE12500105170648489890',
$ar_transaction = test_ar_transaction(invnumber => 'salesinv1');
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
$::form->{invoice_ids} = {
$bt->id => [ $ar_transaction->id ]
payment_id => $payment_terms->id,
);
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
- bank_chart_id => $bank->id,
- amount => $ar_transaction->amount_less_skonto
- ) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction,
+ bank_chart_id => $bank->id,
+ amount => $ar_transaction->amount_less_skonto
+ ) or die "Couldn't create bank_transaction";
$::form->{invoice_ids} = {
$bt->id => [ $ar_transaction->id ]
my $ar_transaction_1 = test_ar_transaction(invnumber => 'salesinv_1');
my $ar_transaction_2 = test_ar_transaction(invnumber => 'salesinv_2');
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction_1,
- amount => ($ar_transaction_1->amount + $ar_transaction_2->amount),
- purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber,
- bank_chart_id => $bank->id,
- ) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction_1,
+ amount => ($ar_transaction_1->amount + $ar_transaction_2->amount),
+ purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber,
+ bank_chart_id => $bank->id,
+ ) or die "Couldn't create bank_transaction";
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($ar_transaction_1);
is($agreement, 16, "points for ar_transaction_1 in test_two_invoices ok");
$ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid');
# amount 135 > 119
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
- bank_chart_id => $bank->id,
- amount => 135
- ) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction,
+ bank_chart_id => $bank->id,
+ amount => 135
+ ) or die "Couldn't create bank_transaction";
$::form->{invoice_ids} = {
$bt->id => [ $ar_transaction->id ]
$ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid partial');
- my $bt_1 = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
- bank_chart_id => $bank->id,
- amount => 10
- ) or die "Couldn't create bank_transaction";
- my $bt_2 = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
- amount => 119,
- transdate => DateTime->today->add(days => 5),
- bank_chart_id => $bank->id,
- ) or die "Couldn't create bank_transaction";
+ my $bt_1 = create_bank_transaction(record => $ar_transaction,
+ bank_chart_id => $bank->id,
+ amount => 10
+ ) or die "Couldn't create bank_transaction";
+ my $bt_2 = create_bank_transaction(record => $ar_transaction,
+ amount => 119,
+ transdate => DateTime->today->add(days => 5),
+ bank_chart_id => $bank->id,
+ ) or die "Couldn't create bank_transaction";
$::form->{invoice_ids} = {
$bt_1->id => [ $ar_transaction->id ]
$ar_transaction = test_ar_transaction(invnumber => 'salesinv partial payment');
# amount 100 < 119
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
- bank_chart_id => $bank->id,
- amount => 100
- ) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction,
+ bank_chart_id => $bank->id,
+ amount => 100
+ ) or die "Couldn't create bank_transaction";
$::form->{invoice_ids} = {
$bt->id => [ $ar_transaction->id ]
my $testname = 'test_credit_note';
- my $part1 = SL::Dev::Part::create_part( partnumber => 'T4254')->save;
- my $part2 = SL::Dev::Part::create_service(partnumber => 'Serv1')->save;
- my $credit_note = SL::Dev::Record::create_credit_note(
+ my $part1 = new_part( partnumber => 'T4254')->save;
+ my $part2 = new_service(partnumber => 'Serv1')->save;
+ my $credit_note = create_credit_note(
invnumber => 'cn 1',
customer => $customer,
taxincluded => 0,
- invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70),
- SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
+ invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70),
+ create_invoice_item(part => $part2, qty => 10, sellprice => 50),
]
);
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $credit_note,
+ my $bt = create_bank_transaction(record => $credit_note,
amount => $credit_note->amount,
bank_chart_id => $bank->id,
transdate => DateTime->today->add(days => 10),
is($invoice->netamount, -20 , "$testname: netamount ok");
is($invoice->amount , -23.8, "$testname: amount ok");
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $invoice,
- amount => $invoice->amount,
- bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
+ my $bt = create_bank_transaction(record => $invoice,
+ amount => $invoice->amount,
+ bank_chart_id => $bank->id,
+ transdate => DateTime->today->add(days => 10),
);
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice);
is($agreement, 15, "points for negative ap transaction ok");
is($invoice->netamount, 115 , "$testname: netamount ok");
is($invoice->amount , 136.85, "$testname: amount ok");
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $invoice,
- amount => $invoice->amount,
- bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
- );
+ my $bt = create_bank_transaction(record => $invoice,
+ amount => $invoice->amount,
+ bank_chart_id => $bank->id,
+ transdate => DateTime->today->add(days => 10),
+ );
$::form->{invoice_ids} = {
$bt->id => [ $invoice->id ]
};
is($invoice->netamount, 115 , "$testname: netamount ok");
is($invoice->amount , 136.85, "$testname: amount ok");
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $invoice,
- amount => $invoice->amount-100,
- bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
- );
+ my $bt = create_bank_transaction(record => $invoice,
+ amount => $invoice->amount-100,
+ bank_chart_id => $bank->id,
+ transdate => DateTime->today->add(days => 10),
+ );
$::form->{invoice_ids} = {
$bt->id => [ $invoice->id ]
};
is($invoice->paid , '36.85000', "$testname: paid ok");
is($bt->invoice_amount, '-36.85000', "$testname: bt invoice amount for ap was assigned");
- my $bt2 = SL::Dev::Payment::create_bank_transaction(record => $invoice,
- amount => 100,
- bank_chart_id => $bank->id,
- transdate => DateTime->today->add(days => 10),
- );
+ my $bt2 = create_bank_transaction(record => $invoice,
+ amount => 100,
+ bank_chart_id => $bank->id,
+ transdate => DateTime->today->add(days => 10),
+ );
$::form->{invoice_ids} = {
$bt2->id => [ $invoice->id ]
};
my $testname = 'test_neg_sales_invoice';
- my $part1 = SL::Dev::Part::create_part( partnumber => 'Funkenhaube öhm')->save;
- my $part2 = SL::Dev::Part::create_service(partnumber => 'Service-Pauschale Pasch!')->save;
+ my $part1 = new_part( partnumber => 'Funkenhaube öhm')->save;
+ my $part2 = new_service(partnumber => 'Service-Pauschale Pasch!')->save;
- my $neg_sales_inv = SL::Dev::Record::create_sales_invoice(
+ my $neg_sales_inv = create_sales_invoice(
invnumber => '20172201',
customer => $customer,
taxincluded => 0,
- invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70),
- SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => -50),
+ invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70),
+ create_invoice_item(part => $part2, qty => 10, sellprice => -50),
]
);
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $neg_sales_inv,
+ my $bt = create_bank_transaction(record => $neg_sales_inv,
amount => $neg_sales_inv->amount,
bank_chart_id => $bank->id,
transdate => DateTime->today,
$ar_transaction = test_ar_transaction(invnumber => 'bt_rule1');
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
+ my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
$ar_transaction->load;
$bt->load;
$ar_transaction = test_ar_transaction(invnumber => 'sepa1');
- my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
- my $se = SL::Dev::Payment::create_sepa_export();
- my $sei = SL::Dev::Payment::create_sepa_export_item(
+ my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
+ my $se = create_sepa_export();
+ my $sei = create_sepa_export_item(
chart_id => $bank->id,
ar_id => $ar_transaction->id,
sepa_export_id => $se->id,
use Carp;
use Support::TestSetup;
-use SL::Dev::ALL;
+use SL::Dev::ALL qw(:ALL);
use_ok 'SL::BackgroundJob::CreatePeriodicInvoices';
use_ok 'SL::Controller::FinancialControllingReport';
$unit = SL::DB::Manager::Unit->find_by(name => 'psch') || croak "No unit";
}
-sub create_sales_order {
+sub make_sales_order {
my %params = @_;
cleanup();
$params{$_} ||= {} for qw(customer part order orderitem);
- $customer = SL::Dev::CustomerVendor::create_customer(
+ $customer = new_customer(
name => 'Test Customer',
%{ $params{customer} }
)->save;
- $part = SL::Dev::Part::create_part(
+ $part = new_part(
partnumber => 'T4254',
description => 'Fourty-two fifty-four',
lastcost => 222.22,
)->save;
$part->load;
- $order = SL::Dev::Record::create_sales_order(
+ $order = create_sales_order(
save => 1,
customer => $customer,
transaction_description => '<%period_start_date%>',
transdate => DateTime->from_kivitendo('01.03.2014'),
orderitems => [
- SL::Dev::Record::create_order_item(
+ create_order_item(
part => $part,
qty => 1,
%{ $params{orderitem} },
sub run_tests {
my ($msg, $num_orders, $values, %order_params) = @_;
- create_sales_order(%order_params);
+ make_sales_order(%order_params);
is($num_orders, scalar @{ $ctrl->orders }, "${msg}, #orders");
is_deeply([ map { ($ctrl->orders->[0]->{$_} // 0) * 1 } @columns ],
use Carp;
use Support::TestSetup;
-use SL::Dev::ALL;
+use SL::Dev::Record qw(create_sales_order create_order_item);
+use SL::Dev::CustomerVendor qw(new_customer);
+use SL::Dev::Part qw(new_part);
use_ok 'SL::BackgroundJob::CreatePeriodicInvoices';
use_ok 'SL::Controller::FinancialOverview';
$unit = SL::DB::Manager::Unit->find_by(name => 'psch') || croak "No unit";
}
-sub create_sales_order {
+sub make_sales_order {
my %params = @_;
$params{$_} ||= {} for qw(customer part order orderitem);
# Clean up: remove invoices, orders, parts and customers
clear_up();
- $customer = SL::Dev::CustomerVendor::create_customer(
+ $customer = new_customer(
name => 'Test Customer',
%{ $params{customer} }
)->save;
- $part = SL::Dev::Part::create_part(
+ $part = new_part(
partnumber => 'T4254',
description => 'Fourty-two fifty-four',
lastcost => 222.22,
)->save;
$part->load;
- $order = SL::Dev::Record::create_sales_order(
+ $order = create_sales_order(
save => 1,
customer => $customer,
transaction_description => '<%period_start_date%>',
transdate => DateTime->from_kivitendo('01.03.2014'),
- orderitems => [ SL::Dev::Record::create_order_item(part => $part, qty => 1, %{ $params{orderitem} }) ],
+ orderitems => [ create_order_item(part => $part, qty => 1, %{ $params{orderitem} }) ],
periodic_invoices_config => $params{periodic_invoices_config} ? {
active => 1,
ar_chart_id => $ar_chart->id,
# ----------------------------------------------------------------------
# An order without periodic invoices:
-create_sales_order();
+make_sales_order();
is_deeply($ctrl->data->{$_}, { months => [ (0) x 12 ], quarters => [ 0, 0, 0, 0 ], year => 0 }, "no periodic invoices, data for $_")
for qw(purchase_invoices purchase_orders requests_for_quotation sales_invoices sales_quotations);
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q
-create_sales_order(
+make_sales_order(
periodic_invoices_config => {
periodicity => 'm',
order_value_periodicity => 'y',
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting in previous year
-create_sales_order(
+make_sales_order(
order => {
transdate => DateTime->from_kivitendo('01.03.2013'),
},
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting in previous year, ending middle of year
-create_sales_order(
+make_sales_order(
order => {
transdate => DateTime->from_kivitendo('01.03.2013'),
},
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting and ending before current
-create_sales_order(
+make_sales_order(
order => {
transdate => DateTime->from_kivitendo('01.03.2012'),
},
use Support::TestSetup;
use Carp;
use Test::Exception;
-use SL::Dev::ALL;
+use SL::Dev::ALL qw(:ALL);
use SL::DB::Part;
use SL::DB::Order;
use SL::DB::Customer;
clear_up();
-my $vendor = SL::Dev::CustomerVendor::create_vendor->save;
-my $customer = SL::Dev::CustomerVendor::create_customer->save;
-my $project = SL::Dev::Record::create_project(projectnumber => 'p1', description => 'Project 1')->save;
+my $vendor = new_vendor()->save;
+my $customer = new_customer()->save;
+my $project = create_project(projectnumber => 'p1', description => 'Project 1');
-my $part1 = SL::Dev::Part::create_part( partnumber => 'T4254')->save;
-my $part2 = SL::Dev::Part::create_service(partnumber => 'Serv1')->save;
+my $part1 = new_part( partnumber => 'T4254')->save;
+my $part2 = new_service(partnumber => 'Serv1')->save;
# sales order with globalproject_id and item project_ids
-my $sales_order = SL::Dev::Record::create_sales_order(
+my $sales_order = create_sales_order(
save => 1,
customer => $customer,
globalproject_id => $project->id,
taxincluded => 0,
- orderitems => [ SL::Dev::Record::create_order_item(part => $part1, qty => 3, sellprice => 70, project_id => $project->id),
- SL::Dev::Record::create_order_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
+ orderitems => [ create_order_item(part => $part1, qty => 3, sellprice => 70, project_id => $project->id),
+ create_order_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
]
);
# sales order with no globalproject_id but item project_ids
-my $sales_order2 = SL::Dev::Record::create_sales_order(
+my $sales_order2 = create_sales_order(
save => 1,
customer => $customer,
taxincluded => 0,
- orderitems => [ SL::Dev::Record::create_order_item(part => $part1, qty => 3, sellprice => 70, project_id => $project->id),
- SL::Dev::Record::create_order_item(part => $part2, qty => 10, sellprice => 50),
+ orderitems => [ create_order_item(part => $part1, qty => 3, sellprice => 70, project_id => $project->id),
+ create_order_item(part => $part2, qty => 10, sellprice => 50),
]
);
# purchase order with globalproject_id and item project_ids
-my $purchase_order = SL::Dev::Record::create_purchase_order(
+my $purchase_order = create_purchase_order(
save => 1,
vendor => $vendor,
globalproject_id => $project->id,
taxincluded => 0,
- orderitems => [ SL::Dev::Record::create_order_item(part => $part1, qty => 3, sellprice => 70, project_id => $project->id),
- SL::Dev::Record::create_order_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
+ orderitems => [ create_order_item(part => $part1, qty => 3, sellprice => 70, project_id => $project->id),
+ create_order_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
]
);
# sales_invoice with globalproject_id, and all items with project_id
-my $sales_invoice = SL::Dev::Record::create_sales_invoice(
+my $sales_invoice = create_sales_invoice(
customer => $customer,
globalproject_id => $project->id,
taxincluded => 0,
- invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70, project_id => $project->id),
- SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
+ invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70, project_id => $project->id),
+ create_invoice_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
]
);
# sales_invoice with globalproject_id, but none of the items has a project_id
-my $sales_invoice2 = SL::Dev::Record::create_sales_invoice(
+my $sales_invoice2 = create_sales_invoice(
customer => $customer,
globalproject_id => $project->id,
taxincluded => 0,
- invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70),
- SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
+ invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70),
+ create_invoice_item(part => $part2, qty => 10, sellprice => 50),
]
);
# one of the invoice items has the project id, but there is no globalproject_id
-my $sales_invoice4 = SL::Dev::Record::create_sales_invoice(
+my $sales_invoice4 = create_sales_invoice(
customer => $customer,
taxincluded => 0,
- invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70),
- SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
+ invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70),
+ create_invoice_item(part => $part2, qty => 10, sellprice => 50, project_id => $project->id),
]
);
use_ok 'Support::TestSetup';
use SL::DATEV qw(:CONSTANTS);
-use SL::Dev::ALL;
+use SL::Dev::ALL qw(:ALL);
use List::Util qw(sum);
use SL::DB::Buchungsgruppe;
use SL::DB::Chart;
my $payment_date = DateTime->new(year => 2017, month => 1, day => 5);
my $gldate = DateTime->new(year => 2017, month => 2, day => 9); # simulate bookings for Jan being made in Feb
-my $part1 = SL::Dev::Part::create_part(partnumber => '19', description => 'Part 19%')->save;
-my $part2 = SL::Dev::Part::create_part(
+my $part1 = new_part(partnumber => '19', description => 'Part 19%')->save;
+my $part2 = new_part(
partnumber => '7',
description => 'Part 7%',
buchungsgruppen_id => $buchungsgruppe7->id,
)->save;
-my $invoice = SL::Dev::Record::create_sales_invoice(
+my $invoice = create_sales_invoice(
invnumber => "1 sales invoice",
itime => $gldate,
gldate => $gldate,
intnotes => 'booked in February',
taxincluded => 0,
transdate => $date,
- invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70),
- SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
+ invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70),
+ create_invoice_item(part => $part2, qty => 10, sellprice => 50),
]
);
$invoice->pay_invoice(chart_id => $bank->id,
], "trans_id datev check ok";
my $march_9 = DateTime->new(year => 2017, month => 3, day => 9);
-my $invoice2 = SL::Dev::Record::create_sales_invoice(
+my $invoice2 = create_sales_invoice(
invnumber => "2 sales invoice",
itime => $march_9,
gldate => $march_9,
intnotes => 'booked in March',
taxincluded => 0,
transdate => $date,
- invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 6, sellprice => 70),
- SL::Dev::Record::create_invoice_item(part => $part2, qty => 20, sellprice => 50),
+ invoiceitems => [ create_invoice_item(part => $part1, qty => 6, sellprice => 70),
+ create_invoice_item(part => $part2, qty => 20, sellprice => 50),
]
);
-my $credit_note = SL::Dev::Record::create_credit_note(
+my $credit_note = create_credit_note(
invnumber => 'Gutschrift 34',
itime => $gldate,
gldate => $gldate,
intnotes => 'booked in February',
taxincluded => 0,
transdate => $date,
- invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70),
- SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
+ invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70),
+ create_invoice_item(part => $part2, qty => 10, sellprice => 50),
]
);
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);
clear_up();
$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,
'donumber' => 'L20199',
'employee_id' => $employee->id,
'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',
use Test::Exception;
use List::Util qw(sum);
-use SL::Dev::Record;
-use SL::Dev::CustomerVendor;
-use SL::Dev::Part;
+use SL::Dev::Record qw(create_invoice_item create_sales_invoice create_credit_note);
+use SL::Dev::CustomerVendor qw(new_customer new_vendor);
+use SL::Dev::Part qw(new_part);
use SL::DB::Buchungsgruppe;
use SL::DB::Currency;
use SL::DB::Exchangerate;
currency_id => $currency->id,
)->save;
- $customer = SL::Dev::CustomerVendor::create_customer(
+ $customer = new_customer(
name => 'Test Customer',
currency_id => $currency_id,
taxzone_id => $taxzone->id,
auto_calculation => 1,
)->save;
- $vendor = SL::Dev::CustomerVendor::create_vendor(
+ $vendor = new_vendor(
name => 'Test Vendor',
currency_id => $currency_id,
taxzone_id => $taxzone->id,
@parts = ();
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
partnumber => 'T4254',
description => 'Fourty-two fifty-four',
lastcost => 1.93,
%{ $params{part1} }
)->save;
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
partnumber => 'T0815',
description => 'Zero EIGHT fifteeN @ 7%',
lastcost => 5.473,
unit => $unit->name,
%{ $params{part2} }
)->save;
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
partnumber => '19%',
description => 'Testware 19%',
lastcost => 0,
unit => $unit->name,
%{ $params{part3} }
)->save;
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
partnumber => '7%',
description => 'Testware 7%',
lastcost => 0,
sub test_default_invoice_one_item_19_without_skonto() {
reset_state() if $ALWAYS_RESET;
- my $item = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item ],
payment_id => $payment_terms->id,
sub test_default_invoice_one_item_19_without_skonto_overpaid() {
reset_state() if $ALWAYS_RESET;
- my $item = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item ],
payment_id => $payment_terms->id,
sub test_default_invoice_two_items_19_7_tax_with_skonto() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 1.2);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
sub test_default_invoice_two_items_19_7_tax_with_skonto_tax_included() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 1.2);
+ my $invoice = create_sales_invoice(
taxincluded => 1,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
sub test_default_invoice_two_items_19_7_without_skonto() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 1.2);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
sub test_default_invoice_two_items_19_7_without_skonto_incomplete_payment() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 1.2);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 1.2);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 1.2);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
# (11.66) rather than the 19% account (5.85). The actual tax amount is
# higher for the 19% case, though (1.11 compared to 0.82)
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 1.2);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
reset_state() if $ALWAYS_RESET;
# if there are two cents left there will be two skonto bookings, 1 cent each
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 1.2);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 1.2);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto() {
reset_state() if $ALWAYS_RESET;
- my $item = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item ],
payment_id => $payment_terms->id,
sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto_1cent() {
reset_state() if $ALWAYS_RESET;
- my $item = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 2.5);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item = create_invoice_item(part => $parts[0], qty => 2.5);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item ],
payment_id => $payment_terms->id,
sub test_default_invoice_two_items_19_7_tax_with_skonto_50_50() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 1);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 1);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[2], qty => 1);
+ my $item2 = create_invoice_item(part => $parts[3], qty => 1);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
payment_id => $payment_terms->id,
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
- my $item3 = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
- my $item4 = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[2], qty => 0.5);
+ my $item2 = create_invoice_item(part => $parts[3], qty => 0.5);
+ my $item3 = create_invoice_item(part => $parts[2], qty => 0.5);
+ my $item4 = create_invoice_item(part => $parts[3], qty => 0.5);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2, $item3, $item4 ],
payment_id => $payment_terms->id,
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25_tax_included() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
- my $item3 = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
- my $item4 = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[2], qty => 0.5);
+ my $item2 = create_invoice_item(part => $parts[3], qty => 0.5);
+ my $item3 = create_invoice_item(part => $parts[2], qty => 0.5);
+ my $item4 = create_invoice_item(part => $parts[3], qty => 0.5);
+ my $invoice = create_sales_invoice(
taxincluded => 1,
invoiceitems => [ $item1, $item2, $item3, $item4 ],
payment_id => $payment_terms->id,
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25_multiple() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
- my $item3 = SL::Dev::Record::create_invoice_item(part => $parts[2], qty => 0.5);
- my $item4 = SL::Dev::Record::create_invoice_item(part => $parts[3], qty => 0.5);
- my $invoice = SL::Dev::Record::create_sales_invoice(
+ my $item1 = create_invoice_item(part => $parts[2], qty => 0.5);
+ my $item2 = create_invoice_item(part => $parts[3], qty => 0.5);
+ my $item3 = create_invoice_item(part => $parts[2], qty => 0.5);
+ my $item4 = create_invoice_item(part => $parts[3], qty => 0.5);
+ my $invoice = create_sales_invoice(
taxincluded => 0,
invoiceitems => [ $item1, $item2, $item3, $item4 ],
payment_id => $payment_terms->id,
sub test_credit_note_two_items_19_7_tax_tax_not_included() {
reset_state() if $ALWAYS_RESET;
- my $item1 = SL::Dev::Record::create_invoice_item(part => $parts[0], qty => 5);
- my $item2 = SL::Dev::Record::create_invoice_item(part => $parts[1], qty => 3);
- my $invoice = SL::Dev::Record::create_credit_note(
+ my $item1 = create_invoice_item(part => $parts[0], qty => 5);
+ my $item2 = create_invoice_item(part => $parts[1], qty => 3);
+ my $invoice = create_credit_note(
invnumber => 'cn1',
taxincluded => 0,
invoiceitems => [ $item1, $item2 ],
use List::MoreUtils qw(uniq);
use Support::TestSetup;
use Test::Exception;
-use SL::Dev::ALL;
+use SL::Dev::ALL qw(:ALL);
use SL::DB::Buchungsgruppe;
use SL::DB::Currency;
$tax7 = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07) || croak "No tax for 7\%";
$taxzone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || croak "No taxzone";
- $customer = SL::Dev::CustomerVendor::create_customer(
+ $customer = new_customer(
name => 'Test Customer',
taxzone_id => $taxzone->id,
%{ $params{customer} }
)->save;
@parts = ();
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
partnumber => 'T4254',
description => 'Fourty-two fifty-four',
lastcost => 1.93,
%{ $params{part1} }
)->save;
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
partnumber => 'T0815',
description => 'Zero EIGHT fifteeN @ 7%',
lastcost => 5.473,
%{ $params{part2} }
)->save;
- push @parts, SL::Dev::Part::create_part(
+ push @parts, new_part(
partnumber => 'T888',
description => 'Triple 8',
lastcost => 0,
sub new_invoice {
my %params = @_;
- return SL::Dev::Record::create_sales_invoice(
+ return create_sales_invoice(
taxzone_id => $taxzone->id,
%params,
);
my $part = delete($params{part}) || $parts[0];
- return SL::Dev::Record::create_invoice_item(
+ return create_invoice_item(
part => $part,
%params,
);
use Data::Dumper;
use Support::TestSetup;
use SL::DB::Part;
-use SL::Dev::Part;
+use SL::Dev::Part qw(new_part);
Support::TestSetup::login();
# test simple transaction
-my $part = create_part();
+my $part = new_part();
SL::DB->client->with_transaction(sub {
$part->save;
ok 1, 'part saved';
};
# test failing transaction
-my $part2 = create_part(partnumber => $part->partnumber); # woops, duplicate partnumber
+my $part2 = new_part(partnumber => $part->partnumber); # woops, duplicate partnumber
SL::DB->client->with_transaction(sub {
$part2->save;
ok 0, 'part saved';
# TODO - not possible to test without locally adding hooks in run time
# test if error gets correctly stored in db->error
-$part2 = create_part(partnumber => $part->partnumber); # woops, duplicate partnumber
+$part2 = new_part(partnumber => $part->partnumber); # woops, duplicate partnumber
SL::DB->client->with_transaction(sub {
$part2->save;
ok 0, 'part saved';
use Support::TestSetup;
use Test::Exception;
use SL::File;
-use SL::Dev::File;
+use SL::Dev::File qw(create_uploaded create_scanned create_created);
+
Support::TestSetup::login();
clear_up();
reset_state();
-my $file1 = SL::Dev::File::create_uploaded( file_name => 'file1', file_contents => 'inhalt1 uploaded' );
-my $file2 = SL::Dev::File::create_scanned( file_name => 'file2', file_contents => 'inhalt2 scanned', file_path => $scannerfile );
-my $file3 = SL::Dev::File::create_created( file_name => 'file3', file_contents => 'inhalt3 created' );
-my $file4 = SL::Dev::File::create_created( file_name => 'file3', file_contents => 'inhalt3 new version');
+my $file1 = create_uploaded( file_name => 'file1', file_contents => 'inhalt1 uploaded' );
+my $file2 = create_scanned( file_name => 'file2', file_contents => 'inhalt2 scanned', file_path => $scannerfile );
+my $file3 = create_created( file_name => 'file3', file_contents => 'inhalt3 created' );
+my $file4 = create_created( file_name => 'file3', file_contents => 'inhalt3 new version');
-is( SL::Dev::File->get_all_count(), 3,"total number of files created is 3");
+is( SL::Dev::File::get_all_count(), 3,"total number of files created is 3");
ok( $file1->file_name eq 'file1' ,"file has right name");
my $content1 = $file1->get_content;
ok( $$content1 eq 'inhalt1 uploaded' ,"file has right content");
my $content2 = File::Slurp::read_file($scannerfile);
ok( $content2 eq 'inhalt2 scanned' ,"scanned file has right content");
-my @file5 = SL::Dev::File->get_all(file_name => 'file3');
+my @file5 = SL::Dev::File::get_all(file_name => 'file3');
is( scalar( @file5), 1, "one actual file found");
my $content5 = $file5[0]->get_content();
ok( $$content5 eq 'inhalt3 new version' ,"file has right actual content");
-my @file6 = SL::Dev::File->get_all_versions(file_name => 'file3');
+my @file6 = SL::Dev::File::get_all_versions(file_name => 'file3');
is( scalar( @file6), 2,"two file versions found");
$content5 = $file6[0]->get_content;
ok( $$content5 eq 'inhalt3 new version' ,"file has right actual content");
sub clear_up {
# Cleaning up may fail.
eval {
- SL::Dev::File->delete_all();
+ SL::Dev::File::delete_all();
unlink($scannerfile);
};
}
use SL::DB::Bin;
use SL::WH;
use SL::AM;
-use SL::Dev::ALL;
+use SL::Dev::ALL qw(:ALL);
use SL::Helper::ShippedQty;
use DateTime;
my ($customer, $vendor, @parts, $unit);
-$customer = SL::Dev::CustomerVendor::create_customer(name => 'Testkunde' )->save;
-$vendor = SL::Dev::CustomerVendor::create_vendor( name => 'Testlieferant')->save;
+$customer = new_customer(name => 'Testkunde' )->save;
+$vendor = new_vendor( name => 'Testlieferant')->save;
my $default_sellprice = 10;
my $default_lastcost = 4;
-my ($wh) = SL::Dev::Inventory::create_warehouse_and_bins();
+my ($wh) = create_warehouse_and_bins();
my $bin1 = SL::DB::Manager::Bin->find_by(description => "Bin 1");
my $bin2 = SL::DB::Manager::Bin->find_by(description => "Bin 2");
# create 3 parts to be used in test
for my $i ( 1 .. 4 ) {
- SL::Dev::Part::create_part( %part_defaults, partnumber => $i, description => "part $i test" )->save;
+ new_part( %part_defaults, partnumber => $i, description => "part $i test" )->save;
};
my $part1 = SL::DB::Manager::Part->find_by( partnumber => '1' );
note("testing purchases, no fill_up");
-my $purchase_order = SL::Dev::Record::create_purchase_order(
+my $purchase_order = create_purchase_order(
save => 1,
- orderitems => [ SL::Dev::Record::create_order_item(part => $part1, qty => 11),
- SL::Dev::Record::create_order_item(part => $part2, qty => 12),
- SL::Dev::Record::create_order_item(part => $part3, qty => 13),
+ orderitems => [ create_order_item(part => $part1, qty => 11),
+ create_order_item(part => $part2, qty => 12),
+ create_order_item(part => $part3, qty => 13),
]
);
ok(!$purchase_order->items_sorted->[0]->{delivered}, "require_stock_out => 1: first purchase orderitem is not delivered");
# ship items from delivery order
-SL::Dev::Inventory::transfer_purchase_delivery_order($purchase_delivery_order);
+transfer_purchase_delivery_order($purchase_delivery_order);
Rose::DB::Object::Helpers::forget_related($purchase_order, 'orderitems');
$purchase_order->orderitems;
note('testing sales, no fill_up');
-my $sales_order = SL::Dev::Record::create_sales_order(
+my $sales_order = create_sales_order(
save => 1,
- orderitems => [ SL::Dev::Record::create_order_item(part => $part1, qty => 5),
- SL::Dev::Record::create_order_item(part => $part2, qty => 6),
- SL::Dev::Record::create_order_item(part => $part3, qty => 7),
+ orderitems => [ create_order_item(part => $part1, qty => 5),
+ create_order_item(part => $part2, qty => 6),
+ create_order_item(part => $part3, qty => 7),
]
);
ok(!$sales_order->items_sorted->[0]->{delivered}, "require_stock_out => 1: first sales orderitem is not delivered");
# ship items from delivery order
-SL::Dev::Inventory::transfer_sales_delivery_order($sales_delivery_order);
+transfer_sales_delivery_order($sales_delivery_order);
Rose::DB::Object::Helpers::forget_related($sales_order, 'orderitems');
$sales_order->orderitems;
use SL::DB::Unit;
use SL::DB::Part;
use SL::DB::Assembly;
-use SL::Dev::Part;
+use SL::Dev::Part qw(new_assembly);
use SL::DB::Helper::ValidateAssembly;
Support::TestSetup::login();
-my $assembly2_part = SL::Dev::Part::create_assembly( partnumber => '20000', assnumber => 'as2' )->save;
+my $assembly2_part = new_assembly( partnumber => '20000', assnumber => 'as2' )->save;
my $retval = validate_assembly($assembly_part,$assembly2_part);
ok(!defined $retval, 'assembly 19000 can be child of assembly 20000' );
$assembly2_part->add_assemblies(SL::DB::Assembly->new(parts_id => $assembly_part->id, qty => 3, bom => 1));
$assembly2_part->save;
-my $assembly3_part = SL::Dev::Part::create_assembly( partnumber => '30000', assnumber => 'as3' )->save;
+my $assembly3_part = new_assembly( partnumber => '30000', assnumber => 'as3' )->save;
$retval = validate_assembly($assembly3_part,$assembly_part);
ok(!defined $retval, 'assembly 30000 can be child of assembly 19000' );
sub reset_state {
my %params = @_;
- my $assembly = SL::Dev::Part::create_assembly( assnumber => '19000', partnumber => '19000' )->save;
+ my $assembly = new_assembly( assnumber => '19000', partnumber => '19000' )->save;
};
1;
use Carp;
use Test::Exception;
use SL::DB::Part;
-use SL::Dev::Part;
+use SL::Dev::Part qw(new_assortment);
Support::TestSetup::login();
clear_up();
-my $assortment = SL::Dev::Part::create_assortment( assnumber => 'aso1',
- description => "Assortment 1",
- number_of_parts => 10,
+my $assortment = new_assortment( assnumber => 'aso1',
+ description => "Assortment 1",
+ number_of_parts => 10,
)->save;
is( SL::DB::Manager::Part->get_all_count(), 11, "total number of parts created is 11");
use Carp;
use Test::Exception;
use SL::DB::Part;
-use SL::Dev::Part;
-use SL::Dev::Inventory;
+use SL::Dev::Part qw(new_part);
+use SL::Dev::Inventory qw(create_warehouse_and_bins set_stock transfer_stock);
Support::TestSetup::login();
clear_up();
-my ($wh1, $bin1_1) = SL::Dev::Inventory::create_warehouse_and_bins(
+my ($wh1, $bin1_1) = create_warehouse_and_bins(
warehouse_description => 'Testlager',
bin_description => 'Testlagerplatz',
number_of_bins => 2,
);
my $bin1_2 = $wh1->bins->[1];
-my ($wh2, $bin2_1) = SL::Dev::Inventory::create_warehouse_and_bins(
+my ($wh2, $bin2_1) = create_warehouse_and_bins(
warehouse_description => 'Testlager 2',
bin_description => 'Testlagerplatz 2',
number_of_bins => 2,
my $today = DateTime->today;
my $yesterday = $today->clone->add(days => -1);
-my $part = SL::Dev::Part::create_part->save;
-SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, qty => 7, shippingdate => $yesterday);
-SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, qty => 5);
-SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, abs_qty => 8); # apply -4 to get qty 8 in bin1_1
-SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_2->id, qty => 9);
-
-SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin2_1->id, abs_qty => 10);
-SL::Dev::Inventory::transfer_stock(part => $part,
- from_bin => $wh2->bins->[0],
- to_bin => $wh2->bins->[1],
- qty => 2,
- );
+my $part = new_part()->save;
+set_stock(part => $part, bin_id => $bin1_1->id, qty => 7, shippingdate => $yesterday);
+set_stock(part => $part, bin_id => $bin1_1->id, qty => 5);
+set_stock(part => $part, bin_id => $bin1_1->id, abs_qty => 8); # apply -4 to get qty 8 in bin1_1
+set_stock(part => $part, bin_id => $bin1_2->id, qty => 9);
+
+set_stock(part => $part, bin_id => $bin2_1->id, abs_qty => 10);
+transfer_stock(part => $part,
+ from_bin => $wh2->bins->[0],
+ to_bin => $wh2->bins->[1],
+ qty => 2,
+ );
is( SL::DB::Manager::Part->get_all_count(), 1, "total number of parts created is 1");
is( $part->get_stock == 27 , 1 , "total stock of part is 27");
use lib 't';
-use SL::Dev::Part;
+use SL::Dev::Part qw(new_part);
use_ok 'Support::TestSetup';
use_ok 'SL::DB::Bin';
SL::DB::Manager::Warehouse->delete_all(where => [ description => NAME() ]);
# Create test data
-$part = SL::Dev::Part::create_part(unit => 'mg', description => NAME(), partnumber => NAME())->save();
+$part = new_part(unit => 'mg', description => NAME(), partnumber => NAME())->save();
is(ref($part), 'SL::DB::Part', 'loading a part to test with id ' . $part->id);