Finance payments
Payment runs from your own bank accounts, on their payment calendars. A run is proposed from what is due, prepared, approved, and released by a second person. Petawork never moves money; a released run becomes an instruction for your own bank.
Payments turns what you owe into payment runs. A run is the set of payments one of your bank accounts makes on one day. One person proposes and prepares it, the approvals engine approves it, and a second person releases it.
Petawork never moves money. It holds no bank login and calls no bank API or payment provider. Releasing a run produces a bank file that you download and upload to your own bank yourself.
Payments is a Finance module (finance.payments). Open it in Finance > Payments (/finance/payments). The page has
these tabs: Runs, Bank accounts (/finance/payments/accounts) and Settings (/finance/payments/settings, the
payment journal's accounts). A run opens at /finance/payments/run?id=<id>.
Bank accounts and calendars
A bank account here is one of your organisation's own accounts that runs pay from. Your vendors' accounts are different: they are on parties. Each account belongs to one entity and has one currency, and neither ever changes. It also has:
| Field | What it is |
|---|---|
| Name | What people call it: "Operating SGD" |
| Bank, bank code, name on account | The bank's details. Spaces and dashes are taken out of the code |
| Account number | Sealed in the vault. Only the last four digits are ever shown. A hash catches the same account added twice |
| Bank file format | The file its runs export to: csv or pain001 |
| Ledger account | The bank's account in your chart of accounts. The payment journal credits it |
| Payables account | The account a payment debits when its line does not name one |
| Statement source | Its bank statements in Reconciliation |
| Calendar | The days runs may go out (below) |
Adding or changing an account needs bank_account.create on its entity: a vendor admin or a controller. An agent can
never do it.
The payment calendar
Each bank account can have a calendar:
- Run weekdays: 1 (Monday) to 7 (Sunday).
- Run days of the month: 1 to 31. 31 means the last day of the month, even in a short month.
- Bank holidays: dates the bank is closed.
- Cut-off: a time of day (HH:MM) in the calendar's time zone. After the cut-off, today is no longer a run day.
A run day that falls on a weekend or a holiday moves forward to the next business day. With no calendar, every business day (Monday to Friday) is a run day. The Bank accounts tab shows each account's next four run days.
A run
Propose run (finance_payrun_propose) takes a bank account and a day. With no day given, it uses the earliest run
day still before the cut-off. The run is numbered PR-000001 and up, per entity, with no gaps.
A run collects:
- the approved items every module that feeds Payments has due before the next run day, or that lose an early-payment discount before then, or are overdue. Today that is bills: approved, scheduled or partly paid, for what is still open (the total less withholding and what is paid). Credit notes are not netted against a vendor's bills yet;
- the manual lines you add: a payee, an amount, a reference, and optionally a due date and the account to debit.
Payments to the same payee are combined into one payment.
Some items are left out. The run lists each one with the reason:
| Reason | What it means |
|---|---|
| open exception | The item has an open exception |
| disputed | The item is in dispute |
| no verified bank account | The payee has no verified bank account in the run's currency. This also raises a payment_blocked exception |
| already in run | The item is in another run that is still open |
| not due yet | It is due after the next run day |
| payee blocked | The payee is blocked |
An item is never in two runs at once, even when two people propose runs at the same moment.
Off-cycle runs
A day that is not a run day (or today after the cut-off) needs an off-cycle reason of at least 20 characters. The reason stays on the run. An off-cycle run is approved only by break glass: a controller forces the approval with a written reason (approvals).
Statuses
| Status | What it means |
|---|---|
proposed |
Being built. Payments can be held and holds taken off |
prepared |
Frozen and checked; on its way to approval |
in_approval |
Waiting in Finance > Approvals |
approved |
Approved; waiting to be released |
released |
Released by a second person. Its bank file can be exported |
exported |
Its bank file was downloaded; the file's sha256 is on the run |
sent |
Someone marked the file uploaded to the bank |
settled, partly_settled |
The payments settled on the bank statement (coming with reconciliation) |
cancelled |
Cancelled with a reason. Its items are free for another run |
Hold (finance_payrun_hold) holds one payment, with a reason, or takes the hold off. Taking a hold off checks the
payee's bank account again. Any change to a run that was prepared, sent or approved sends it back to proposed. Its
approval request is closed and it has to be prepared and approved again.
Prepare (finance_payrun_prepare) checks every payee's bank account again. A payment whose account changed or is
no longer verified is held, and a payment_blocked exception is raised. Prepare then freezes the run and sends it for
approval as the document type payment_run. When no policy names an approver, a controller on the entity approves it.
If the run could not be sent, it stays prepared. Prepare it again to send it.
Cancel (finance_payrun_cancel) needs a reason. A released run is never cancelled: a correction is a new run.
Release
Release is the two-person step. It happens only in the app, by a signed-in person. There is no MCP tool and no API call for it, and an agent can never release a run.
To release a run you need payment_releaser on its entity, and you must not have proposed, prepared or changed it.
Everyone who did is listed on the run. That holds even if someone else changed the run after you. If you configured an
agent that changed the run, you count as having changed it too. All of this is checked again inside the release itself,
with the run locked, so two people pressing Release at the same moment release it once. The database refuses a release
by any of the run's editors or by an agent.
At release, Petawork checks again:
- the approval covers exactly this version of the run;
- every payee's bank account is still verified, and is the same account that was frozen into the run;
- every item can still be paid (a bill being disputed or voided at that moment is waited for, then its payment held);
- you did not change any payee's bank details in the last 30 days.
A payment that fails these checks is held, and a payment_blocked exception is raised. The rest are released together.
If every payment is held, nothing is released and the run goes back to proposed.
The bills a released run pays move from approved to scheduled. If a bill's payment is held later, for example by the
check at export, the bill goes back to approved and the next run can pick it up. A bill becomes paid only when the
payment settles.
A released run proposes its payment journal once (journals), described below.
A release also sends finance.payment_run.released to your webhooks.
The payment journal
The journal clears from payables everything a payment settles, not only the cash:
| Line | Amount |
|---|---|
| Debit the bill's payables account | the cash, plus any early-payment discount taken, plus the bill's tax withheld |
| Credit the bank's ledger account | the cash |
| Credit the discounts received account | the discount taken |
| Credit the withholding tax payable account | the tax withheld, once, on the payment that settles the bill in full |
Set the two accounts in Finance > Payments > Settings (/finance/payments/settings), one pair per entity. They are
stored in the entity's settings as settings.payments.discount_account_id (an income or expense account) and
settings.payments.withholding_account_id (a liability account), so finance_entity_update sets them too. You need
reference.write on the entity.
A run that takes a discount, or pays a bill with tax withheld, is refused at prepare and at release until the account it needs is set; the refusal names the setting. A payment that settles after release with no journal of its own, and whose account is still missing, settles anyway and its page says why there is no journal.
The journal also needs the bank account's ledger account and a payables account for every line. If one is missing, the run is still released and its page says why there is no journal; each payment's journal is then recorded when it settles, once the missing account is set.
Journals posted before this change are not rewritten. Their payables account keeps the discount and the withholding as an open debit balance on the vendor. To clear it, post a manual journal in Finance > Journals, dated in an open period: debit the payables account, credit your discounts received account with the discounts, and credit your withholding tax payable account with the tax withheld, with the vendor on each line. The vendor's payables balance then reads zero for those bills.
Bank files
A released run shows a Bank file section with the format, the number of payments and the control sum. Compare these with what your bank's portal shows after you upload the file.
Export bank file downloads the file. Only a signed-in person with payment_releaser on the run's entity can do it,
in the app. An agent, an API key and a connected app never can, because the file holds full account numbers. At the
first export Petawork checks every payee's bank account once more. The account the payment was frozen with must still
be verified, and its number must still match the hash taken when the run was prepared. A payment that fails is held, a
payment_blocked exception is raised, and the payment is left out of the file. A held payment is never in a file.
The first export moves the run and its payments to exported and records the file's sha256 on the run. Download
again makes the same file, byte for byte, from the same frozen details, and every download is on the event chain. If
the paying account's details or file settings changed since, the file would differ, so nothing is handed out. The file
you downloaded first stays the record. A correction is a new run.
After you upload the file to your bank, press Mark sent (finance_payrun_mark_sent). Petawork sends nothing to the
bank.
Full account numbers appear only in the file. They are never in a tool's answer, an event, the audit log or an error. Problems name the payment and the field instead.
Formats
The bank account's Bank file format picks the format, and its format options (JSON) configure it.
pain001 is ISO 20022 pain.001.001.03, a credit transfer. Most European banks take it, and so do many others.
The file has one payment block per run and batch booking, and the control sums are in the currency's decimals. Each
payment's end-to-end id is its Petawork id. An account number that is an IBAN goes as an IBAN, and any other number
goes as a local account number. A bank code that is a BIC goes as a BIC, and any other code as a clearing code. Options:
| Option | Default | What it does |
|---|---|---|
charset |
latin |
latin: the SEPA character set. Accents are dropped ("Müller" becomes "Muller") and & becomes +. A name with no Latin form, such as one in Chinese characters, stops the file and names the payment. unicode: UTF-8 as written |
service_level |
none | SEPA, URGP or another code your bank asks for |
charge_bearer |
none | SLEV (SEPA), SHAR, DEBT or CRED |
batch_booking |
true |
One debit for the whole run, or one per payment |
name_max |
70 |
The longest name your bank takes (up to 140) |
account_scheme |
auto |
iban refuses any account that is not an IBAN; other always sends the local number |
The file is checked against the published schema, which is kept in the repository.
csv is a bulk-upload CSV, the format most local banks in Indonesia, Singapore and elsewhere take. The layout is a
template. format_options.layout picks a built-in one, and format_options.template overrides any part of it:
| Template key | What it says |
|---|---|
columns |
The columns in order: each has a title, a field and optionally max (the longest value allowed). For a fixed value, set field to fixed and give a value |
delimiter, line_ending, quote |
, ; | or a tab; crlf or lf; minimal or all |
encoding |
utf8, utf8_bom or ascii (accents dropped; other characters refused) |
date_format, decimal |
YYYY-MM-DD, YYYYMMDD, DD/MM/YYYY, MM/DD/YYYY, DD-MM-YYYY or DD.MM.YYYY; . or , |
titles |
A first row of column titles |
before, after |
Control rows before and after the payments, such as a header record and a trailer with the count and control sum |
Row fields: end_to_end_id, payment_id, row, payee_name, payee_account, payee_bank_code, payee_bank_name,
amount, amount_minor, currency, value_date, reference, debtor_name, debtor_account, debtor_bank_code,
run_number, fixed. Control row fields: count, control_sum, control_sum_minor, currency, value_date,
created_date, run_number, debtor_name, debtor_account, debtor_bank_code, fixed.
The built-in layouts are generic, Petawork's own plain layout and the default, and two examples:
example_header_trailer and example_semicolon. The examples show what a template can say. They are not any
bank's specification, and the run page warns you when an account uses one. Ask your bank for its bulk upload layout
and set it as the account's template. A text cell a spreadsheet would read as a formula (starting with =, +, -
or @) gets a leading apostrophe.
Before any file is made, every payment is checked: field lengths, the character set, the account and bank code formats,
and one currency per file. Check (finance_payrun_export, also on the run page) lists every problem without making
the file.
Remittance advice
Each payment in an exported file has a Remittance advice link on the run page
(/finance/payments/remittance?id=<payment id>). The advice shows who paid whom, the value date, the run, the last four
digits of the account, each bill or item paid with its discount, any withholding, and the total. It is in the payee's
remittance contact's language (else their billing contact's, else English). Add &lang= with another of the seven
languages to change it. Print or save as PDF makes a PDF for you to send.
Petawork does not email remittance advice yet. Sending it through your organisation's connected
Comms mailbox needs a per-entity switch that does not exist yet, so for now you send the PDF
yourself. finance_remittance_get returns the same advice to an agent.
Roles
| Who | May |
|---|---|
payment_preparer |
Propose, hold, prepare and cancel runs |
payment_releaser |
Release a run they did not propose, prepare or change; export its bank file in the app; mark it sent |
| Controller, auditor, payment roles | Read runs and payments (reports.read), check a run's bank file, read remittance advice |
| Vendor admin, controller | Add and change bank accounts |
| An agent | Propose, hold, prepare and cancel with payment_preparer, read, and check a file. Never release, never download a bank file, never mark one sent, never add a bank account |
Tools
| Tool | What it does |
|---|---|
finance_bankaccount_create, finance_bankaccount_list, finance_bankaccount_update |
Your bank accounts and their calendars |
finance_payrun_propose, finance_payrun_list, finance_payrun_get |
Propose a run; list and read runs |
finance_payrun_prepare, finance_payrun_hold, finance_payrun_cancel |
Prepare, hold or unhold a payment, cancel |
finance_payment_list, finance_payment_get |
Payments in runs and the items each covers |
finance_payrun_export |
Check a run's bank file: format, count, control sum, sha256 and every problem. Never the file itself |
finance_payrun_mark_sent |
Mark an exported run sent |
finance_remittance_get |
A payment's remittance advice |
Their REST forms are under /api/v1/finance/bank-accounts, /api/v1/finance/payment-runs and /api/v1/finance/payments.
A run is also a workspace reference (fin_payment_run), so you can mention one in a note or an issue
(references).