Auftrags-Controller: Fix: Preisquellenermittlung: js-Funktion richtig aufrufen
[kivitendo-erp.git] / t / wh / journal.t
1 use strict;
2 use Test::More tests => 4;
3
4 use lib 't';
5
6 use SL::Dev::Part qw(new_part);
7 use SL::Dev::Inventory qw(create_warehouse_and_bins);
8 use SL::DB::Inventory;
9 use Support::TestSetup;
10
11 Support::TestSetup::login();
12
13 use_ok("SL::WH");
14
15 my ($wh, $bin, $part);
16
17 sub init  {
18   ($wh, $bin) = create_warehouse_and_bins(
19     warehouse_description => 'Test warehouse',
20     bin_description       => 'Test bin',
21     number_of_bins        => 1,
22   );
23
24   $part = new_part()->save->load;
25
26   my $tt_used = SL::DB::Manager::TransferType->find_by(direction => 'out', description => 'used') or die;
27   my $tt_assembled = SL::DB::Manager::TransferType->find_by(direction => 'in', description => 'assembled') or die;
28
29   my %args = (
30     trans_id     => 1,
31     bin          => $bin,
32     warehouse    => $wh,
33     part         => $part,
34     qty          => 1,
35     employee     => SL::DB::Manager::Employee->current,
36     shippingdate => DateTime->now,
37   );
38
39   SL::DB::Inventory->new(%args, trans_type => $tt_used, qty => -1)->save;
40   SL::DB::Inventory->new(%args, trans_type => $tt_used, qty => -1)->save;
41   SL::DB::Inventory->new(%args, trans_type => $tt_assembled, qty => 1)->save;
42
43   qty                           => { type => 'numeric', precision => 25, scale => 5 },
44   shippingdate                  => { type => 'date', not_null => 1 },
45 }
46
47 sub reset_inventory {
48   SL::DB::Manager::Inventory->delete_all(all => 1);
49 }
50
51 reset_inventory();
52 init();
53
54 # l_date = Y
55 # l_warehouse_from = Y
56 # l_bin_from = Y
57 # l_warehouse_to = Y
58 # l_bin_to = Y
59 # l_partnumber = Y
60 # l_partdescription = Y
61 # l_chargenumber = Y
62 # l_trans_type = Y
63 # l_qty = Y
64 # l_oe_id = Y
65 # l_projectnumber = Y
66 # qty_op = dontcare
67
68
69 my @contents = WH->get_warehouse_journal(sort => 'date');
70
71 is $contents[0]{qty}, '1.00000', "produce assembly does not multiply qty (1)";
72 is $contents[1]{qty}, '1.00000', "produce assembly does not multiply qty (2)";
73 is $contents[2]{qty}, '1.00000', "produce assembly does not multiply qty (3)";
74
75 1;