-our ($ar_chart, $buchungsgruppe, $ctrl, $currency_id, $customer, $employee, $order, $part, $tax_zone, $unit, @invoices);
+our ($ar_chart, $ctrl, $customer, $order, $part, $unit, @invoices);
+
+sub clear_up {
+ "SL::DB::Manager::${_}"->delete_all(all => 1) for qw(InvoiceItem Invoice OrderItem Order Customer Part);
+};
- $ar_chart = SL::DB::Manager::Chart->find_by(accno => '1400') || croak "No AR chart";
- $buchungsgruppe = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%') || croak "No accounting group";
- $currency_id = SL::DB::Default->get->currency_id;
- $employee = SL::DB::Manager::Employee->current || croak "No employee";
- $tax_zone = SL::DB::Manager::TaxZone->find_by( description => 'Inland') || croak "No taxzone";
- $unit = SL::DB::Manager::Unit->find_by(name => 'psch') || croak "No unit";
+ $ar_chart = SL::DB::Manager::Chart->find_by(accno => '1400') || croak "No AR chart";
+ $unit = SL::DB::Manager::Unit->find_by(name => 'psch') || croak "No unit";
- $order = SL::DB::Order->new(
- customer_id => $customer->id,
- currency_id => $currency_id,
- taxzone_id => $tax_zone->id,
+ $order = create_sales_order(
+ save => 1,
+ customer => $customer,
transaction_description => '<%period_start_date%>',
transdate => DateTime->from_kivitendo('01.03.2014'),
transaction_description => '<%period_start_date%>',
transdate => DateTime->from_kivitendo('01.03.2014'),
- orderitems => [
- { parts_id => $part->id,
- description => $part->description,
- lastcost => $part->lastcost,
- sellprice => $part->sellprice,
- qty => 1,
- unit => $unit->name,
- %{ $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,
periodic_invoices_config => $params{periodic_invoices_config} ? {
active => 1,
ar_chart_id => $ar_chart->id,
# ----------------------------------------------------------------------
# An order without periodic invoices:
# ----------------------------------------------------------------------
# An order without periodic invoices:
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);
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
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q
periodic_invoices_config => {
periodicity => 'm',
order_value_periodicity => 'y',
periodic_invoices_config => {
periodicity => 'm',
order_value_periodicity => 'y',
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting in previous year
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting in previous year
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting in previous year, ending middle of year
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting in previous year, ending middle of year
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting and ending before current
# ----------------------------------------------------------------------
# order_value_periodicity=y, periodicity=q, starting and ending before current
is_deeply($ctrl->data->{$_}, { months => [ (0) x 12 ], quarters => [ 0, 0, 0, 0 ], year => 0 }, "periodic conf p=q ovp=y, no invoices, starting and ending before current year, data for $_")
for qw(purchase_invoices purchase_orders requests_for_quotation sales_invoices sales_orders sales_orders_per_inv sales_quotations);
is_deeply($ctrl->data->{$_}, { months => [ (0) x 12 ], quarters => [ 0, 0, 0, 0 ], year => 0 }, "periodic conf p=q ovp=y, no invoices, starting and ending before current year, data for $_")
for qw(purchase_invoices purchase_orders requests_for_quotation sales_invoices sales_orders sales_orders_per_inv sales_quotations);