Commit 653ce528 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Change API to pass entire set of transactions in inventory stock

balances
parent 731f402c
# Inventory functions # Inventory functions
# Copyright (C) 2009-2014, AllWorldIT # Copyright (C) 2009-2019, AllWorldIT
# Copyright (C) 2008, LinuxRulz # Copyright (C) 2008, LinuxRulz
# Copyright (C) 2007 Nigel Kukard <nkukard@lbsd.net> # Copyright (C) 2007 Nigel Kukard <nkukard@lbsd.net>
# #
...@@ -1600,6 +1600,7 @@ sub getInventoryStockBalance ...@@ -1600,6 +1600,7 @@ sub getInventoryStockBalance
inventory_tracking.GLTransactionID, inventory_tracking.GLTransactionID,
inventory_tracking.SerialNumber, inventory_tracking.QtyChange, inventory_tracking.Price, inventory_tracking.SerialNumber, inventory_tracking.QtyChange, inventory_tracking.Price,
gl_transactions.TransactionDate AS GLTransactionDate,
gl_transactions.Reference AS GLTransactionReference gl_transactions.Reference AS GLTransactionReference
FROM FROM
...@@ -1624,7 +1625,7 @@ sub getInventoryStockBalance ...@@ -1624,7 +1625,7 @@ sub getInventoryStockBalance
my $stockBalances = {}; my $stockBalances = {};
# Build result list # Build result list
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(), while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
qw( Code GLTransactionID GLTransactionReference SerialNumber QtyChange Price ) qw( Code GLTransactionID GLTransactionDate GLTransactionReference SerialNumber QtyChange Price )
)) { )) {
my $item; my $item;
...@@ -1643,8 +1644,6 @@ sub getInventoryStockBalance ...@@ -1643,8 +1644,6 @@ sub getInventoryStockBalance
$item->{'Quantity'} = Math::BigFloat->new(0); $item->{'Quantity'} = Math::BigFloat->new(0);
$item->{'Quantity'}->precision(-4); $item->{'Quantity'}->precision(-4);
$item->{'Value'} = Math::BigFloat->new(0); $item->{'Value'} = Math::BigFloat->new(0);
$item->{'GLTransactionID'} = [ ];
$item->{'GLTransactionReference'} = [ ];
} }
# Add quantity # Add quantity
...@@ -1652,8 +1651,12 @@ sub getInventoryStockBalance ...@@ -1652,8 +1651,12 @@ sub getInventoryStockBalance
# Add cost # Add cost
$item->{'Value'}->badd($row->{'Price'}); $item->{'Value'}->badd($row->{'Price'});
# Add GL transactions # Add GL transactions
push(@{$item->{'GLTransactionID'}},$row->{'GLTransactionID'}); $item->{'GLTransactions'}->{$row->{'GLTransactionID'}} = {
push(@{$item->{'GLTransactionReference'}},$row->{'GLTransactionReference'}); 'GLTransactionDate' => $row->{'GLTransactionDate'},
'GLTransactionReference' => $row->{'GLTransactionReference'},
'Price' => $row->{'Price'},
'QtyChange' => $row->{'QtyChange'},
};
# Save item # Save item
$stockBalances->{ $row->{'Code'} }->{ $row->{'SerialNumber'} } = $item; $stockBalances->{ $row->{'Code'} }->{ $row->{'SerialNumber'} } = $item;
} }
......
# Reporting functions # Reporting functions
# Copyright (C) 2009-2018, AllWorldIT # Copyright (C) 2009-2019, AllWorldIT
# Copyright (C) 2008, LinuxRulz # Copyright (C) 2008, LinuxRulz
# Copyright (C) 2007 Nigel Kukard <nkukard@lbsd.net> # Copyright (C) 2007 Nigel Kukard <nkukard@lbsd.net>
# #
...@@ -626,8 +626,7 @@ sub sendReport ...@@ -626,8 +626,7 @@ sub sendReport
my $sentry; my $sentry;
$sentry->{'TotalQuantity'} = sprintf('%.4f',$stockItem->{'Quantity'}->bstr()); $sentry->{'TotalQuantity'} = sprintf('%.4f',$stockItem->{'Quantity'}->bstr());
$sentry->{'TotalValue'} = sprintf('%.4f',$stockItem->{'Value'}->bstr()); $sentry->{'TotalValue'} = sprintf('%.4f',$stockItem->{'Value'}->bstr());
$sentry->{'GLTransactionID'} = $stockItem->{'GLTransactionID'}; $sentry->{'GLTransactions'} = $stockItem->{'GLTransactions'};
$sentry->{'GLTransactionReference'} = $stockItem->{'GLTransactionReference'};
$resdata->{'StockItemBalances'}->{$itemCode}->{$itemSerial} = $sentry; $resdata->{'StockItemBalances'}->{$itemCode}->{$itemSerial} = $sentry;
} }
} }
......
Supports Markdown
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