Page 1 of 1

Sales line items On Demand issue

PostPosted: Fri Jan 17, 2020 11:28 am
by Riyaz
Hi There

Have a scenario which I'm trying to understand,

Here's an example, we have a PO with just one item ABCD for a quanity of 216, our custom program processes the EDI purchase orders and jiwa automatically allocates a serial number say 1234 for the line item created for ABCD.

This then gets sent to the warehouse, and warehouse provides us back with a confirmation file, which can change the batch serial number of the inventory based on the stock on hand then, or pallet size as the pallet can only hold a certain quantity. At times what happens is that, the warehouse file, will split the quantity into two batches say 144 and 72 (with two diff serial numbers) , our program then updates the SO accordingly.

What happens now, is that when we update the SO, since the quantity is split, we then add the Line Details as accordingly, in this case two line details needs added.

What happens in Jiwa is that, it puts one of the split quantity into OnDemand, pls see attached screenshot. Can you pls advise on how do we rectify this.

Re: Sales line items On Demand issue

PostPosted: Fri Jan 17, 2020 11:47 am
by Mike.Sheen
Riyaz wrote:s that when we update the SO, since the quantity is split, we then add the Line Details as accordingly, in this case two line details needs added.

What happens in Jiwa is that, it puts one of the split quantity into OnDemand


You'll need to show how you're updating the SO / adding the line details.

Also - is the sales order processed and are you working with multiple snapshots?

Re: Sales line items On Demand issue

PostPosted: Fri Jan 17, 2020 11:59 am
by Riyaz
Have attached the code snippet, couldnt put this in the code tag, kept saying 403 error

Re: Sales line items On Demand issue

PostPosted: Fri Jan 17, 2020 4:15 pm
by Mike.Sheen
The 403 error is caused by the 2 occurances of this line in the code:

EmailStockShortage.png
EmailStockShortage.png (2.5 KiB) Viewed 739 times


Not related to your problem, but the forum software for some reason will 403 when that line appears in the post text, even in code block or a quote block.

EDIT: it's the keyword Alert followed by parenthesis which it has the problem which causes the 403 - probably overly cautious about avoiding Javascript embedded in the post.

Re: Sales line items On Demand issue

PostPosted: Fri Jan 17, 2020 4:26 pm
by Riyaz
No worries, thanks for letting me know

Re: Sales line items On Demand issue

PostPosted: Mon Jan 20, 2020 11:31 am
by Riyaz
Pls do let me know if you have any advise on this issue, thanks

Re: Sales line items On Demand issue

PostPosted: Tue Jan 21, 2020 1:15 pm
by Riyaz
Hi There

I think I might know the issue here, here's the scenario again.

Initially when the SO is created, the sales order line has only one line details record. But when we receive the warehouse confirmation, at times the batch number gets split between two batches. Hence we update the SalesOrderlines.LineDetails with each LinkID of the inventory, the first part of the below code does that, after this we use the below code to update the quantity this delivery, second part of the below code does that, here the SalesOrder.SalesOrderLines(i).LineDetails.Count returns 1 instead of 2. Can you pls advise why?

With SalesOrder
For Each SOHRow As DataRow In dsSOH.Tables("IN_SOH").Rows
Dim Quantity As Double = Math.Min(CType(SOHRow("QuantityLeft"), Double), (PickedQty - AllocQty))

If Math.Round(Quantity, 2) > 0 Then

.SalesOrderLines(i).LineDetails(.SalesOrderLines(i).LineDetails.Count).SOHID = SOHRow("LinkID").ToString
.SalesOrderLines(i).LineDetails(.SalesOrderLines(i).LineDetails.Count).DateIn = CType(SOHRow("DateIn"), DateTime)
.SalesOrderLines(i).LineDetails(.SalesOrderLines(i).LineDetails.Count).Cost = CType(SOHRow("LCostIn"), Decimal)
.SalesOrderLines(i).LineDetails(.SalesOrderLines(i).LineDetails.Count).Quantity = CDec(Quantity)
.SalesOrderLines(i).LineDetails(.SalesOrderLines(i).LineDetails.Count).ExpiryDate = CType(SOHRow("ExpiryDate"), DateTime)
.SalesOrderLines(i).LineDetails(.SalesOrderLines(i).LineDetails.Count).SerialNo = SOHRow("SerialNo").ToString
AllocQty += Quantity
.SalesOrderLines(i).Picked = True

If Math.Round(AllocQty, 2) >= Math.Round(PickedQty, 2) Then
Exit For
End If
End If
Next


For i = 1 To .SalesOrderLines.Count
Dim TotalQty As Double = 0

For j = 1 To .SalesOrderLines(i).LineDetails.Count
TotalQty += .SalesOrderLines(i).LineDetails(j).Quantity
Next

.SalesOrderLines(i).QuantityThisDelivery = CDec(TotalQty)
Next

.Save()

End With

Re: Sales line items On Demand issue  Topic is solved

PostPosted: Tue Jan 21, 2020 3:20 pm
by Mike.Sheen
Riyaz wrote:.SalesOrderLines(i).QuantityThisDelivery = CDec(TotalQty)


Don't set the QuantityThisDelivery property if you are setting the line details.

Doing so may cause a FIFO stock allocation, discarding your line details and populating with new ones.

If you want to manually set the Line details, when you're done call the ReAdjustDelivered method of the sales order line afterwards.

Re: Sales line items On Demand issue

PostPosted: Tue Jan 21, 2020 3:25 pm
by Riyaz
Thanks Mike, I'm now trying to zero the current line details and add two new line details, and I think that probably will work. Doing some testing at the moment