accounting
Stable. Describes behaviour that is built and covered by tests in this repository.
GET /v1/accounting/summary #
Income and expenses of a period, one block per currency
Currencies are never converted or added together. Income is read from the invoices: an invoice counts on the UTC day its payment succeeded (gross is its total, tax its TAX lines), credit notes against paid invoices and invoices refunded in full are the refunds. Provider commission is not recorded by Payrudder; provider_fees_minor is what the tenant entered as payment_fees expenses, and provider_fees_recorded is false when there is none. expenses_minor includes those fees. profit_minor is net income minus expenses. The series has one point for every day (or month) of the period. app_id limits the expenses, not the income.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
from required | query | string · date | First day, inside the period |
to required | query | string · date | Last day, inside the period; at most five years after `from` |
app_id | query | string · uuid | |
granularity | query | day | month | Default: day up to 62 days, month beyond. Day is allowed for at most 366 days. |
Responses
| Status | Meaning | Body |
|---|---|---|
200 | OK | AccountingSummary |
400 | Error envelope | Error |
Example response
{
"from_date": "string",
"to_date": "string",
"granularity": "day",
"app_id": "string",
"currencies": [
{
"currency": "string",
"gross_income_minor": "string",
"tax_minor": "string",
"refunds_minor": "string",
"net_income_minor": "string",
"expenses_minor": "string",
"provider_fees_minor": "string",
"provider_fees_recorded": false,
"profit_minor": "string",
"paid_invoices": "string",
"expense_by_category": [
{
"category": {},
"amount_minor": "string"
}
],
"series": [
{
"bucket": "string",
"gross_income_minor": "string",
"tax_minor": "string",
"refunds_minor": "string",
"net_income_minor": "string",
"expenses_minor": "string",
"profit_minor": "string",
"discounts_minor": "string"
}
],
"discounts_minor": "string",
"sales_minor": "string",
"coupons": [
{
"coupon_code": "string",
"invoices": "string",
"gross_minor": "string",
"discount_minor": "string",
"net_minor": "string"
}
]
}
]
}curl
curl -X GET https://YOUR-API-ADDRESS/v1/accounting/summary \
-H "Authorization: Bearer $PAYRUDDER_API_KEY"GET /v1/accounting/export.csv #
The accounting series as CSV
The query of the summary. One row per currency and day (or month), then a total row per currency; amounts are minor units. The provider_fees_minor of a total row is not_recorded when no payment_fees expense exists. discounts_minor is what coupons took off (contra-revenue) and sales_before_discounts_minor is gross - tax + discounts.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
from required | query | string · date | |
to required | query | string · date | |
app_id | query | string · uuid | |
granularity | query | day | month |
Responses
| Status | Meaning | Body |
|---|---|---|
200 | OK |
curl
curl -X GET https://YOUR-API-ADDRESS/v1/accounting/export.csv \
-H "Authorization: Bearer $PAYRUDDER_API_KEY"GET /v1/accounting/coupons.csv #
Gross sales, discounts and net per coupon as CSV
The query of the summary. One row per currency and coupon over the invoices paid in the period: their number, what they came to before the coupon (positive lines, tax excluded), what the coupon took off, and the net. Currencies are never added together.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
from required | query | string · date | |
to required | query | string · date | |
app_id | query | string · uuid | |
granularity | query | day | month |
Responses
| Status | Meaning | Body |
|---|---|---|
200 | OK | |
400 | Error envelope | Error |
curl
curl -X GET https://YOUR-API-ADDRESS/v1/accounting/coupons.csv \
-H "Authorization: Bearer $PAYRUDDER_API_KEY"Models
AccountingCoupon
| Field | Type | Description |
|---|---|---|
coupon_code required | string | |
invoices required | string · int64 | |
gross_minor required | string · int64 | What those invoices came to before the coupon: positive lines, tax excluded |
discount_minor required | string · int64 | |
net_minor required | string · int64 | gross - discount |
AccountingCurrency
| Field | Type | Description |
|---|---|---|
currency required | string | |
gross_income_minor required | string · int64 | Invoices paid in the period, tax included |
tax_minor required | string · int64 | The tax lines of those invoices, less the tax that credit notes issued in the period gave back (it is negative in a period that gave back more than it collected) |
refunds_minor required | string · int64 | Credit notes against paid invoices plus invoices refunded in full |
net_income_minor required | string · int64 | gross - tax - refunds |
expenses_minor required | string · int64 | Every live occurrence in the period, provider fees included |
provider_fees_minor required | string · int64 | The payment_fees expenses; meaningful only when provider_fees_recorded |
provider_fees_recorded required | boolean | False: no commission was entered, which is not the same as zero |
profit_minor required | string · int64 | net income - expenses; negative for a loss |
paid_invoices required | string · int64 | |
expense_by_category required | array of object | |
series required | array of AccountingPoint | |
discounts_minor required | string · int64 | What coupons took off the paid invoices (contra-revenue, a positive number). gross_income_minor is already after it |
sales_minor required | string · int64 | Revenue before discounts: gross - tax + discounts |
coupons required | array of AccountingCoupon | Gross, discounts and net per coupon, most discount first |
AccountingPoint
| Field | Type | Description |
|---|---|---|
bucket required | string · date | The day, or the first day of the month |
gross_income_minor required | string · int64 | |
tax_minor required | string · int64 | |
refunds_minor required | string · int64 | |
net_income_minor required | string · int64 | |
expenses_minor required | string · int64 | |
profit_minor required | string · int64 | |
discounts_minor required | string · int64 | What coupons took off the invoices paid in this bucket |
AccountingSummary
| Field | Type | Description |
|---|---|---|
from_date required | string · date | |
to_date required | string · date | |
granularity required | day | month | |
app_id required | string | |
currencies required | array of AccountingCurrency | Ordered by currency code; a currency with no income and no expenses has no block |
Error
| Field | Type | Description |
|---|---|---|
error required | object |