Create a contract
defrr_create_contractUse when a new deal is signed and you need its revenue and billing schedule worked out from the terms, without saving it anywhere. Returns every month's billing, revenue and deferred balance, and the contract's totals. For a deal priced in a foreign currency, send currency and exchangeRate and the term prices in that currency. For a contract that started in months that are already closed (a back-dated contract), pass lockedThrough: the months from its start through that month are caught up as one lump of revenue in the first open month, the way defrr's app does, and the result says how much (foreign currency works; a single-term contract needs a quantity of 1, renewals are fine). Nothing is corrected, credited or saved: to record the contract in the user's defrr organization, use defrr_save_contract instead, if you have it. Costs 1 credit (refunded if it fails).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| currency | No | Only when the deal is priced in a foreign currency: its three-letter code, such as EUR. Then every term's price is in that currency. | |
| schedule | Yes | The contract's terms. The first term needs a startDate; each later term (a renewal) starts the day after the previous one ends when endDateIncluded is true (the default), or on the day the previous one ends when it is false. | |
| exchangeRate | No | Required with currency: how much of the organization's base currency ONE unit of that currency is worth (1 EUR = 1.8 NZD is 1.8). The schedule and totals come back in the base currency, with the foreign prices beside them. | |
| lockedThrough | No | Only for a back-dated contract: the latest closed month, as YYYY-MM (it must be on or after the contract's start month and before its last month). Revenue for the months through it is recognised together in the next month. |