Help - Using the Web API to generate prepaid orders?

SUGGESTED

Hello,

We have transactions that our customers have paid for using a credit card. We'd like to get those processed transactions brought in to Sage as an order that has a prepayment applied to it, so that the invoice that is automatically generated shows an amount due of zero dollars.

So, from what I currently know, we need to do the following for this type of transaction:

  1. Create a new A/R Receipt Batch by calling ARReceiptAndAdjustmentBatches.
  2. Create a prepayment by calling ARPostReceiptsAndAdjustments, and reference the A/R Receipt Batch to add it to the batch.
  3. Create an OEOrders and reference the prepayment in the details.

So, I guess I have a few questions:

  1. I'm unsure if the workflow that I've described above adequately solves what we are trying to accomplish. If I could get feedback on whether the workflow above describes the steps that are necessary to commit a credit card transaction into a prepaid Sage order, that would be great.
  2. Models in the Web API have hundreds of properties, and I'm not sure which ones need to be set in order to build what we are trying to create. If there is documentation somewhere where could understand these properties and you could share those details, or if you could clarify which properties are important for the steps I've outlined above, that would be a huge help.

Thanks,

Craig

Parents
  • 0

    Here is our current attempt while trying a POST OEOrder:

    {
    "CustomerNumber": "51300",
    "PurchaseOrderNumber": "PO00001",
    "OrderReference": "xyz1",
    "ShipToLocationCode": "99999",
    "OrderDetails": [
    {
    "LineType": "Item",
    "Item": "EMPLVFWSCSE01ELR",
    "QuantityOrdered": 1,
    "QuantityShipped": 1
    }
    ],
    "PaymentType": "CreditCard",
    "PaymentTypeOnOrder": "CreditCard",
    "OrderTotal": 144.00,
    "InvoiceNumberOfPrepayments": 1,
    "TermsCode": "PPD",
    "PostInvoice": true,
    "ReceiptBatchNumber": 5838,
    "ReceiptType": "Prepayment",
    "CheckDate": "2020-10-08",
    "CheckFiscalYear": "2020",
    "CheckFiscalPeriod": "Num10",
    "CheckNumber": "TEST123",
    "PaymentAppliedTo": "OrderNumber",
    "OEPendingTransactionIncluded": true,
    "PaymentInCustomerCurrency": 144.00
    }

  • 0 in reply to Craig Wallace
    SUGGESTED

    Hey, our Web API specialist is off for a couple of days, but here is some preliminary info:

    With the current flow, this may not be possible.  If user manually enters the order, they can do a Prepayment from Order Entry, making the invoice generated show an amount due of $0.

    However, Order Entry webapi (same with import) does not have this for prepayment.  And if user uses the webapi to create a prepayment in AR Receipt Entry, it will not “see” the OE Order yet because that order has not been invoiced/DEP’ed yet. 

    They will look to see if there is any other option, but it does not look possible at this point with the current flow.

  • 0 in reply to John Thomas

    Hi John, 

    Thanks for the response.

    We remain completely flexible on the order of the workflow if you or the Web API specialist have some ideas that would get us to the finish line, so if either of you could weigh in further we'd be very grateful. For example, if first we need to generate a posted order and invoice and then apply a prepayment second, we are open to that as a solution.

    Also, thanks for your helpful blog! It's come in handy for our team.

    Craig

  • 0 in reply to Craig Wallace

    Hey Craig,

    See the response from our specialist:

    Regarding prepayment to orders, you are correct that it cannot be done using WEBAPI. Reason is prepayment on order requires complex logic that’s closely associated with receipt creation, so it’s very difficult to be integrated into the OE Order endpoint.

     The workaround will be ALMOST like what Craig described:

    1. Create an OEOrders
    2. Create a prepayment by calling ARPostReceiptsAndAdjustments, and apply it to the order. This can be achieved by setting “Apply By” to “Order Number” and “Apply To” to the order number created. Post the prepayment.

    Note that OE order must be created first before the prepayment, such that the order number can be specified on the prepayment. Later on, the prepayment will be automatically applied to any OE invoice created from this order and posted in AR.

    I hope this helps!!

  • 0 in reply to John Thomas

    This is hugely helpful. I'll give this a shot and report back. Thanks so much John, and mystery specialist! Smiley

  • 0 in reply to Craig Wallace
    SUGGESTED

    Hey Craig,

    I passed on your thanks to our specialist and they passed along the two payload files used for testing (against our SAMLTD sample database). They are here below:

    OEOrders:

    {
    "OrderNumber": "ORD103",
    "CustomerNumber": "1400",
    "OrderDescription": "Order Entry",
    "OrderDate": "2020-01-15",
    "OrderDetails": [
    {
    "LineType": "Item",
    "Item": "A1-105/0",
    "Location": "1",
    "QuantityOrdered": 8
    }
    ]
    }

    ARReceiptAndAdjustmentBatches (Prepayment):

    {
    "BatchRecordType": "CA",
    "BatchNumber": 146,
    "BatchDate": "2020-01-05",
    "Description": "prepay",
    "NumberOfEntries": 1,
    "BankCode": "CCB",
    "DefaultBankCurrency": "CAD",
    "ReceiptsAdjustments": [
    {
    "BatchType": "CA",
    "BatchNumber": 146,
    "EntryNumber": 1,
    "CustomerNumber": "1400",
    "ReceiptDateAdjustmentDate": "2020-01-05",
    "EntryDescription": "1",
    "EntryReference": "",
    "BankReceiptAmount": 67.8,
    "CustomerReceiptAmount": 67.8,
    "TotalCustomerAmountApplied": 67.8,
    "ReceiptTransactionType": "Prepayment",
    "DocumentType": "OrderNumber",
    "MatchingDocumentNumber": "ORD103",
    "CustomerUnappliedAmount": 0,
    "AppliedReceiptsAdjustments": [
    {
    "BatchType": "CA",
    "BatchNumber": 146,
    "EntryNumber": 1,
    "LineNumber": 20,
    "CustomerNumber": "1400",
    "PaymentNumber": 1,
    "CustomerReceiptAmount": 67.8
    }
    ]
    }
    ]
    }

    I hope this helps.

  • 0 in reply to John Thomas

    Thanks John. We attempted to create an order through OE and a prepayment through AR, and as the specialist mentioned, it doesn't seem like the two are seeing each other: I can create the order and I can create the prepayment but I can't apply the prepayment to the order (I also can't apply it to the invoice). Could you confirm if there is no clear way to intake an order and apply a prepayment to it? If we can be assured that this development path isn't going to work, then we will pivot to using the COM Layer instead.

    So I guess I have a few questions:

    1. At what stage does an OE Prepayment need to be applied to an order: before or after it is posted? Can this be done with the Web API?
    2. At what stage does an AR Prepayment need to be applied to an order: before or after it is posted? Can this be done with the Web API?
    3. Can a prepayment be applied to an invoice? Obviously the invoice needs to be generated before we attempt to apply a prepayment to it, so the order needs to be posted before an invoice is generated so that we can apply the prepayment to it, but at that stage it seems like you can't modify the invoice to be prepaid because it's already posted. What's going on here?
    4. When applying a prepayment to an order, if the order needs to have the prepayment applied to it before the order is posted, can the order be left as unposted and then updated with the prepayment details and then posted once it's all mapped up? Can all this occur through the Web API? If so, can it be accomplished through OE or AR calls? Is there a workflow for this if this is possible?
    5. Should we give up and attempt this workflow through the COM API instead?

    Here's an example of what we tried. We also tried posting where the DocumentType is equal to "OrderNumber" and providing the order number in the MatchingDocumentNumber field. The example below is an example where we were trying to apply the prepayment to the order's generated invoice, but keep in mind that we've tried many of the combinations listed above and are looking for feedback on the entire process.

    This is the POST ARReceiptAndAdjustmentBatch:

    {
    "BatchRecordType": "CA",
    "BatchDate": "2020-10-19",
    "Description": "Test Batch 2020-10-19",
    "NumberOfEntries": 1,
    "BatchType": "Entered",
    "BatchStatus": "Open",
    "BankCode": "CUCO",
    "DefaultBankCurrency": "CAD",
    "ReceiptsAdjustments": [
    {
    "BatchType": "CA",
    "EntryNumber": 1,
    "CheckReceiptNumber": "PayPal Reference",
    "CustomerNumber": "51300",
    "ReceiptDateAdjustmentDate": "2020-10-19",
    "EntryDescription": "Entry Description",
    "EntryReference": "Entry Reference",
    "BankReceiptAmount": 144.00,
    "CustomerReceiptAmount": 144.00,
    "TotalCustomerAmountApplied": 144.00,
    "PaymentCode": "CC",
    "ReceiptTransactionType": "Prepayment",
    "DocumentType": "DocumentNumber",
    "MatchingDocumentNumber": "IN00000389",
    "FiscalYear": "2020",
    "FiscalPeriod": "10",
    "PaymentType": "CreditCard",
    "PostingDate": "2020-10-19",
    "AccountSet": "DFLT",
    "AppliedReceiptsAdjustments": [
    {
    "BatchType": "CA",
    "EntryNumber": 1,
    "LineNumber": 1,
    "CustomerNumber": "51300",
    "PaymentNumber": 1,
    "TransactionType": "PrepaymentPosted",
    "CustomerReceiptAmount": 144.00,
    "PPMatchingDocumentNumber": "IN00000389",
    "PPMatchingDocumentType": "DocumentNumber",
    "ReceiptTransactionType": "Prepayment"
    }
    ]
    }
    ]
    }

    This is the POST OEOrder:

    {
    "CustomerNumber": "51300",
    "ShipToLocationCode": "99999",
    "PurchaseOrderNumber": "PO00002",
    "OrderReference": "xyz1",
    "OrderDetails": [
    {
    "LineType": "Item",
    "Item": "EMPLVFWSCSE01ELR",
    "Location": "CUIC",
    "QuantityOrdered": 1,
    "QuantityShipped": 1
    }
    ]
    }

  • 0 in reply to John Thomas

    Come to think of it, most of those questions were answered by the specialist. So from what I gather from what the specialist is saying, the workflow looks like this:

    1. Create an unposted order with OEOrders.
    2. Create an A/R batch with ARReceiptAndAdjustmentBatches that includes a prepayment, and in the details for that prepayment, reference the order number as mentioned above.
    3. Post the order that was generated in step one.
    4. Post the A/R batch.

    I have a few questions related to this:

    1. Is this the correct workflow? If not, could you please correct it?
    2. How can I post an unposted OEOrder programmatically through the Web API after it has been created as an unposted order? Is there a way to update the OEOrder in order to post it after the fact? If so, what properties do we need to set to do so?
    3. What needs to happen first: does the order need to be posted first, and then the A/R batch is posted second, or is it the other way around?

    Thanks so much for your patience while I try to work this out.

  • 0 in reply to John Thomas

    Could you please provide an example of how to apply the payment to the Invoice?
    I tried to use "DocumentType""Invoice", but API returns the following error:

    {
    "error": {
    "code": "InvalidPayload",
    "message": {
    "lang": "en-US",
    "value": "The payload is invalid for this resource.Requested value 'Invoice Note' was not found."
    }
    }
    }

    Also, could you provide an example of API for the ARPostReceiptsAndAdjustments?

  • 0 in reply to Andrew1986

    Hi, there I'm taking over from Craig. We were told in Sage 300 2019 this isn't possible through the new Web API. I'm wondering if this can be done with Sage 300 2022 when we upgrade next year?

    I can try and give you more info but we've been told by Sage our workflow of what we want won't currently work in 2019 Web API.

Reply Children
No Data