Allocating Payments to an Invoice

I've trying to allocate a payment to an invoice but getting this returned:

1
Struct
$severity
string error
$dataCode
string Validation
$message
string contact_allocation is missing
$source
string contact_allocation
2
Struct
$severity
string error
$dataCode
string Validation
$message
string contact_allocation[transaction_type_id] is missing
$source
string contact_allocation[transaction_type_id]
3
Struct
$severity
string error
$dataCode
string Validation
$message
string contact_allocation[contact_id] is missing
$source
string contact_allocation[contact_id]
4
Struct
$severity
string error
$dataCode
string Validation
$message
string contact_allocation[allocated_artefacts] is missing
$source
string contact_allocation[allocated_artefacts]

I am posting this via a POST:

    {
      "contact_payment":
          {
        "transaction_type_id": "CUSTOMER_ALLOCATION",
        "contact_id": "577a81163ac24bec9b41ac095e4f4690",    
        "date": "2020-06-24",
        "allocated_artefacts":
            [
              {"artefact_id": "ba41f154245849419c252cd22bfcf2fa", "amount": 10.00},
            {"artefact_id": "99c03cce0e794413b47407ed978c8058", "amount": -10.00}
            ]
          }
    }

The customer_id is correct and the payment and invoice are also correct.  I just can't seem to get this to work.

The invoice is showing in Sage with no payments made against it and the payment is not allocated anywhere.

Any ideas?

Parents
  • Hi Ash,

    Please refer to this thread from a week or so ago, it looks to me like it could be the same issue.

    https://www.sagecity.com/developer/accounting-api/f/discussions/151826/couldn-t-find-sales-payable-artefact

    Everything in your POST request looks fine but as per the thread above you will need to use the payment_on_account_id rather than the ID of the payment itself. 

    Please let us know if this is not the issue and we can look to troubleshoot further

    Kind Regards 

    Dan

  • Thanks for getting back to me Dan.  I've just tried this and get the same errors returned:

    contact_allocation is missing
    contact_allocation[transaction_type_id] is missing
    contact_allocation[contact_id] is missing
    contact_allocation[allocated_artefacts] is missing

    I retrieved the payment_on_account id using contact_payments/[key] with key being the payment_id of the payment in Sage

    I then posted this in JSON:

    {
    "contact_payment":
    {
    "transaction_type_id": "CUSTOMER_ALLOCATION",
    "contact_id": "67d1215519c542b4825c49d7f74cb6b5",
    "date": "2020-06-24",
    "allocated_artefacts":
    [
    {"artefact_id": "cebe8fe981e843ee860e9259dc19432f", "amount": 49.80}, 
    {"artefact_id": "69a7da0e32de4b0eb25d4ff6e4aee64a", "amount": -29.80}
    ]
    }
    }

    to:  https://api.accounting.sage.com/v3.1/contact_allocations 

    I've tried deliberately using invalid artefact_ids and this also produces the same errors.

    Do you have any further thoughts please?

  • Hi Ash,

    I think I have noticed an issue. It looks as though you're posting to the correct endpoint in contact_allocations but the request should look something like the example below. Since the Invoice and the contact_payment already exists you do not need to post another contact_payment. Hopefully this helps. 

    {
      "contact_allocation":{
        "transaction_type_id": "CUSTOMER_ALLOCATION",
        "contact_id": "{{{ customer_id }}}",
        "allocated_artefacts": [
          {
            "artefact_id": "{{{ another_sales/purchase_invoice_id }}}",
            "amount": 5
          },
          {
            "artefact_id": "{{{ contact_payment_on_account_id }}}",
            "amount": -5
          }
        ]
      }
    }
    


    Kind Regards

    Dan

  • Thanks very much for your help Dan, I've now got the payments allocating to the invoice correctly. 

    I did have to amend and remove the extra {} braces around the contact_id and artifact_ids which weren't needed. 

    {
    "contact_allocation":{
    "transaction_type_id": "CUSTOMER_ALLOCATION",
    "contact_id": "67d1215519c542b4825c49d7f74cb6b5",
    "allocated_artefacts": [
    {
    "artefact_id": "cebe8fe981e843ee860e9259dc19432f",
    "amount": 49.80
    },
    {
    "artefact_id": "9815adf004a94d2c933c0177e9342291",
    "amount": -20.00
    },
    {
    "artefact_id": "69a7da0e32de4b0eb25d4ff6e4aee64a",
    "amount": -29.80
    }
    ]
    }
    }

    Thanks once again!

Reply
  • Thanks very much for your help Dan, I've now got the payments allocating to the invoice correctly. 

    I did have to amend and remove the extra {} braces around the contact_id and artifact_ids which weren't needed. 

    {
    "contact_allocation":{
    "transaction_type_id": "CUSTOMER_ALLOCATION",
    "contact_id": "67d1215519c542b4825c49d7f74cb6b5",
    "allocated_artefacts": [
    {
    "artefact_id": "cebe8fe981e843ee860e9259dc19432f",
    "amount": 49.80
    },
    {
    "artefact_id": "9815adf004a94d2c933c0177e9342291",
    "amount": -20.00
    },
    {
    "artefact_id": "69a7da0e32de4b0eb25d4ff6e4aee64a",
    "amount": -29.80
    }
    ]
    }
    }

    Thanks once again!

Children
No Data