Apply a Payment to the Invoice

SUGGESTED

Hello Team,

I want to apply a payment to the Invoice. To do it I use the following endpoint: POST ARPostReceiptsAndAdjustments

Example of the request:

{
"BatchRecordType""CA",
"BatchNumber"77,
"BatchDate""2021-06-27",
"Description""prepay",
"NumberOfEntries"1,
"BankCode""CCB",
"DefaultBankCurrency""CAD",
"ReceiptsAdjustments": [
{
"BatchType""CA",
"BatchNumber"77,
"EntryNumber"1,
"CustomerNumber""SAGE 300 T1",
"ReceiptDateAdjustmentDate""2021-06-27",
"EntryDescription""1",
"EntryReference""",
"BankReceiptAmount"66,
"CustomerReceiptAmount"66,
"TotalCustomerAmountApplied"66,
"ReceiptTransactionType""Prepayment",
"MatchingDocumentNumber""SAGE2021",
"DocumentType""Invoice",
"CustomerUnappliedAmount"0,
"AppliedReceiptsAdjustments": [
{
"BatchType""CA",
"BatchNumber"77,
"EntryNumber"1,
"LineNumber"1,
"CustomerNumber""SAGE 300 T1",
"PaymentNumber"2,
"CustomerReceiptAmount"66
}
]
}
]
}

But, Sage 300 returned the error:

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

Could you help me with the request that I should use to apply the payment to the Invoice?
  • 0
    SUGGESTED

    This endpoint doesn't take a payload in the way you are expecting. The most important thing you need to know about the web API is that you CANNOT make a batch (or any other record) ready to post. You can add a batch with invoices (or whatever type of batch you want) to Sage. You then need an external process to make the batch ready to post. Once it is ready to post, you then call the post endpoint and it will post it. You do that by creating an object in this format:

    public class ARPostInvoices
    {
        public string PostAllBatches { get; set; }
        public int PostBatchFrom { get; set; }
        public int PostBatchTo { get; set; }
        public string ActionSelector { get; set; }
        public string UpdateOperation { get; set; }
    }

    Set the values to be:

    aRPostInvoices.PostAllBatches = "Donotpostallbatches";
    aRPostInvoices.PostBatchFrom = System.Convert.ToInt32(psBatchNumber);
    aRPostInvoices.PostBatchTo = System.Convert.ToInt32(psBatchNumber);
    

    Then you post that in the request body to your endpoint using the following URL:

    http://localhost/Sage300WebApi/v1.0/-/SAMLTD/AR/ARPostReceiptsAndAdjustments('$process')

    This calls the $process method and tells Sage to process all AR batches that are ready to post within the batch from and to values you sent.

    All of this info you can get from here: http://localhost/sage300webapi

  • 0 in reply to Vega

    As of V2021 you can set GL/AR/AP batches as Ready to Post via the API, new endpoints have been included for this and we are using it in production.