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, 04:58 AM
Post: #1
Wrong sales order roll back after a credit note
Hi all,
I had to credit a delivery made, but in the related Sales Order every row of the item credited have been decremented of the quantity credited.

In details, I've generated a credit note for 3 pcs of an item against a Sales Order.The SO has the same item due in different dates and different qty, some delivered, some partially delivered and some to be delivered.
After the credit note, every row with that item (completed or not) have been decremented by 3 pcs.
A completed row of 34 pcs becomes 31, a completed row of 20 pcs becomes 17, a partially delivered row of 9 of 15 becomes 6 of 15 and an full outstanding row of 3 pcs becomes -3 (see image below).

Giusba

   
Find all posts by this user
Quote this message in a reply
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 


Forum Jump:


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