Receiving backorders

Hi,

In an inteface between ERP software and Quantify the goal is to be able to passthrough partial receipts on a purchase order -> generating a backorder and then receive the remaining amounts (or another partial receipts, and so on). E.g.

Purchase order 100 goods
Receipt of 50 goods -> generating backorder of remaining 50 goods
Receipt of 20 goods -> generating backorder of remaing 30 goods

The problem I’m facing is that for my ERP software the order I’m receiving on remains the same (backorder lines are added tot the original order) and Quantify generates separate backorders (with the addition of .01 or .02 in the ordernumber). I don’t know how to match the receipt based on the ordernumber (e.g. 100) with the outstanding backorder (e.g. 100.03).

Additionally, when I’m changing quantities in my purchase order the Quantify UI has the possibility to change the amounts in the original purchase order, how am I supposed to do this using the API?

Thanks for the help in advance :slight_smile:

Hello Bernice. The trick is to get the last order in the sequence. This may involve writing a little algorithm. If it’s the first backorder then you’ll fetch the original order, then save it. This will create a .01 order, which you’ll then fetch again to place another back order against. In the code below we simply use the “.01” because we know there’s only two, but you could try and fetch each of these to see if they exist (check the number after fetching, if it exists the number will be the same).

    Dim orderID As Guid = Guid.NewGuid()
    ' You'll use or fetch your customer and branch ID's here.
    Dim businessPartnerID As Guid = New Guid("{07001CE8-CE22-47AA-A896-E60042723EB9}")
    Dim branchID As Guid = New Guid("{DA38E3FF-59D6-4F2B-898E-A68506C92F1F}")

    'New product - just as an example, you can use your own part number here.
    Dim partNumber As String = "PROD-P-222"
    Dim prod As Product = Product.NewProduct(ProductType.Product)
    prod.PartNumber = partNumber
    prod.Description = "Test Product"
    prod.Weight = 0.5
    prod.Save()

    'Create Order
    Dim transactionNumber As String = "MOV-M-222"
    Dim order As Movement = Movement.NewMovement(MovementType.Ordered, True)
    order.MovementID = orderID
    order.MovementNumber = transactionNumber
    order.TypeOfMovement = MovementType.Ordered
    order.OrderLoadType = MovementOrderLoadType.New
    order.BackOrderNumber = "ORD0001113"
    order.BusinessPartnerID = businessPartnerID
    order.DestinationID = branchID
    order.DestinationType = PartnerTypes.BranchOffice
    order.MovementProducts.First(Function(o) o.PartNumber = partNumber).Quantity = 100
    order.Save()

    'Receive Order
    order = Movement.GetMovementForReceiving(orderID, MovementGetAction.ForEdit, True)
    order.SetMovementOrderReceiveType(MovementType.Ordered)
    order.OrderLoadType = MovementOrderLoadType.ForReceiving
    order.DestinationType = PartnerTypes.BranchOffice
    order.BusinessPartnerID = businessPartnerID
    order.DestinationID = branchID
    order.MovementProducts.First(Function(o) o.PartNumber = partNumber).Quantity = 100
    order.MovementProducts.First(Function(o) o.PartNumber = partNumber).ReceivedQuantity = 50
    order.Save()


    'Receive Order
    Dim mov As Movement = Movement.GetMovement(transactionNumber + ".01", MovementGetAction.None, False)
    order = Movement.GetMovementForReceiving(mov.MovementID, MovementGetAction.ForEdit, True)
    order.SetMovementOrderReceiveType(MovementType.BackOrdered)
    order.OrderLoadType = MovementOrderLoadType.ForReceiving
    order.DestinationType = PartnerTypes.BranchOffice
    order.BusinessPartnerID = businessPartnerID
    order.DestinationID = branchID
    order.MovementProducts.First(Function(o) o.PartNumber = partNumber).Quantity = 50
    order.MovementProducts.First(Function(o) o.PartNumber = partNumber).ReceivedQuantity = 50
    order.Save()

Hi,

I would like to get back to this issue since I finally got the time to work on this.
When I use the:
Movement = Movement.GetMovement(I can only provide a guid here).
How should I get the movement based on the MovementNumber?

I’m not sure we can provide an overload for the number as there are cases where it isn’t unique. To get the Guid, you can load the list, then traverse it. Once you find the number you need, you can grab the Guid from there. Hope this helps.

Would you maybe be so kind as to provide example code on how to do this :)?

To get MovementID from MovementList

MovementList.GetMovementList(<Branch-TradingPartner-ID>, MovementType.All, false, Guid.Empty).FirstOrDefault(transaction=>transaction.Number=="MOV-XXXXX").MovementID

To get Branch-TradingPartner-ID from TradingPartner

TradingPartner.GetTradingPartner("BranchName").TradingPartnerID