01-20-2020, 12:43 PM,
|
|
daveparrish
Senior Member
|
Posts: 140
Threads: 63
Joined: Mar 2015
|
|
RE: Credit Note Allocations off
(01-18-2020, 08:39 PM)falkoner Wrote: Well I have run my own tests which appear to corroborate what I said, and in the absence of any reaction to my proposed fix I assume nobody disagrees so I have committed this change.
Tim
Thanks
I applied and all worked well.
|
|
01-21-2020, 02:16 PM,
|
|
daveparrish
Senior Member
|
Posts: 140
Threads: 63
Joined: Mar 2015
|
|
RE: Credit Note Allocations off
(01-17-2020, 08:43 AM)falkoner Wrote: It appears from looking at the code that the invoicing script (ConfirmDispatch_Invoice.php) is not rounding the tax figures to the required decimal places, whereas the crediting script (Credit_Invoice.php) is rounding the tax amount on line 542 of the current version. Does this agree with your findings?
If yes, then the answer is to the problem is to insert the lines:
$_SESSION['Items' . $identifier]->total = round($_SESSION['Items' . $identifier]->total, $_SESSION['Items' . $identifier]->CurrDecimalPlaces);
$TaxTotal = round($TaxTotal, $_SESSION['Items' . $identifier]->CurrDecimalPlaces);
at around line 813 of ConfirmDispatch_Invoice.php
It's late and so I haven't had the time to test this but it should work.
Tim
Tim
After updating the script and testing for a couple days I have a issue with rounding, debtortrans alloc is not rounding this happens when I credit an invoice with Credit_Invoice.php it post ovamount and ovgst rounded correctly I think it may be this line '" . -$Allocate_amount . "',
any thoughts.
Thanks
Dave
|
|
01-21-2020, 08:17 PM,
|
|
TimSchofield
Tim Schofield
|
Posts: 1,318
Threads: 22
Joined: Mar 2015
|
|
RE: Credit Note Allocations off
(01-21-2020, 02:16 PM)daveparrish Wrote: Tim
After updating the script and testing for a couple days I have a issue with rounding, debtortrans alloc is not rounding this happens when I credit an invoice with Credit_Invoice.php it post ovamount and ovgst rounded correctly I think it may be this line '" . -$Allocate_amount . "',
any thoughts.
Thanks
Dave
Dave, does this credit note have freight on, or maybe the invoice was partially allocated? Anyway, can you replace the block of code (it starts at line 539 on the latest version) with the following:
PHP Code: /*Do some rounding */
$_SESSION['CreditItems' . $identifier]->FreightCost = round($_SESSION['CreditItems' . $identifier]->FreightCost, $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces); $_SESSION['CreditItems' . $identifier]->total = round($_SESSION['CreditItems' . $identifier]->total, $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces); $TaxTotal = round($TaxTotal, $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces);
$Allocate_amount = 0; $Settled = 0; $SettledInvoice = 0; $MyRow[0] = round($MyRow[0], $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces);); if ($MyRow[0] > 0) { /*the invoice is not already fully allocated */
if ($MyRow[0] > ($_SESSION['CreditItems' . $identifier]->total + $_SESSION['CreditItems' . $identifier]->FreightCost + $TaxTotal)) {
$Allocate_amount = $_SESSION['CreditItems' . $identifier]->total + $_SESSION['CreditItems' . $identifier]->FreightCost + $TaxTotal; $SettledInvoice = 0; $Settled = 1; } else if ($MyRow[0] < ($_SESSION['CreditItems' . $identifier]->total + $_SESSION['CreditItems' . $identifier]->FreightCost + $TaxTotal)) { /*the balance left to allocate is less than the credit note value */ $Allocate_amount = $MyRow[0]; $SettledInvoice = 1; $Settled = 0; } else { $Allocate_amount = $MyRow[0]; $SettledInvoice = 1; $Settled = 1; }
/*Now need to update the invoice DebtorTrans record for the amount to be allocated and if the invoice is now settled*/
$SQL = "UPDATE debtortrans SET alloc = alloc + " . $Allocate_amount . ", settled='" . $SettledInvoice . "' WHERE transno = '" . $_SESSION['ProcessingCredit'] . "' AND type=10";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The alteration to the invoice record to reflect the allocation of the credit note to the invoice could not be done because'); $DbgMsg = _('The following SQL to update the invoice allocation was used'); $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); }
Thanks
Tim[/php]
|
|
01-22-2020, 12:10 AM,
|
|
daveparrish
Senior Member
|
Posts: 140
Threads: 63
Joined: Mar 2015
|
|
RE: Credit Note Allocations off
(01-21-2020, 08:17 PM)falkoner Wrote: (01-21-2020, 02:16 PM)daveparrish Wrote: Tim
After updating the script and testing for a couple days I have a issue with rounding, debtortrans alloc is not rounding this happens when I credit an invoice with Credit_Invoice.php it post ovamount and ovgst rounded correctly I think it may be this line '" . -$Allocate_amount . "',
any thoughts.
Thanks
Dave
Dave, does this credit note have freight on, or maybe the invoice was partially allocated? Anyway, can you replace the block of code (it starts at line 539 on the latest version) with the following:
PHP Code: /*Do some rounding */
$_SESSION['CreditItems' . $identifier]->FreightCost = round($_SESSION['CreditItems' . $identifier]->FreightCost, $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces); $_SESSION['CreditItems' . $identifier]->total = round($_SESSION['CreditItems' . $identifier]->total, $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces); $TaxTotal = round($TaxTotal, $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces);
$Allocate_amount = 0; $Settled = 0; $SettledInvoice = 0; $MyRow[0] = round($MyRow[0], $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces);); if ($MyRow[0] > 0) { /*the invoice is not already fully allocated */
if ($MyRow[0] > ($_SESSION['CreditItems' . $identifier]->total + $_SESSION['CreditItems' . $identifier]->FreightCost + $TaxTotal)) {
$Allocate_amount = $_SESSION['CreditItems' . $identifier]->total + $_SESSION['CreditItems' . $identifier]->FreightCost + $TaxTotal; $SettledInvoice = 0; $Settled = 1; } else if ($MyRow[0] < ($_SESSION['CreditItems' . $identifier]->total + $_SESSION['CreditItems' . $identifier]->FreightCost + $TaxTotal)) { /*the balance left to allocate is less than the credit note value */ $Allocate_amount = $MyRow[0]; $SettledInvoice = 1; $Settled = 0; } else { $Allocate_amount = $MyRow[0]; $SettledInvoice = 1; $Settled = 1; }
/*Now need to update the invoice DebtorTrans record for the amount to be allocated and if the invoice is now settled*/
$SQL = "UPDATE debtortrans SET alloc = alloc + " . $Allocate_amount . ", settled='" . $SettledInvoice . "' WHERE transno = '" . $_SESSION['ProcessingCredit'] . "' AND type=10";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The alteration to the invoice record to reflect the allocation of the credit note to the invoice could not be done because'); $DbgMsg = _('The following SQL to update the invoice allocation was used'); $Result = DB_query($SQL, $ErrMsg, $DbgMsg, true); }
Thanks
Tim[/php] Tim
I dose have freight on it I tried the code and get error 500
Thanks
|
|
01-22-2020, 12:19 AM,
(This post was last modified: 01-22-2020, 12:43 AM by TimSchofield.)
|
|
TimSchofield
Tim Schofield
|
Posts: 1,318
Threads: 22
Joined: Mar 2015
|
|
RE: Credit Note Allocations off
Sorry my bad, the line
PHP Code: $MyRow[0] = round($MyRow[0], $_SESSION['CreditItems' . $identifier]->CurrDecimalPlaces););
has acquired an extra ); on the end. Just remove these.
Apologies,
Tim
|
|
|