Add clearing record to invoice (by invoice number)
POST/invoices-by-number/{invoiceNumber}/clearingrecords
Adds a clearing record (payment, interest, or reminder) to the invoice's clearing. The invoice is identified by invoice number. Invoice clearing is created when invoice status is approved and payment status is 'open'. Not allowed for netting members or collection members. Supplier invoices with payment status 'on-hold' do not have clearing; clearing is created when approved for payment.
When totalUnpaid becomes 0 after this record, invoice payment status is set to closed. For CUSTOMER_INVOICE with POSTPAID/PREPAID, payment may be applied to billing balance automatically.
If the path contains %, the value is URL-decoded before lookup. If multiple invoices match the invoice number, the API returns 409 (TOO_MANY_RECORDS_FOR_INV_NUMBER).
Audit event:
- invoice.by.number.clearing.record.add
Privilege (one of; checked against invoice class):
- finance-invoices.manage
- finance-cust-invoices.manage
- finance-supplier-invoices.manage
- finance-netting-invoices.manage
clearingTypeId:
- 1 - Invoice (auto-generated)
- 2 - Payment (paidAmount required)
- 3 - Interest (amountIncrement required)
- 4 - Reminder (amountIncrement required)
paymentTypeId:
- 1 - Bank Transfer (bankAccountId required or 0 for default)
- 2 - Credit Card
- 3 - Paypal
- 4 - Cash
Errors:
- INVOICE_NOTFOUND - Invoice not found
- NETTING_MEMBER_COLLECTION_LEAD_CHANGE_NOT_ALLOWED - Can not manage clearing records for netting invoice member
- COLLECTION_MEMBER_CLEARING_RECORD_NOT_ALLOWED - Invoice is collection member.Collection members ar not allowed to have clearing records
- INVOICE_CLEARING_NOTFOUND - Invoice clearing not found
- CREDIT_RECORD_NOTFOUND - Credit record not found
- PAYMENT_TRANSFER_FAILED - Payment transfer to billing failed
- BILLING_RECORD_NOTFOUND - Billing record not found
- INVOICE_CLEARING_RECORD_NOTFOUND - Invoice clearing record not found
- TOO_MANY_RECORDS_FOR_INV_NUMBER - There are multiple invoices for the given invoice number
- NOT_AUTHORIZED - Not authorized
- NOT_AUTHENTICATED - Not authenticated
- INT_APP_ERROR - Unexpected internal error
Error items:
- invalid value - clearingTypeId can not be nil
- invalid value - clearingTypeId can not be 1
- invalid value - clearingTypeId must be in (2,3,4)
- invalid value - recordDate can not be nil
- invalid value - RecordDate date invalid
- invalid value - paymentTypeID can not be nil
- PAYMENT_TYPE_NOT_FOUND - Payment type not found
- invalid value - amountIncrement must not be empty or 0 for clearingTypeId 3 or 4
- invalid value - paidAmount must not be empty less than 0 for clearingTypeId 2 or 5
- payment overflow - maximum paidAmount can be <totalUnpaid>
- invalid value - bank account id not provided
- invalid value - bank account with given id not found
- invalid value - bank account currency and invoice currency do not match
- BANK_ACC_NOT_ALLOWED_FOR_PAYMENT_TYPE - Bank acc not allowed for payment type: 'paymentTypeName'
Request
Responses
- 200
- 400
- 401
- 404
- 409
- 500
Clearing record added; returns the created record
Bad Request - Missing context or validation failed
Not Authorized or Not Authenticated
Invoice, clearing, credit/billing record, or clearing record not found
Conflict - Multiple invoices for number, or not allowed to add clearing record (netting member or collection member)
Internal Server Error