X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fcontrollers%2Fcsvimport%2Finventory.t;h=14923234b6cd451ca5cbe33f2e2f6e1a1c7d1796;hb=092d31105afe7d3dd180502fec1272df07713815;hp=952210de1e58ddfbd9303de777efd53219a61312;hpb=0b68d45da337a155d69fe2417a3c27a1689c5642;p=kivitendo-erp.git diff --git a/t/controllers/csvimport/inventory.t b/t/controllers/csvimport/inventory.t index 952210de1..14923234b 100644 --- a/t/controllers/csvimport/inventory.t +++ b/t/controllers/csvimport/inventory.t @@ -263,7 +263,38 @@ $inv_obj = SL::DB::Manager::Inventory->find_by(trans_id => $trans_id); # we expect one entry for one trans_id is ref $inv_obj, "SL::DB::Inventory", "One inventory object, no array or undef"; -is $inv_obj->qty == 30.35, 1, "Valid qty accepted"; +is $inv_obj->qty == 30.35, 1, "Valid qty accepted"; +is $inv_obj->comment, "Jetzt wirklich", "Valid comment accepted"; +is $inv_obj->employee_id, 1, "Employee valid"; +is ref $inv_obj->shippingdate, 'DateTime', "Valid DateTime for shippingdate"; +is $inv_obj->shippingdate, DateTime->today_local, "Default shippingdate set"; + +$tt = SL::DB::Manager::TransferType->find_by(id => $inv_obj->trans_type_id); + +is ref $tt, 'SL::DB::TransferType', "Valid TransferType, no undef"; +is $tt->direction, 'in', "Transfer direction correct"; +is $tt->description, 'correction', "Transfer description correct"; + +# target_qty is 0 + +$file = \<[0]; +is scalar @{ $entry->{errors} }, 0, "No error for valid data occurred"; +is $entry->{object}->qty, "-33.75", "Valid qty accepted"; # evals to text qty = target_qty - actual_qty +is(SL::Helper::Inventory::get_stock(part => $part1), "0.00000", 'simple add (stock) qty works'); +is(SL::Helper::Inventory::get_onhand(part => $part1), undef, 'simple add (onhand) qty works'); # hmm good return? + +# now check the real Inventory entry +$trans_id = $entry->{object}->trans_id; +$inv_obj = SL::DB::Manager::Inventory->find_by(trans_id => $trans_id); + +# we expect one entry for one trans_id +is ref $inv_obj, "SL::DB::Inventory", "One inventory object, no array or undef"; +is $inv_obj->qty == -33.75000, 1, "Valid qty accepted"; is $inv_obj->comment, "Jetzt wirklich", "Valid comment accepted"; is $inv_obj->employee_id, 1, "Employee valid"; @@ -273,9 +304,32 @@ is $inv_obj->shippingdate, DateTime->today_local, "Default shippingdate set"; $tt = SL::DB::Manager::TransferType->find_by(id => $inv_obj->trans_type_id); is ref $tt, 'SL::DB::TransferType', "Valid TransferType, no undef"; -is $tt->direction, 'in', "Transfer direction correct"; +is $tt->direction, 'out', "Transfer direction correct"; is $tt->description, 'correction', "Transfer description correct"; +# add some stuff with a different numberformat + +$::myconfig{numberformat} = '1.000,00'; +$file = \<[0]; +is scalar @{ $entry->{errors} }, 0, "No error for valid data occurred"; +is $entry->{object}->qty, "31.2", "Valid qty accepted"; # evals to text qty = target_qty - actual_qty +is(SL::Helper::Inventory::get_stock(part => $part1), "31.20000", 'simple add (stock) qty works'); +is(SL::Helper::Inventory::get_onhand(part => $part1), "31.20000", 'simple add (onhand) qty works'); + +# now check the real Inventory entry +$trans_id = $entry->{object}->trans_id; +$inv_obj = SL::DB::Manager::Inventory->find_by(trans_id => $trans_id); + +# we expect one entry for one trans_id +is ref $inv_obj, "SL::DB::Inventory", "One inventory object, no array or undef"; +is $inv_obj->qty == 31.2, 1, "Valid qty calculated"; + + clear_up(); # remove all data at end of tests