Jump to content

Set the status of an invoice when creating it


 Share

Recommended Posts

Hi there,

Just wondering how I can set the status_id of an invoice when I create it. At the moment when I create an invoice, they automatically are set as overdue. Here is my code, if you have any ideas they would be much appreciated

url = 'https://api.accounting.sage.com/v3.1/sales_invoices'
    payload = {
        "sales_invoice": {
            "contact_id": contact_id,
            "date": date,
            "due_date": date,
            "reference": reference,
            "invoice_lines": products,
            "status_id": 'PAID'
        }
    }

    headers = {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer ' + access_token,
    }

    response = requests.request("POST", url, headers=headers, json=payload)

Thank you

Link to comment
Share on other sites

Hi Norman, thank you for your question.

The status_id of artefacts is read only and cannot and should not be set directly. They are given their various statuses based on dates, such as date and due_date and payment/credit allocations.

If you're creating an invoice with both a date and due_date of today, the invoice will be automatically given the status of overdue as it is expecting payment that same day.

There are a couple of guides available that will help you further with this. Artefact StatusesPayments & Receipts

Thanks

Mark

Link to comment
Share on other sites

@Norman Firkins

The transaction_types endpoint returns all available transaction types including the id.

 

{
    "$total": 41,
    "$page": 1,
    "$next": "/transaction_types?page=2&items_per_page=20",
    "$back": null,
    "$itemsPerPage": 20,
    "$items": [
        {
            "id": "BANK_OPENING_BALANCE",
            "displayed_as": "Bank Opening Balance",
            "$path": "/transaction_types/BANK_OPENING_BALANCE"
        },
        {
            "id": "BANK_PAYMENT",
            "displayed_as": "Bank Payment",
            "$path": "/transaction_types/BANK_PAYMENT"
        },
        {
            "id": "BANK_RECEIPT",
            "displayed_as": "Bank Receipt",
            "$path": "/transaction_types/BANK_RECEIPT"
        },
        {
            "id": "BANK_TRANSFER",
            "displayed_as": "Bank Transfer",
            "$path": "/transaction_types/BANK_TRANSFER"
        },
        {
            "id": "CORRECTION",
            "displayed_as": "Correction",
            "$path": "/transaction_types/CORRECTION"
        },
        {
            "id": "CUSTOMER_ALLOCATION",
            "displayed_as": "Customer Allocation",
            "$path": "/transaction_types/CUSTOMER_ALLOCATION"
        },
        {
            "id": "CUSTOMER_RECEIPT",
            "displayed_as": "Customer Receipt",
            "$path": "/transaction_types/CUSTOMER_RECEIPT"
        },
        {
            "id": "CUSTOMER_REFUND",
            "displayed_as": "Customer Refund",
            "$path": "/transaction_types/CUSTOMER_REFUND"
        },
        {
            "id": "DEPOSIT",
            "displayed_as": "Deposit",
            "$path": "/transaction_types/DEPOSIT"
        },
        {
            "id": "JOURNAL",
            "displayed_as": "Journal",
            "$path": "/transaction_types/JOURNAL"
        },
        {
            "id": "GENERAL_LEDGER_OPENING_BALANCE",
            "displayed_as": "Journal Opening Balance",
            "$path": "/transaction_types/GENERAL_LEDGER_OPENING_BALANCE"
        },
        {
            "id": "OTHER_RECEIPT",
            "displayed_as": "Other Receipt",
            "$path": "/transaction_types/OTHER_RECEIPT"
        },
        {
            "id": "OTHER_PAYMENT",
            "displayed_as": "Other Payment",
            "$path": "/transaction_types/OTHER_PAYMENT"
        },
        {
            "id": "PURCHASE_QUICK_ENTRY_CREDIT_NOTE",
            "displayed_as": "Purchase QE Credit",
            "$path": "/transaction_types/PURCHASE_QUICK_ENTRY_CREDIT_NOTE"
        },
        {
            "id": "PURCHASE_QUICK_ENTRY_INVOICE",
            "displayed_as": "Purchase QE Invoice",
            "$path": "/transaction_types/PURCHASE_QUICK_ENTRY_INVOICE"
        },
        {
            "id": "PURCHASE_INVOICE",
            "displayed_as": "Purchase Invoice",
            "$path": "/transaction_types/PURCHASE_INVOICE"
        },
        {
            "id": "PURCHASE_CREDIT_NOTE",
            "displayed_as": "Purchase Credit Note",
            "$path": "/transaction_types/PURCHASE_CREDIT_NOTE"
        },
        {
            "id": "SALES_QUICK_ENTRY_CREDIT_NOTE",
            "displayed_as": "Sales QE Credit",
            "$path": "/transaction_types/SALES_QUICK_ENTRY_CREDIT_NOTE"
        },
        {
            "id": "SALES_QUICK_ENTRY_INVOICE",
            "displayed_as": "Sales QE Invoice",
            "$path": "/transaction_types/SALES_QUICK_ENTRY_INVOICE"
        },
        {
            "id": "SALES_CREDIT_NOTE",
            "displayed_as": "Sales Credit Note",
            "$path": "/transaction_types/SALES_CREDIT_NOTE"
        }
    ]
}

Thanks

Mark

Link to comment
Share on other sites

@Steel, Mark

Thanks Mark thats great. I'm having trouble with searching for a sales invoice by reference. Here's my code, am I doing anything wrong? Thank you

url = 'https://api.accounting.sage.com/v3.1/sales_invoices?search=' + reference + ',status_id=paid'

headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + access_token,
}
response = requests.request("GET", url, headers=headers)

 

Link to comment
Share on other sites

  • 5 weeks later...

Hi Jake

How do your stripe payouts appear in the Bank Account? A lot will depend on how your stripe account is configured within Sage Business Cloud Accounting. Was the registration for stripe payments setup through Sage Business Cloud Accounting or external to it? 

The payments need to be seen as customer receipts in order for them to be allocated in the API. Our Payments and Receipts guide offers further guidance on this. 

Thanks

Mark

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...