Commit 756fb957 authored by Nigel Kukard's avatar Nigel Kukard

Merge branch 'nkupdates3' into 'master'

Nkupdates3

See merge request !31
parents de895105 65e02d2c
Pipeline #2574 passed with stages
in 1 minute and 39 seconds
......@@ -242,6 +242,7 @@ sub update
$detail->{'GLAssetAccountNumber'} = $parms->{'assetaccount'};
$detail->{'GLExpenseAccountNumber'} = $parms->{'expenseaccount'};
$detail->{'SellPrice'} = $parms->{'sellprice'};
$detail->{'TaxTypeID'} = $parms->{'taxtype'};
$detail->{'Unit'} = $parms->{'unit'};
$detail->{'Discountable'} = $parms->{'discoutable'};
my $res = soapCall($OUT,"wiaflos/server/api/Inventory","updateInventoryItem",$detail);
......
......@@ -387,7 +387,7 @@ Invoice transactions for: @<<<<<<<<<<<<<<<<<<<
| @||||| | @|||||||||||||||||||||||||||||||||||||||||||||||| | @>>>>>>>>>>> |
+========+===================================================+==============+
END
my $transBalance = Math::BigFloat->new();
my $transBalance = Math::BigFloat->new(0);
my $balance = Math::BigFloat->new($invoice->{'Total'});
# Loop with items
......
......@@ -425,7 +425,7 @@ Invoice transactions for: @<<<<<<<<<<<<<<<<<<<
| @||||| | @|||||||||||||||||||||||||||||||||||||||||||||||| | @>>>>>>>>>>> |
+========+===================================================+==============+
END
my $transBalance = Math::BigFloat->new();
my $transBalance = Math::BigFloat->new(0);
my $balance = Math::BigFloat->new($invoice->{'Total'});
# Loop with items
......
......@@ -311,9 +311,9 @@ sub show
return $res->{'Result'};
}
my $subTotal = Math::BigFloat->new();
my $taxTotal = Math::BigFloat->new();
my $invTotal = Math::BigFloat->new();
my $subTotal = Math::BigFloat->new(0);
my $taxTotal = Math::BigFloat->new(0);
my $invTotal = Math::BigFloat->new(0);
$res = soapCall($OUT,"wiaflos/server/api/SupplierCreditNotes","getSupplierCreditNoteItems",$detail);
if ($res->{'Result'} == RES_OK) {
print swrite(<<'END', "ID", "Description", "Invt/Exp", "Unit", "Qty", "UnitPrice", "Price", "TaxAmount", "Total");
......@@ -381,7 +381,7 @@ Credit note transactions for: @<<<<<<<<<<<<<<<<<<<
| @||||| | @|||||||||||||||||||||||||||||||||||||||||||||||| | @>>>>>>>>>>> |
+========+===================================================+==============+
END
my $transBalance = Math::BigFloat->new();
my $transBalance = Math::BigFloat->new(0);
my $balance = Math::BigFloat->new($invoice->{'Total'});
# Loop with items
......
......@@ -921,7 +921,7 @@ sub linkGLTransaction
}
# Pull in amount
my $cleanAmount = Math::BigFloat->new();
my $cleanAmount = Math::BigFloat->new(0);
$cleanAmount->precision(-2);
# Lets see what we going to pull in...
......@@ -1056,7 +1056,7 @@ sub postGLTransaction
}
# Fetch rows
my $balance = Math::BigFloat->new();
my $balance = Math::BigFloat->new(0);
$balance->precision(-2);
my $count = 0;
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(), qw( ID Amount ))) {
......@@ -1295,7 +1295,7 @@ sub getGLAccountEntries
}
# Generate balance brought forward amount
my $bbfAmount = Math::BigFloat->new();
my $bbfAmount = Math::BigFloat->new(0);
$bbfAmount->precision(-2);
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),qw( Amount Type ))) {
# Check filter, if this is not one of our items, continue
......@@ -1466,9 +1466,9 @@ sub getGLAccountBalance
}
# These are our balances
my $balance = Math::BigFloat->new();
my $creditBalance = Math::BigFloat->new();
my $debitBalance = Math::BigFloat->new();
my $balance = Math::BigFloat->new(0);
my $creditBalance = Math::BigFloat->new(0);
my $debitBalance = Math::BigFloat->new(0);
$balance->precision(-2);
$creditBalance->precision(-2);
$debitBalance->precision(-2);
......
......@@ -287,12 +287,12 @@ sub getInventoryStockList
# Look for free inventory items
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),qw( ID QtyChange Price ))) {
# Total stock quantity
$stockList{$row->{'ID'}}{'TotalQuantity'} = Math::BigFloat->new();
$stockList{$row->{'ID'}}{'TotalQuantity'} = Math::BigFloat->new(0);
$stockList{$row->{'ID'}}{'TotalQuantity'}->precision(-4);
$stockList{$row->{'ID'}}{'TotalQuantity'}->badd($row->{'QtyChange'});
# Total quantity value
$stockList{$row->{'ID'}}{'TotalValue'} = Math::BigFloat->new();
$stockList{$row->{'ID'}}{'TotalValue'} = Math::BigFloat->new(0);
$stockList{$row->{'ID'}}{'TotalValue'}->badd($row->{'Price'});
# This is adjusted below if we have any allocations
......@@ -355,12 +355,12 @@ sub getInventoryStockList
# Loop and add up
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),qw( ID QtyChange Price ))) {
# Current stock quantity
$stockList{'0'}{'CurrentQuantity'} = Math::BigFloat->new();
$stockList{'0'}{'CurrentQuantity'} = Math::BigFloat->new(0);
$stockList{'0'}{'CurrentQuantity'}->precision(-4);
$stockList{'0'}{'CurrentQuantity'}->badd($row->{'QtyChange'});
# Current quantity value
$stockList{'0'}{'CurrentValue'} = Math::BigFloat->new();
$stockList{'0'}{'CurrentValue'} = Math::BigFloat->new(0);
$stockList{'0'}{'CurrentValue'}->badd($row->{'Price'});
}
DBFreeRes($sth);
......@@ -453,7 +453,7 @@ sub adjustInventoryStock
}
# Pull in with math library
my $qtyChange = Math::BigFloat->new();
my $qtyChange = Math::BigFloat->new(0);
$qtyChange->precision(-4);
$qtyChange->badd($detail->{'QtyChange'});
......@@ -565,7 +565,7 @@ sub adjustInventoryStock
my $inventoryTrackingID = $stockAdjustItem->{'InventoryTrackingID'};
# Pull in stock adjustment quantity
my $stockAdjustQuantity = Math::BigFloat->new();
my $stockAdjustQuantity = Math::BigFloat->new(0);
$stockAdjustQuantity->precision(-4);
$stockAdjustQuantity->badd($stockAdjustItem->{'Quantity'});
......@@ -700,7 +700,7 @@ sub getInventoryStockItem
if ($inventoryItem->{'Type'} eq "product") { # Product
# This is the quantity we need
my $quantity = Math::BigFloat->new();
my $quantity = Math::BigFloat->new(0);
$quantity->precision(-4);
$quantity->badd($detail->{'Quantity'});
......@@ -1209,6 +1209,7 @@ sub removeInventoryItem
# GLAssetAccountNumber - GL asset account
# GLExpenseAccountNumber - GL expense account
# SellPrice - Selling price
# TaxTypeID - Tax type ID
# Unit - Unit
# Discountable - Either service is discountable or not
sub updateInventoryItem
......@@ -1295,6 +1296,23 @@ sub updateInventoryItem
if (defined($data->{'SellPrice'})) {
push(@updates,sprintf('SellPrice = %s',DBQuote($data->{'SellPrice'})));
}
# Check if TaxTypeID was specified
if (defined($data->{'TaxTypeID'})) {
# Check if tax type exists
if ((my $res = wiaflos::server::core::Tax::taxTypeIDExists($data->{'TaxTypeID'})) != 1) {
# If not exist, err
if ($res == 0) {
setError("Tax type '".$data->{'TaxTypeId'}."' does not exist");
return ERR_NOTFOUND;
}
# else err with result & set error
setError(wiaflos::server::core::Tax::Error());
return $res;
}
push(@updates,sprintf('TaxTypeID = %s',DBQuote($data->{'TaxTypeID'})));
}
if (defined($data->{'Unit'})) {
push(@updates,sprintf('Unit = %s',DBQuote($data->{'Unit'})));
}
......@@ -1379,7 +1397,7 @@ sub linkInventoryItemToExpenseAccount
}
# Pull quantity as we do math below, else we wouldn't need to
my $quantity = Math::BigFloat->new();
my $quantity = Math::BigFloat->new(0);
$quantity->precision(-4);
$quantity->badd( defined($detail->{'Quantity'}) ? $detail->{'Quantity'} : 1 ); # Default to 1 item
......@@ -1441,7 +1459,7 @@ sub linkInventoryItemToExpenseAccount
}
# Work out cost price & stock list we require for adjustment
my $costPrice = Math::BigFloat->new();
my $costPrice = Math::BigFloat->new(0);
my @stockAdjustmentList;
# Check if this is a tracked item, if so add up all the stock we need
foreach my $stockItem (@{$inventoryItem->{'StockRequired'}}) {
......@@ -1620,9 +1638,9 @@ sub getInventoryStockBalance
# If no item defined, create one
if (!defined($item)) {
$item->{'Quantity'} = Math::BigFloat->new();
$item->{'Quantity'} = Math::BigFloat->new(0);
$item->{'Quantity'}->precision(-4);
$item->{'Value'} = Math::BigFloat->new();
$item->{'Value'} = Math::BigFloat->new(0);
}
# Add quantity
......
......@@ -605,7 +605,7 @@ sub linkInvoiceItem
}
# Get quantity. NOTE: We do this soo high up so we can get the stock item below.
my $quantity = Math::BigFloat->new();
my $quantity = Math::BigFloat->new(0);
$quantity->precision(-4);
if (defined($detail->{'Quantity'})) {
$quantity->badd($detail->{'Quantity'});
......@@ -625,7 +625,7 @@ sub linkInvoiceItem
}
# Check discountability
my $discount = Math::BigFloat->new();
my $discount = Math::BigFloat->new(0);
if (defined($detail->{'Discount'})) {
$discount->badd($detail->{'Discount'});
if ($inventoryItem->{'Discountable'} eq 'no' && !$discount->is_zero()) {
......@@ -668,7 +668,7 @@ sub linkInvoiceItem
my $taxRate = Math::BigFloat->new($taxType->{'TaxRate'});
# Get price
my $sellPrice = Math::BigFloat->new();
my $sellPrice = Math::BigFloat->new(0);
if (defined($detail->{'UnitPrice'})) {
$sellPrice->badd($detail->{'UnitPrice'});
} else {
......@@ -689,7 +689,7 @@ sub linkInvoiceItem
# Calculate discount
if (!$discount->is_zero()) {
# Set totalprice
my $discountAmount = Math::BigFloat->new();
my $discountAmount = Math::BigFloat->new(0);
$discountAmount->precision(-4);
$discountAmount->badd($totalPrice);
......@@ -838,9 +838,9 @@ sub postInvoice
my %stockEntries;
my %expEntries;
my %incEntries;
my $discTotal = Math::BigFloat->new();
my $subTotal = Math::BigFloat->new();
my $invTotal = Math::BigFloat->new();
my $discTotal = Math::BigFloat->new(0);
my $subTotal = Math::BigFloat->new(0);
my $invTotal = Math::BigFloat->new(0);
# Fetch rows
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
......@@ -848,7 +848,7 @@ sub postInvoice
TaxGLAccountID )
)) {
# Pull quantity as we do math below, else we wouldn't need to
my $quantity = Math::BigFloat->new();
my $quantity = Math::BigFloat->new(0);
$quantity->precision(-4);
$quantity->badd($row->{'Quantity'});
......@@ -879,7 +879,7 @@ sub postInvoice
}
# Work out cost price & stock list we require for adjustment
my $costPrice = Math::BigFloat->new();
my $costPrice = Math::BigFloat->new(0);
my @stockAdjustmentList;
# Check if this is a tracked item, if so add up all the stock we need
foreach my $stockItem (@{$inventoryItem->{'StockRequired'}}) {
......
......@@ -703,7 +703,7 @@ sub linkSupplierInvoiceItem
}
# Pull discount
my $discount = Math::BigFloat->new();
my $discount = Math::BigFloat->new(0);
if (defined($detail->{'Discount'})) {
$discount->badd($detail->{'Discount'});
}
......@@ -730,7 +730,7 @@ sub linkSupplierInvoiceItem
}
# Get quantity
my $quantity = Math::BigFloat->new();
my $quantity = Math::BigFloat->new(0);
$quantity->precision(-4);
if (defined($detail->{'Quantity'})) {
$quantity->badd($detail->{'Quantity'});
......@@ -899,9 +899,9 @@ sub postSupplierInvoice
my %taxEntries;
my %stockEntries;
my %expEntries;
my $invTotal = Math::BigFloat->new();
my $subTotal = Math::BigFloat->new();
my $discountTotal = Math::BigFloat->new();
my $invTotal = Math::BigFloat->new(0);
my $subTotal = Math::BigFloat->new(0);
my $discountTotal = Math::BigFloat->new(0);
# Fetch rows
while (my $row = hashifyLCtoMC($sth->fetchrow_hashref(),
......@@ -909,7 +909,7 @@ sub postSupplierInvoice
TaxTypeID TaxMode TaxAmount TaxGLAccountID )
)) {
# Pull quantity as we do math below, else we wouldn't need to
my $quantity = Math::BigFloat->new();
my $quantity = Math::BigFloat->new(0);
$quantity->precision(-4);
$quantity->badd($row->{'Quantity'});
......
......@@ -159,10 +159,10 @@ sub getAccountBalances
my ($paccount,$search) = @_;
# This is our final balances
my $creditBalance = Math::BigFloat->new();
my $openingCreditBalance = Math::BigFloat->new();
my $debitBalance = Math::BigFloat->new();
my $openingDebitBalance = Math::BigFloat->new();
my $creditBalance = Math::BigFloat->new(0);
my $openingCreditBalance = Math::BigFloat->new(0);
my $debitBalance = Math::BigFloat->new(0);
my $openingDebitBalance = Math::BigFloat->new(0);
$creditBalance->precision(-2);
$openingCreditBalance->precision(-2);
$debitBalance->precision(-2);
......@@ -336,7 +336,7 @@ sub sendReport
}
# Check balance
my $balance = Math::BigFloat->new();
my $balance = Math::BigFloat->new(0);
$balance->precision(-2);
$balance->badd($account->{'Balance'});
# Check if its negative or positive
......@@ -547,7 +547,7 @@ sub sendReport
@{$res} = sort { $a->{'TransactionDate'} cmp $b->{'TransactionDate'} } @{$res};
# Work out closing balance
my $closingBalance = Math::BigFloat->new();
my $closingBalance = Math::BigFloat->new(0);
$closingBalance->precision(-2);
# Fetch items
......@@ -598,16 +598,16 @@ sub sendReport
}
# Work out closing balance
my $totalValue = Math::BigFloat->new();
my $totalValue = Math::BigFloat->new(0);
$totalValue->precision(-2);
# Loop with stock codes
foreach my $itemCode (keys %{$res}) {
my $entry;
$entry->{'TotalQuantity'} = Math::BigFloat->new();
$entry->{'TotalQuantity'} = Math::BigFloat->new(0);
$entry->{'TotalQuantity'}->precision(-4);
$entry->{'TotalValue'} = Math::BigFloat->new();
$entry->{'TotalValue'} = Math::BigFloat->new(0);
# Loop with stock items
foreach my $itemSerial (keys %{$res->{$itemCode}}) {
......
......@@ -243,7 +243,7 @@ sub sendStatement
};
# Tally up a running balance
my $runningBalance = Math::BigFloat->new();
my $runningBalance = Math::BigFloat->new(0);
$runningBalance->precision(-2);
# Load invoice line items
......@@ -264,7 +264,7 @@ sub sendStatement
}
# Get statement balance
my $statementBalance = Math::BigFloat->new();
my $statementBalance = Math::BigFloat->new(0);
$statementBalance->precision(-2);
foreach my $item (@{$entries}) {
$statementBalance->badd($item->{'Amount'});
......
......@@ -575,7 +575,7 @@ sub linkSupplierCreditNoteItem
}
# Get quantity
my $quantity = Math::BigFloat->new();
my $quantity = Math::BigFloat->new(0);
$quantity->precision(-4);
if (defined($detail->{'Quantity'})) {
$quantity->badd($detail->{'Quantity'});
......@@ -760,8 +760,8 @@ sub postSupplierCreditNote
my %GLOrigExpenseAdjustEntries;
my %GLAssetAdjustEntries;
my %GLExpenseAdjustEntries;
my $crnTotal = Math::BigFloat->new();
my $subTotal = Math::BigFloat->new();
my $crnTotal = Math::BigFloat->new(0);
my $subTotal = Math::BigFloat->new(0);
DBBegin();
......@@ -809,7 +809,7 @@ sub postSupplierCreditNote
#
# Get details from credit note
#
my $crnQuantity = Math::BigFloat->new();
my $crnQuantity = Math::BigFloat->new(0);
$crnQuantity->precision(-4);
$crnQuantity->badd($crnItem->{'Quantity'});
......@@ -931,9 +931,9 @@ sub postSupplierCreditNote
}
# Setup balance...
my $itemQtyBalance = Math::BigFloat->new();
my $itemQtyBalance = Math::BigFloat->new(0);
$itemQtyBalance->precision(-4);
my $itemPriceBalance = Math::BigFloat->new();
my $itemPriceBalance = Math::BigFloat->new(0);
# Tracked item balances
my @inventoryTracking;
# Loop with inventory item movement
......@@ -944,9 +944,9 @@ sub postSupplierCreditNote
# Check if we have inventory item tracking information
if (defined($item->{'InventoryTrackingID'})) {
# This will only be set for an inventory item
my $trackingQtyBalance = Math::BigFloat->new();
my $trackingQtyBalance = Math::BigFloat->new(0);
$trackingQtyBalance->precision(-4);
my $trackingPriceBalance = Math::BigFloat->new();
my $trackingPriceBalance = Math::BigFloat->new(0);
# Build request
$data = undef;
$data->{'ID'} = $item->{'InventoryTrackingID'};
......
......@@ -105,7 +105,7 @@ sub performYearEnd
$search->{'EndDate'} = $detail->{'EndDate'};
# Transaction balance
my $transActBalance = Math::BigFloat->new();
my $transActBalance = Math::BigFloat->new(0);
$transActBalance->precision(-2);
# Pick out expense accounts and generate transaction list
......
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