Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wrong sales order roll back after a credit note
05-28-2015, 10:03 PM
Post: #2
RE: Wrong sales order roll back after a credit note
This is a known issue if the same item is on the order multiple times. The system doesn't use the line number in the query because the credit/return may not match the same sort order or the same items/quantities. Probably the Update SQL should be changed to query the lines on the order with the same stock item and decrement them one at a time until the total quantity returned for that stock item has been consumed - then break out of the loop.

/* some want this some do not
* We cannot use the orderlineno to update with as it could be different when added to the credit note than it was when the order was created
* Also there could potentially be the same item on the order multiple times with different delivery dates
* So all up the SQL below is a bit hit and miss !!
* Probably right 99% of time with the item on the order only once */

$SQL = "UPDATE salesorderdetails
SET qtyinvoiced = qtyinvoiced - " . $CreditLine->QtyDispatched . ",
completed=0
WHERE orderno = '" . $_SESSION['CreditItems' . $identifier]->OrderNo . "'
AND stkcode = '" . $CreditLine->StockID . "'";
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Wrong sales order roll back after a credit note - agaluski - 05-28-2015 10:03 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)