{ "$schema": "http://json-schema.org/draft-04/schema#", "type":"object", "title": "credit_note", "description": "A credit note", "properties":{ "id":{ "description":"Unique identifier - UUID", "identity":true, "readOnly":true, "type":"string", "maxLength": 22, "minLength":22 }, "company_id":{ "description":"Company", "readOnly":true, "type":"string", "maxLength": 22, "minLength":22 }, "number":{ "description": "Unique number assigned by SK credit note number schema. Auto-assigned when document is opened. Required unless doc status is draft.", "type":"string", "maxLength": 50 }, "address_field":{ "description": "Address field with the receiver. Shown in envelope window.", "type":"string" }, "date":{ "description": "Date the credit note is issued. Automatically set when document is opened. Required unless doc status is draft. YYYY-MM-DD", "format":"date", "type":"string" }, "due_days":{ "description": "Used to calculate the due date of the credit note. Useless if date and due date are present.", "type":"integer" }, "due_date":{ "description": "Auto-calculated from date + due days if empty and the document is opened. YYYY-MM-DD", "format":"date", "type":"string" }, "status":{ "description": "Defaults to draft for new documents, unless otherwise stated. For new documents with status 'open' or 'closed' or doc where the status changes away from draft, following fields are set if empty: number(next in number schema), date(today), due date(due_days must be given). Only draft documents can be deleted.", "default":"draft", "enum":["draft","open","closed"], "type":"string" }, "external_ref":{ "description": "Some external reference, whatever this may be.", "type":"string", "maxLength": 255 }, "payment_method":{ "description": "How the document is being payed. Used for new payments.", "enum":["cash","bank_transfer","credit_card","paypal","direct_debit","cheque", "moneybookers", "premium_sms"], "type":"string" }, "title":{ "description": "The headline of a document. Use SK placeholders to prevent excessive typing e.g. 'Your credit note [number]'", "type":"string", "maxLength": 255 }, "notes_before":{ "description": "Notes shown before the line items. Normally contains salutation and other introductional information. SK placeholders can be used.", "type":"string", "format":"string" }, "notes_after":{ "description": "Notes shown after the line items. Can contain information about payments, bank account or a thank-you message. SK placeholders can be used.", "type":"string", "format":"string" }, "tag_list":{ "description": "Space separated list of tags. Are split and saved as Tag objects on create, update.", "type":"string" }, "language":{ "description": "Should be a valid language short-code: de-DE, fr, en-GB; like defined in your account language menu. When the document is emailed or printed, a localized version of a multi-language template(email, pdf) will be used if available. Defaults to the clients language, if empty and a client is assigned.", "type":"string", "maxLength": 10 }, "currency":{ "description": "Currency code as defined by the ISO 4217 standard (3-letter UPCASE: EUR, USD)", "type":"string", "maxLength": 3, "minLength": 3 }, "exchange_rate":{ "description": "The exchange rate from the foreign document currency(eg. USD) to the company currency(EUR). If the rate is empty we use the exchange rate on the document date or today if doc.date is empty. If there is no rate for this day, say on weekends, the closest previous day is taken(Sunday->Friday). If you open the doc at a later time make sure to manually refresh the rate, as we dont change it. ", "readOnly":true, "type":"number" }, "gross_total_exchanged":{ "description": "Exchanged gross total, in your company currency.", "readOnly":true, "type":"number" }, "archived_pdf":{ "description": "Archived PDF version of the document. Is created when an document is printed and archived. A document can have multiple archived versions. This only returns the most recent one. ", "readOnly":true, "type":"object", "$ref":"./attachment.json" }, "contact":{ "description": "The contact for the document. Use contact_id field to set a contact.", "readOnly":true, "type":"object", "$ref":"./contact.json#" }, "contact_id":{ "description": "The contact uuid. When assigning a contact its language, currency, address_field (due days, cash discount) values are used for the document if those doc-fields are not set.", "type":"string", "maxLength": 22, "minLength":22 }, "team_id":{ "description": "A team uuid taken from the contact. If set only the team and its parent teams can see the record.", "readOnly" :true, "type":"string", "maxLength": 22, "minLength":22 }, "items":{ "description": "Items for the document, including divider and sub_total items. You MUST set the type field(CamelCasedItem class name) on each item on creation.", "type":"array", "minItems": 0, "items": { "type" : "object", "anyOf" : [ { "title": "line_item", "$ref": "./line_item.json#" }, { "title": "divider_item", "$ref": "./divider_item.json#" }, { "title": "sub_total_item", "$ref": "./sub_total_item.json#" } ] } }, "created_at":{ "description": "Date the object was created in SK. Never changes afterwards.", "format":"date-time", "readOnly":true, "type":"string" }, "updated_at":{ "description": "Date the object was edited in SK.", "format":"date-time", "readOnly":true, "type":"string" }, "lock_version":{ "description": "Auto-incremented to prevent concurrent updates. First save wins.", "readOnly":true, "type":"integer" }, "gross_total":{ "description": "Gross total of all line items, 2 decimals places in document currency.", "readOnly":true, "type":"number" }, "tax_total":{ "description": "Tax total, 2 decimals places", "readOnly":true, "type":"number" }, "net_total":{ "description": "Net total, 2 decimals places", "readOnly":true, "type":"number" }, "net_total_base":{ "description": "Net total, 6 decimal places incl. discount", "readOnly":true, "type":"number" }, "cost_total":{ "description": "Cost total of all line items, 2 decimals places in document currency.", "readOnly":true, "type":"number" }, "gross_margin_total":{ "description": "Total gross margin across all line items. Calculated from net_total-cost_total.", "readOnly":true, "type":"number" }, "gross_margin_pct":{ "description": "Percentage of gross profit to cost of items sold. Calculated from gross_margin_total/net_total*100", "readOnly":true, "type":"number" }, "tax_exemption_id":{ "description": "ID of a tax exemption. When set all item taxes are omitted.", "type":"string", "maxLength": 22, "minLength":22 } }, "links":[ { "rel": "self", "href": "credit_notes/{id}" }, { "rel": "instances", "href": "credit_notes", "properties" : { "page":{ "title" : "Page", "description": "In paginated results set the page to look for", "type":"number" }, "per_page":{ "title" : "Per page", "description": "Results per page. Default is 50, max is 200", "type":"number" }, "filter[q]":{ "title" : "Search", "description": "Search in title, number, address field", "type":"string" }, "filter[status]":{ "title" : "Status", "description": "A single or a list of status, comma separated: open,closed,overdue,draft", "type" : "string" }, "filter[number]":{ "title" : "Number", "description": "Find by exact number", "type":"string" }, "filter[tags]":{ "title" : "Tags", "description": "Filter by a space delimited list of tags", "type":"string" }, "filter[from]":{ "title" : "From date", "description": "Objects with a date on and after the date. YYYY-MM-DD", "type" :"date" }, "filter[to]":{ "title" : "To date", "description": "Objects with date before and on the date. YYYY-MM-DD", "type" :"date" }, "filter[created_at_from]":{ "title" : "From date", "description": "Objects with a creation on/after the date(>=). ISO 8601 format YYY-MM-DDThh:mm:ss+z or just a date YYY-MM-DD. If date is given the time is set to the start of the day(00:00:00) so all objects created on this day are included. A time should be already utc time", "format" : "date-time", "type" : "string" }, "filter[created_at_to]":{ "title" : "To date", "description": "Objects with a creation until the date(<=). ISO 8601 format YYY-MM-DDThh:mm:ss+z or just a date YYY-MM-DD. If date is given the time is set to the end of the day(23:59:59) so all objects created on that day are included. A time should be already utc time.", "format" : "date-time", "type" : "string" }, "filter[languages]":{ "title" : "Languages", "description": "A list of language codes, comma separated", "type" : "string" }, "filter[client_ids]":{ "title" : "Clients", "description": "A single or a list of client uuids, comma separated", "type" : "string" }, "filter[ids]":{ "title" : "Documents", "description": "A single or a list of document uuids, comma separated", "type" : "string" }, "filter[creator_ids]":{ "title" : "Creator", "description": "Objects created by the given users uuids, comma separated", "type" : "string" }, "filter[product_ids]":{ "title" : "Products", "description": "Documents using the given product uuids(comma separated) in their line items.", "type" : "string" }, "sort_by":{ "title" : "Sort by", "description": "Sort the results by the given field => number", "enum":["title", "number", "created_at", "updated_at", "price_total", "price_tax", "date", "due_date"], "type": "string" }, "sort":{ "title" : "Sort", "enum":["ASC","DESC"], "description": "Sort the results in ASC or DESC", "type": "string" } } }, { "rel": "destroy", "href": "credit_notes/{id}", "method": "DELETE" }, { "rel": "update", "href": "credit_notes/{id}", "method": "PUT" }, { "rel": "create", "href": "credit_notes", "method": "POST", "properties" : { "source" : { "title" : "Source document id", "description": "Copies the source(excl. number,date) and returns a new draft document. You can pass any document type(e.g. invoice, order). Fields passed with the object(e.g. notes, title, address_field) are not overwritten." }, "cancel" : { "title" : "Cancel an credit note", "description": "Cancelling a document negates its line item values. A source id must be set.", "dependencies": ["source"] } } }, { "rel": "attachments", "href": "attachments?filter[related_object_ids]={id}" }, { "rel": "payments", "href": "payments?filter[related_object_ids]={id}" }, { "rel": "comments", "href": "comments?filter[related_object_ids]={id}" }, { "rel": "emails", "href": "emails?filter[related_object_ids]={id}" }, { "rel": "print", "href": "credit_notes/{id}/print", "method": "POST", "properties" : { "template_id" : { "title" : "PDF template used for printing", "description": "UUID of a pdf template used to print the document. MUST be present" }, "base64" : { "title" : "Return the created pdf base64 encoded", "description": "If set the new pdf is returned inside the attachment JSON within 'base64' key. Leave empty to save traffic." } } } ] }