raghu Chaudhary Posted December 6, 2023 Share Posted December 6, 2023 If I already have Invoice on Sage and I want to create a Credit note linked to that Invoice, what invoice data should I send with the credit note data to link them and make invoice Paid. I am currently sending data like this for creating Credit note in CURL(PHP) - $data = '{ "sales_credit_note": { "contact_id": "'.$contact_id.'", "currency_id": "'.$currency_id.'", "exchange_rate": "1", "date": "'.$date.'", "reference": "'.$reference.'", "main_address": { "address_line_1": "'.$billing_street.'", "address_line_2": "'.$billing_state.'", "city": "'.$billing_city.'", "postal_code": "'.$billing_zip.'", "country_id": "GB" }, "credit_note_lines": [' '], "net_amount": "'.$net_amount.'", "total_amount": "'.$net_amount.'", "total_quantity": "'.$total_quantity.'" } }'; It only creates the credit note but I also want to link Invoice with it. Link to comment Share on other sites More sharing options...
Steel, Mark Posted December 6, 2023 Share Posted December 6, 2023 Hi Raghu, The credit note needs to be allocated to the invoice in order to mark the invoice as paid. Our payments guide provides further details of how this can be achieved in the Allocating contact artefacts section. https://developer.sage.com/accounting/guides/concepts/payments/ Thanks Mark Link to comment Share on other sites More sharing options...
raghu Chaudhary Posted December 6, 2023 Author Share Posted December 6, 2023 Hello Mark, I have read the payments section but I am unable to find out how can I allocate credit note with invoice on sage. Like in this I can pass invoice id in artefact_id, but where should I put credit note id or credit note data which I want to link with that invoice? POST /contact_payments Content-Type: application/json { "contact_payment": { "transaction_type_id": "CUSTOMER_RECEIPT", "payment_method_id": "CREDIT_DEBIT", "contact_id": "7dfc261d51eb9c107bff7273862f6e80", "bank_account_id": "27cf77a0e56b4c420345893cfc404c94", "date": "2018-04-06", "total_amount": "99.99", "allocated_artefacts": [ { "artefact_id": "ba0473ae7201b61bc1d820059ff69551", "amount": "77.77" } ] } } Link to comment Share on other sites More sharing options...
Steel, Mark Posted December 6, 2023 Share Posted December 6, 2023 The example we have in the guide(attached) uses the contact_allocations API. You are creating an allocation and do not require the contact_payment API. The example refers to the credit value of a payment on account but this could be any credit value(including a credit note) on the customer account. You need to pass in the amount being allocated as well as the sales_invoice id and sales_credit_note id in the allocated artefacts array. The amount can only be as large as the highest amount outstanding on either artefact. For example the SI outstanding amount = 10 and the SC outstanding amount = 20 the largest amount possible to allocate is 10. Thanks Mark Link to comment Share on other sites More sharing options...
raghu Chaudhary Posted December 7, 2023 Author Share Posted December 7, 2023 Sorry to bother you again- Link to comment Share on other sites More sharing options...
raghu Chaudhary Posted December 7, 2023 Author Share Posted December 7, 2023 (edited) Sorry to bother you again- in this part of the artefacts id in which money is getting deducted- the artefact_id is Credit Note id or contact_id? I tried giving credit_note sage id like this- but it's saying - 'A malformed request body was sent to the API.' Thanks. Edited December 7, 2023 by raghu Chaudhary Link to comment Share on other sites More sharing options...
raghu Chaudhary Posted December 7, 2023 Author Share Posted December 7, 2023 Please ignore my last queries- What should I pass in TransactionType? I passed CUSTOMER_RECEIPT but its giving the following response- Couldn't find TransactionType with name=CUSTOMER_RECEIPT Link to comment Share on other sites More sharing options...
Steel, Mark Posted December 7, 2023 Share Posted December 7, 2023 Hi Raghu, The transaction type = CUSTOMER_ALLOCATION. I've included an example body below where 387a3153269143aa9555ce8ad377eea2 = sales_invoice_id and 17ade05ce4674040a0742578308c20c0 = sales_credit_note_id. The credit value needs to be signed -. https://developer.sage.com/accounting/reference/payments/#tag/Contact-Allocations/operation/postContactAllocations { "contact_allocation": { "transaction_type_id": "CUSTOMER_ALLOCATION", "contact_id": "2f0a9bdd56a548ffbac9380eba27ac19", "date": "2023-12-07", "allocated_artefacts": [ { "artefact_id": "387a3153269143aa9555ce8ad377eea2", "amount": "162.25" }, { "artefact_id": "17ade05ce4674040a0742578308c20c0", "amount": "-162.25" } ] } } Thanks Mark Link to comment Share on other sites More sharing options...
raghu Chaudhary Posted December 11, 2023 Author Share Posted December 11, 2023 One more thing, what if I want to unallocate/unlink that credit note from the Invoice? Thank you for your help. Link to comment Share on other sites More sharing options...
Steel, Mark Posted December 11, 2023 Share Posted December 11, 2023 Hi Raghu, The contact_allocation would need to be deleted in order to un-allocate the invoice and credit. The contact_allocation created from the above example is 19ef656e02a64d0eb8c0c06fb6fc87a4 so I would need to pass the below request to un-allocate. DELETE https://api.accounting.sage.com/v3.1/contact_allocations/19ef656e02a64d0eb8c0c06fb6fc87a4 Thanks Mark Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now