From 98b64fe1e380c232428d63cea0eb5f44b1d1a2c3 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Thu, 28 Jul 2016 18:30:14 +0200 Subject: [PATCH] Ware/Erzeugnis/Dienstleistung per parts.part_type unterscheiden 2 kivitendo Code angepasst. --- SL/Common.pm | 6 +-- SL/Controller/CsvImport/Part.pm | 6 +-- SL/DB/Helper/FlattenToForm.pm | 3 +- SL/DB/Manager/Part.pm | 15 ++---- SL/DB/Part.pm | 33 ++++++------ SL/DO.pm | 2 +- SL/Form.pm | 9 ++-- SL/IC.pm | 22 ++++---- SL/IR.pm | 4 +- SL/IS.pm | 8 +-- SL/OE.pm | 2 +- SL/WH.pm | 2 +- bin/mozilla/io.pl | 2 +- sql/Pg-upgrade2/erzeugnisnummern.pl | 7 ++- t/background_job/create_periodic_invoices.t | 1 + ...ales_order_with_periodic_invoices_config.t | 1 + .../financial_overview/sales_orders.t | 1 + t/controllers/helpers/parse_filter.t | 51 ++++++++++--------- t/db_helper/convert_invoice.t | 2 + t/db_helper/payment.t | 4 ++ t/db_helper/price_tax_calculator.t | 3 ++ t/part/assembly.t | 3 +- t/wh/transfer.t | 2 +- 23 files changed, 97 insertions(+), 92 deletions(-) diff --git a/SL/Common.pm b/SL/Common.pm index f6a72679a..b70378e66 100644 --- a/SL/Common.pm +++ b/SL/Common.pm @@ -67,14 +67,14 @@ sub retrieve_parts { } if ($form->{no_assemblies}) { - $filter .= qq| AND (NOT COALESCE(assembly, FALSE))|; + $filter .= qq| AND (NOT part_type = 'assembly')|; } if ($form->{assemblies}) { - $filter .= qq| AND assembly=TRUE|; + $filter .= qq| AND part_type = 'assembly'|; } if ($form->{no_services}) { - $filter .= qq| AND (inventory_accno_id is not NULL or assembly=TRUE)|; + $filter .= qq| AND NOT (part_type = 'service' OR part_type = 'assembly')|; } substr($filter, 1, 3) = "WHERE" if ($filter); diff --git a/SL/Controller/CsvImport/Part.pm b/SL/Controller/CsvImport/Part.pm index 9ccaf83b5..4a0074812 100644 --- a/SL/Controller/CsvImport/Part.pm +++ b/SL/Controller/CsvImport/Part.pm @@ -97,12 +97,12 @@ sub init_warehouses_by { sub init_parts_by { my ($self) = @_; -# my $parts_by = { id => { map { ( $_->id => $_ ) } grep { !$_->assembly } @{ $self->existing_objects } }, +# my $parts_by = { id => { map { ( $_->id => $_ ) } grep { !$_->part_type = 'assembly' } @{ $self->existing_objects } }, # partnumber => { part => { }, # service => { } } }; # # foreach my $part (@{ $self->existing_objects }) { -# next if $part->assembly; +# next if $part->part_type eq 'assembly'; # $parts_by->{partnumber}->{ $part->type }->{ $part->partnumber } = $part; # } @@ -675,7 +675,7 @@ sub init_profile { my ($self) = @_; my $profile = $self->SUPER::init_profile; - delete @{$profile}{qw(alternate assembly bom expense_accno_id income_accno_id inventory_accno_id makemodel priceupdate stockable type)}; + delete @{$profile}{qw(bom expense_accno_id income_accno_id inventory_accno_id makemodel priceupdate stockable type)}; $profile->{"pricegroup_$_"} = '' for 1 .. scalar @{ $_[0]->all_pricegroups }; diff --git a/SL/DB/Helper/FlattenToForm.pm b/SL/DB/Helper/FlattenToForm.pm index cda59e7d6..cca17044b 100644 --- a/SL/DB/Helper/FlattenToForm.pm +++ b/SL/DB/Helper/FlattenToForm.pm @@ -82,7 +82,8 @@ sub flatten_to_form { $form->{"partsgroup_${idx}"} = $item->part->partsgroup->partsgroup if _has($item->part, 'partsgroup_id'); _copy($item, $form, "${items_name}_", "_${idx}", 0, qw(id)) if $items_name; - _copy($item->part, $form, '', "_${idx}", 0, qw(id partnumber weight assembly)); + # TODO: is part_type correct here? Do we need to set part_type as default? + _copy($item->part, $form, '', "_${idx}", 0, qw(id partnumber weight part_type)); _copy($item->part, $form, '', "_${idx}", 0, qw(listprice)); _copy($item, $form, '', "_${idx}", 0, qw(description project_id ship serialnumber pricegroup_id ordnumber donumber cusordnumber unit subtotal longdescription price_factor_id marge_price_factor approved_sellprice reqdate transdate diff --git a/SL/DB/Manager/Part.pm b/SL/DB/Manager/Part.pm index 0b751bd34..b43b57319 100644 --- a/SL/DB/Manager/Part.pm +++ b/SL/DB/Manager/Part.pm @@ -33,7 +33,7 @@ sub type_filter { $prefix //= ''; - # this is to make selection like type => { part => 1, service => 1 } work + # this is to make selections like part_type => { part => 1, service => 1 } work if ('HASH' eq ref $type) { $type = [ grep { $type->{$_} } keys %$type ]; } @@ -43,16 +43,11 @@ sub type_filter { for my $type (@types) { if ($type =~ m/^part/) { - push @filter, (and => [ or => [ $prefix . assembly => 0, $prefix . assembly => undef ], - "!${prefix}inventory_accno_id" => 0, - "!${prefix}inventory_accno_id" => undef, - ]); + push @filter, ($prefix . part_type => 'part'); } elsif ($type =~ m/^service/) { - push @filter, (and => [ or => [ $prefix . assembly => 0, $prefix . assembly => undef ], - or => [ $prefix . inventory_accno_id => 0, $prefix . inventory_accno_id => undef ], - ]); - } elsif ($type =~ m/^assembl/) { - push @filter, ($prefix . assembly => 1); + push @filter, ($prefix . part_type => 'service'); + } elsif ($type =~ m/^assembly/) { + push @filter, ($prefix . part_type => 'assembly'); } } diff --git a/SL/DB/Part.pm b/SL/DB/Part.pm index a83e9bd75..d6ffc3547 100644 --- a/SL/DB/Part.pm +++ b/SL/DB/Part.pm @@ -61,36 +61,37 @@ sub is_type { return $self->type eq $type ? 1 : 0; } -sub is_part { $_[0]->is_type('part') } -sub is_assembly { $_[0]->is_type('assembly') } -sub is_service { $_[0]->is_type('service') } +sub is_part { $_[0]->part_type eq 'part' } +sub is_assembly { $_[0]->part_type eq 'assembly' } +sub is_service { $_[0]->part_type eq 'service' } sub type { - my ($self, $type) = @_; - if (@_ > 1) { - die 'invalid type' unless $type =~ /^(?:part|service|assembly)$/; - $self->assembly( $type eq 'assembly' ? 1 : 0); - $self->inventory_accno_id($type eq 'part' ? 1 : undef); - } - - return 'assembly' if $self->assembly; - return 'part' if $self->inventory_accno_id; - return 'service'; + return $_[0]->part_type; + # my ($self, $type) = @_; + # if (@_ > 1) { + # die 'invalid type' unless $type =~ /^(?:part|service|assembly)$/; + # $self->assembly( $type eq 'assembly' ? 1 : 0); + # $self->inventory_accno_id($type ne 'service' ? 1 : undef); + # } + + # return 'assembly' if $self->assembly; + # return 'part' if $self->inventory_accno_id; + # return 'service'; } sub new_part { my ($class, %params) = @_; - $class->new(%params, type => 'part'); + $class->new(%params, part_type => 'part'); } sub new_assembly { my ($class, %params) = @_; - $class->new(%params, type => 'assembly'); + $class->new(%params, part_type => 'assembly'); } sub new_service { my ($class, %params) = @_; - $class->new(%params, type => 'service'); + $class->new(%params, part_type => 'service'); } sub orphaned { diff --git a/SL/DO.pm b/SL/DO.pm index 4ba482850..b087becdd 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -779,7 +779,7 @@ sub retrieve { # stuff different from the whole will not be overwritten, but saved with a suffix. $query = qq|SELECT doi.id AS delivery_order_items_id, - p.partnumber, p.assembly, p.listprice, doi.description, doi.qty, + p.partnumber, p.part_type, p.listprice, doi.description, doi.qty, doi.sellprice, doi.parts_id AS id, doi.unit, doi.discount, p.notes AS partnotes, doi.reqdate, doi.project_id, doi.serialnumber, doi.lastcost, doi.ordnumber, doi.transdate, doi.cusordnumber, doi.longdescription, diff --git a/SL/Form.pm b/SL/Form.pm index 5c7d062ab..b2a707b4f 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -3180,16 +3180,13 @@ sub get_partsgroup { my @values; if ($p->{searchitems} eq 'part') { - $query .= qq|WHERE p.inventory_accno_id > 0|; + $query .= qq|WHERE p.part_type = 'part'|; } if ($p->{searchitems} eq 'service') { - $query .= qq|WHERE p.inventory_accno_id IS NULL|; + $query .= qq|WHERE p.part_type = 'service'|; } if ($p->{searchitems} eq 'assembly') { - $query .= qq|WHERE p.assembly = '1'|; - } - if ($p->{searchitems} eq 'labor') { - $query .= qq|WHERE (p.inventory_accno_id > 0) AND (p.income_accno_id IS NULL)|; + $query .= qq|WHERE p.part_type = 'assembly'|; } $query .= qq|ORDER BY partsgroup|; diff --git a/SL/IC.pm b/SL/IC.pm index d70c214d2..942831bfa 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -78,10 +78,10 @@ sub get_part { $form->{lastmtime} = $form->{mtime}; $form->{onhand} *= 1; + die "part needs a part_type" unless $form->{part_type}; # TODO from part_type enum conversion # part or service item - $form->{item} = ($form->{inventory_accno}) ? 'part' : 'service'; - if ($form->{assembly}) { - $form->{item} = 'assembly'; + $form->{item} = $form->{part_type}; + if ($form->{item} eq 'assembly') { # retrieve assembly items $query = @@ -256,7 +256,6 @@ sub _save { my $makemodel = ($form->{make_1} || $form->{model_1} || ($form->{makemodel_rows} > 1)) ? 1 : 0; - $form->{assembly} = ($form->{item} eq 'assembly') ? 1 : 0; my ($query, $sth); @@ -300,7 +299,7 @@ sub _save { $form->{partnumber} ||= $trans_number->create_unique; ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('id')|); - do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit) VALUES (?, ?, ?)|, $form->{id}, $form->{partnumber}, $form->{unit}); + do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit, part_type) VALUES (?, ?, ?, ?)|, $form->{id}, $form->{partnumber}, $form->{unit}, $form->{item}); $form->{orphaned} = 1; } @@ -336,7 +335,6 @@ sub _save { partnumber = ?, description = ?, makemodel = ?, - assembly = ?, listprice = ?, sellprice = ?, lastcost = ?, @@ -362,6 +360,7 @@ sub _save { has_sernumber = ?, not_discountable = ?, microfiche = ?, + part_type = ?, partsgroup_id = ?, price_factor_id = ? $priceupdate @@ -369,7 +368,6 @@ sub _save { @values = ($form->{partnumber}, $form->{description}, $makemodel ? 't' : 'f', - $form->{assembly} ? 't' : 'f', $form->{listprice}, $form->{sellprice}, $form->{lastcost}, @@ -393,6 +391,7 @@ sub _save { $form->{has_sernumber} ? 't' : 'f', $form->{not_discountable} ? 't' : 'f', $form->{microfiche}, + $form->{item}, conv_i($partsgroup_id), conv_i($form->{price_factor_id}), conv_i($form->{id}) @@ -576,7 +575,7 @@ sub retrieve_assemblies { FROM parts p2, assembly a WHERE (p2.id = a.parts_id) AND (a.id = p.id)) AS inventory FROM parts p - WHERE NOT p.obsolete AND p.assembly $where|; + WHERE NOT p.obsolete AND p.part_type = 'assembly' $where|; $form->{assembly_items} = selectall_hashref_query($form, $dbh, $query, @values); @@ -893,10 +892,9 @@ sub all_parts { } for ($form->{searchitems}) { - push @where_tokens, 'p.inventory_accno_id > 0' if /part/; - push @where_tokens, 'p.inventory_accno_id IS NULL' if /service/; - push @where_tokens, 'NOT p.assembly' if /service/; - push @where_tokens, ' p.assembly' if /assembly/; + push @where_tokens, "p.part_type = 'part'" if /part/; + push @where_tokens, "p.part_type = 'service'" if /service/; + push @where_tokens, "p.part_type = 'assembly'" if /assembly/; } for ($form->{itemstatus}) { diff --git a/SL/IR.pm b/SL/IR.pm index 3498bf0bf..25820bd12 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -1218,7 +1218,7 @@ sub retrieve_item { my $i = $form->{rowcount}; # don't include assemblies or obsolete parts - my $where = "NOT p.assembly = '1' AND NOT p.obsolete = '1'"; + my $where = "NOT p.part_type = 'assembly' AND NOT p.obsolete = '1'"; my @values; foreach my $table_column (qw(p.partnumber p.description pg.partsgroup)) { @@ -1276,7 +1276,7 @@ sub retrieve_item { my $query = qq|SELECT p.id, p.partnumber, p.description, p.lastcost AS sellprice, p.listprice, - p.unit, p.assembly, p.onhand, p.formel, + p.unit, p.part_type, p.onhand, p.formel, p.notes AS partnotes, p.notes AS longdescription, p.not_discountable, p.inventory_accno_id, p.price_factor_id, p.ean, diff --git a/SL/IS.pm b/SL/IS.pm index bc23f7f72..f09b17871 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1656,7 +1656,7 @@ sub process_assembly { my ($dbh, $myconfig, $form, $position, $id, $totalqty) = @_; my $query = - qq|SELECT a.parts_id, a.qty, p.assembly, p.partnumber, p.description, p.unit, + qq|SELECT a.parts_id, a.qty, p.part_type, p.partnumber, p.description, p.unit, p.inventory_accno_id, p.income_accno_id, p.expense_accno_id FROM assembly a JOIN parts p ON (a.parts_id = p.id) @@ -1797,7 +1797,7 @@ sub reverse_invoice { # reverse inventory items my $query = - qq|SELECT i.id, i.parts_id, i.qty, i.assemblyitem, p.assembly, p.inventory_accno_id + qq|SELECT i.id, i.parts_id, i.qty, i.assemblyitem, p.part_type, p.inventory_accno_id FROM invoice i JOIN parts p ON (i.parts_id = p.id) WHERE i.trans_id = ?|; @@ -2003,7 +2003,7 @@ sub _retrieve_invoice { i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.discount, i.parts_id AS id, i.unit, i.deliverydate AS reqdate, i.project_id, i.serialnumber, i.pricegroup_id, i.ordnumber, i.donumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost, i.price_factor_id, i.price_factor, i.marge_price_factor, i.active_price_source, i.active_discount_source, - p.partnumber, p.assembly, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, p.formel, p.listprice, + p.partnumber, p.part_type, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, p.formel, p.listprice, pr.projectnumber, pg.partsgroup, prg.pricegroup FROM invoice i @@ -2314,7 +2314,7 @@ sub retrieve_item { c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid, - p.unit, p.assembly, p.onhand, + p.unit, p.part_type, p.onhand, p.notes AS partnotes, p.notes AS longdescription, p.not_discountable, p.formel, p.payment_id AS part_payment_id, p.price_factor_id, p.weight, diff --git a/SL/OE.pm b/SL/OE.pm index c82a3322e..d3863497b 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -1093,7 +1093,7 @@ sub _retrieve { c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from as income_valid, c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from as expense_valid, oe.ordnumber AS ordnumber_oe, oe.transdate AS transdate_oe, oe.cusordnumber AS cusordnumber_oe, - p.partnumber, p.assembly, p.listprice, o.description, o.qty, + p.partnumber, p.part_type, p.listprice, o.description, o.qty, o.sellprice, o.parts_id AS id, o.unit, o.discount, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, o.reqdate, o.project_id, o.serialnumber, o.ship, o.lastcost, o.ordnumber, o.transdate, o.cusordnumber, o.subtotal, o.longdescription, diff --git a/SL/WH.pm b/SL/WH.pm index a548bda77..89a937f9a 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -191,7 +191,7 @@ sub transfer_assembly { my $query = qq|SELECT assembly.parts_id, assembly.qty, parts.warehouse_id FROM assembly INNER JOIN parts ON assembly.parts_id = parts.id - WHERE assembly.id = ? AND (inventory_accno_id IS NOT NULL OR parts.assembly = TRUE)|; + WHERE assembly.id = ? AND parts.part_type != 'service'|; my $sth_part_qty_assembly = prepare_execute_query($form, $dbh, $query, $params{assembly_id}); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 6826833d7..3a77b09a0 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -604,7 +604,7 @@ sub item_selected { my @new_fields = qw(id partnumber description sellprice listprice inventory_accno - income_accno expense_accno bin unit weight assembly taxaccounts + income_accno expense_accno bin unit weight part_type taxaccounts partsgroup formel longdescription not_discountable partnotes lastcost price_factor_id price_factor); diff --git a/sql/Pg-upgrade2/erzeugnisnummern.pl b/sql/Pg-upgrade2/erzeugnisnummern.pl index bd8eb1cd8..8468e6922 100644 --- a/sql/Pg-upgrade2/erzeugnisnummern.pl +++ b/sql/Pg-upgrade2/erzeugnisnummern.pl @@ -79,16 +79,15 @@ sub filter_parts { } if ($::form->{filter_type} eq 'assembly') { - $where .= ' AND assembly'; + $where .= " AND part_type = 'assembly'"; } if ($::form->{filter_type} eq 'service') { - $where .= ' AND inventory_accno_id IS NULL AND NOT assembly'; + $where .= " AND part_type = 'service'"; } if ($::form->{filter_type} eq 'part') { - $where .= ' AND inventory_accno_id IS NOT NULL'; - $where .= ' AND NOT assembly'; + $where .= " AND part_type = 'part'"; } if ($::form->{filter_obsolete} eq 'obsolete') { diff --git a/t/background_job/create_periodic_invoices.t b/t/background_job/create_periodic_invoices.t index 9f55a0c94..783f7c59c 100644 --- a/t/background_job/create_periodic_invoices.t +++ b/t/background_job/create_periodic_invoices.t @@ -69,6 +69,7 @@ sub create_invoices { description => 'Fourty-two fifty-four', lastcost => 222.22, sellprice => 333.33, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe->id, unit => $unit->name, %{ $params{part} } diff --git a/t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t b/t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t index 1dab1e8f0..943666d85 100644 --- a/t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t +++ b/t/controllers/financial_controlling/sales_order_with_periodic_invoices_config.t @@ -66,6 +66,7 @@ sub create_sales_order { description => 'Fourty-two fifty-four', lastcost => 222.22, sellprice => 333.33, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe->id, unit => $unit->name, %{ $params{part} } diff --git a/t/controllers/financial_overview/sales_orders.t b/t/controllers/financial_overview/sales_orders.t index 8994faddf..cfa4ad5cd 100644 --- a/t/controllers/financial_overview/sales_orders.t +++ b/t/controllers/financial_overview/sales_orders.t @@ -70,6 +70,7 @@ sub create_sales_order { description => 'Fourty-two fifty-four', lastcost => 222.22, sellprice => 333.33, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe->id, unit => $unit->name, %{ $params{part} } diff --git a/t/controllers/helpers/parse_filter.t b/t/controllers/helpers/parse_filter.t index 0d3db7feb..7fab3da46 100644 --- a/t/controllers/helpers/parse_filter.t +++ b/t/controllers/helpers/parse_filter.t @@ -243,47 +243,48 @@ test { }, 'object test simple', class => 'SL::DB::Manager::Part'; test { - 'type' => 'assembly', + 'part_type' => 'assembly', }, { query => [ - 'assembly' => 1 - ], + 'part_type', + 'assembly' + ] , }, 'object test without prefix', class => 'SL::DB::Manager::Part'; test { - 'part.type' => 'assembly', + 'part.part_type' => 'assembly', }, { query => [ - 'part.assembly' => 1 - ], + 'part.part_type', + 'assembly' + ] }, 'object test with prefix', class => 'SL::DB::Manager::OrderItem'; test { - 'type' => [ 'part', 'assembly' ], + 'part_type' => [ 'part', 'assembly' ], }, { query => [ - or => [ - and => [ or => [ assembly => 0, assembly => undef ], - "!inventory_accno_id" => 0, - "!inventory_accno_id" => undef, - ], - assembly => 1, - ] - ], + 'or', + [ + 'part_type', + 'part', + 'part_type', + 'assembly' + ] + ] }, 'object test without prefix but complex value', class => 'SL::DB::Manager::Part'; - test { - 'part.type' => [ 'part', 'assembly' ], + 'part.part_type' => [ 'part', 'assembly' ], }, { query => [ - or => [ - and => [ or => [ 'part.assembly' => 0, 'part.assembly' => undef ], - "!part.inventory_accno_id" => 0, - "!part.inventory_accno_id" => undef, - ], - 'part.assembly' => 1, - ] - ], + 'or', + [ + 'part.part_type', + 'part', + 'part.part_type', + 'assembly' + ] + ] }, 'object test with prefix but complex value', class => 'SL::DB::Manager::OrderItem'; test { diff --git a/t/db_helper/convert_invoice.t b/t/db_helper/convert_invoice.t index abc3d8494..ead4024ce 100644 --- a/t/db_helper/convert_invoice.t +++ b/t/db_helper/convert_invoice.t @@ -93,6 +93,7 @@ sub reset_state { 'listprice' => '0.00000', 'onhand' => '5.00000', 'partnumber' => 'v-519160549', + part_type => 'part', #'partsgroup_id' => 111645, 'rop' => '0', 'sellprice' => '242.20000', @@ -113,6 +114,7 @@ Kapseln mit Yamaha Profil, Kerbenabstand 3,6 mm mit eingedrehten Abnickschrauben 'id' => 25505, 'lastcost' => '153.00000', 'listprice' => '0.00000', + 'part_type' => 'part', 'onhand' => '9.00000', 'partnumber' => 'v-120160086', # 'partsgroup_id' => 111639, diff --git a/t/db_helper/payment.t b/t/db_helper/payment.t index 2919cf491..9eb2d9d77 100644 --- a/t/db_helper/payment.t +++ b/t/db_helper/payment.t @@ -147,6 +147,7 @@ sub reset_state { description => 'Fourty-two fifty-four', lastcost => 1.93, sellprice => 2.34, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe->id, unit => $unit->name, %{ $params{part1} } @@ -157,6 +158,7 @@ sub reset_state { description => 'Zero EIGHT fifteeN @ 7%', lastcost => 5.473, sellprice => 9.714, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe7->id, unit => $unit->name, %{ $params{part2} } @@ -166,6 +168,7 @@ sub reset_state { description => 'Testware 19%', lastcost => 0, sellprice => 50, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe->id, unit => $unit->name, %{ $params{part3} } @@ -175,6 +178,7 @@ sub reset_state { description => 'Testware 7%', lastcost => 0, sellprice => 50, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe7->id, unit => $unit->name, %{ $params{part4} } diff --git a/t/db_helper/price_tax_calculator.t b/t/db_helper/price_tax_calculator.t index 8f09a4cda..22f4165dd 100644 --- a/t/db_helper/price_tax_calculator.t +++ b/t/db_helper/price_tax_calculator.t @@ -62,6 +62,7 @@ sub reset_state { description => 'Fourty-two fifty-four', lastcost => 1.93, sellprice => 2.34, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe->id, unit => $unit->name, %{ $params{part1} } @@ -72,6 +73,7 @@ sub reset_state { description => 'Zero EIGHT fifteeN @ 7%', lastcost => 5.473, sellprice => 9.714, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe7->id, unit => $unit->name, %{ $params{part2} } @@ -82,6 +84,7 @@ sub reset_state { description => 'Triple 8', lastcost => 0, sellprice => 0.6, + part_type => 'part', buchungsgruppen_id => $buchungsgruppe->id, unit => $unit->name, %{ $params{part3} } diff --git a/t/part/assembly.t b/t/part/assembly.t index d7da36cca..28654b74d 100644 --- a/t/part/assembly.t +++ b/t/part/assembly.t @@ -20,7 +20,7 @@ my $assembly_item_part = SL::DB::Manager::Part->find_by( partnumber => '19000' ) is($assembly_part->inventory_accno_id, undef, "assembly doesn't have an inventory accno id"); -is($assembly_part->type, 'assembly', 'assembly has correct type'); +is($assembly_part->part_type, 'assembly', 'assembly has correct type'); is( scalar @{$assembly_part->assemblies}, 2, 'assembly consists of two parts' ); # fetch assembly item corresponding to partnumber 19000 @@ -46,6 +46,7 @@ sub reset_state { $part1 = SL::DB::Part->new_part(partnumber => '19000', unit => $unit->name, + part_type => 'part', )->save; $part2 = $part1->clone_and_reset($part1); $part2->partnumber($part1->partnumber + 1); diff --git a/t/wh/transfer.t b/t/wh/transfer.t index 66daf58f7..2a05c55d3 100644 --- a/t/wh/transfer.t +++ b/t/wh/transfer.t @@ -26,7 +26,7 @@ SL::DB::Manager::Bin ->delete_all(where => [ or => [ description => NAME() SL::DB::Manager::Warehouse->delete_all(where => [ description => NAME() ]); # Create test data -$part = SL::DB::Part->new(unit => 'mg', description => NAME(), partnumber => NAME()); +$part = SL::DB::Part->new(unit => 'mg', description => NAME(), partnumber => NAME(), part_type => 'part'); $part->save(); is(ref($part), 'SL::DB::Part', 'loading a part to test with id ' . $part->id); -- 2.20.1