Your end-user, or their accountant, makes the accounting choices: which bank account in their books each of your accounts feeds, and when the feed starts. You build the setup screen where they make these choices, and the logic that sends the statements.
1. Fetch the bank accounts
Fetch the bank accounts when the end-user connects their accounting software. Show them in your setup screen. Store the selection of the end-user for each consumer, for each of your accounts and for each currency. Call Get bank accounts. The list is paginated: see Pagination. When the connection gives access to several folders, addfolder_id. See Multi-folder.
- Store the
id. You send it asbank_account_idon the statement. - Show the
account_nameand thecode. - Use the
ibanto suggest a match with your account. It is empty when the accounting software holds no IBAN for the bank account. - Check the
currency. The currency of a statement must be the currency of its bank account. Your end-user links each of your accounts, in each currency, to one bank account.
2. Send the statement
Create one statement for each of your accounts and for each day. Call Create bank transactions:POST /consumers/{consumer_id}/accounting/bank-transactions
Statement fields
bank_statement_date: the date of the statement (YYYY-MM-DD).bank_account_id: the bank account selected for this account and this currency (see step 1).currency: the ISO 4217 code, for exampleEUR. It must be the currency of the bank account. For another currency than the one of the folder, see Multi-currency.external_bank_statement_id: your identifier of the statement. Use digits only, with a maximum length of 10.opening_balance: the balance of the account before the statement. Send it on every statement. The accounting software uses it to check the balance.pdfandpdf_name: the PDF of the statement in base64, and its file name. The file name accepts letters, digits,-,_and spaces, and can end with.pdf. See Attachments.items: the lines of the statement.
Line fields
amount: the amount of the movement, including fee and tax. Send a positive amount for money received and a negative amount for money leaving the account.description: the most identifying text of the movement, such as the counterparty name or the reference of an invoice. The accounting software uses it to suggest a match during reconciliation.external_transaction_id: your identifier of the movement.counterpart: the counterparty, withname,ibanandbank_account.fee_amount,tax_amount,currency_exchange_rateandgeneral_ledger_account: optional. Each accounting software uses only the fields that it can store. Check the page of the connector.
Check the balance before you send
Send every settled movement once, and only settled movements. A pending movement is sent after it has settled. Before you send a statement, check the balance:Example
POST /consumers/{consumer_id}/accounting/bank-transactions
< and > come from step 1 and from your own data.
The response returns the id of the statement and the id of each line. Store them.
Avoid duplicates
Add a uniquex-chift-client-requestid header to each request. When you retry a request that already succeeded, Chift answers with a 409 error and does not create a second statement. See Idempotency.
Run your synchronization on a schedule, for example every night. Start it on the day chosen by your end-user. This day must follow the last movement already in their books. Otherwise, the same movements are booked twice.