Commit b922d651 authored by Nigel Kukard's avatar Nigel Kukard

Change API to pass entire set of transactions in inventory stock

balances
parent 0ef6384e
# Inventory functions
# Copyright (C) 2009-2014, AllWorldIT
# Copyright (C) 2009-2019, AllWorldIT
# Copyright (C) 2008, LinuxRulz
# Copyright (C) 2007 Nigel Kukard <nkukard@lbsd.net>
#
......@@ -1600,6 +1600,7 @@ sub getInventoryStockBalance
inventory_tracking.GLTransactionID,
inventory_tracking.SerialNumber, inventory_tracking.QtyChange, inventory_tracking.Price,
gl_transactions.TransactionDate AS GLTransactionDate,
gl_transactions.Reference AS GLTransactionReference
FROM
......@@ -1624,7 +1625,7 @@ sub getInventoryStockBalance
my $stockBalances = {};
# Build result list
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
qw( Code GLTransactionID GLTransactionReference SerialNumber QtyChange Price )
qw( Code GLTransactionID GLTransactionDate GLTransactionReference SerialNumber QtyChange Price )
)) {
my $item;
......@@ -1643,8 +1644,6 @@ sub getInventoryStockBalance
$item->{'Quantity'} = Math::BigFloat->new(0);
$item->{'Quantity'}->precision(-4);
$item->{'Value'} = Math::BigFloat->new(0);
$item->{'GLTransactionID'} = [ ];
$item->{'GLTransactionReference'} = [ ];
}
# Add quantity
......@@ -1652,8 +1651,12 @@ sub getInventoryStockBalance
# Add cost
$item->{'Value'}->badd($row->{'Price'});
# Add GL transactions
push(@{$item->{'GLTransactionID'}},$row->{'GLTransactionID'});
push(@{$item->{'GLTransactionReference'}},$row->{'GLTransactionReference'});
$item->{'GLTransactions'}->{$row->{'GLTransactionID'}} = {
'GLTransactionDate' => $row->{'GLTransactionDate'},
'GLTransactionReference' => $row->{'GLTransactionReference'},
'Price' => $row->{'Price'},
'QtyChange' => $row->{'QtyChange'},
};
# Save item
$stockBalances->{ $row->{'Code'} }->{ $row->{'SerialNumber'} } = $item;
}
......
# Reporting functions
# Copyright (C) 2009-2018, AllWorldIT
# Copyright (C) 2009-2019, AllWorldIT
# Copyright (C) 2008, LinuxRulz
# Copyright (C) 2007 Nigel Kukard <nkukard@lbsd.net>
#
......@@ -626,8 +626,7 @@ sub sendReport
my $sentry;
$sentry->{'TotalQuantity'} = sprintf('%.4f',$stockItem->{'Quantity'}->bstr());
$sentry->{'TotalValue'} = sprintf('%.4f',$stockItem->{'Value'}->bstr());
$sentry->{'GLTransactionID'} = $stockItem->{'GLTransactionID'};
$sentry->{'GLTransactionReference'} = $stockItem->{'GLTransactionReference'};
$sentry->{'GLTransactions'} = $stockItem->{'GLTransactions'};
$resdata->{'StockItemBalances'}->{$itemCode}->{$itemSerial} = $sentry;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment