crm.invoice.add
Scope: catalog Permissions to execute: for all
crm.invoice.add(fields)
Creates new invoice. When buyer/seller requisite details must be included into the invoice (because a company can have several), use the method crm.requisite.link.register.
The created invoice must contain buyer and seller companies:
UF_COMPANY_ID
, in case of buyer - a company, or UF_CONTACT_ID
, when buyer - a contact.
UF_MYCOMPANY_ID
- seller.
The identifiers, specified in the crm.requisite.link.register and in the created invoice must match to buyer and seller.
Parameters
Parameter | Description |
---|---|
fields | Set of fields - is an array (“updated field"=>”value”[, ...]), containing values of the invoice fields.
Note: to find out the required field format, execute the method crm.invoice.fields to view the retrieved field format.
|
Example 1
var current = new Date(); var nextMonth = new Date(); nextMonth.setMonth(current.getMonth() + 1); var date2str = function(d) { return d.getFullYear() + '-' + paddatepart(1 + d.getMonth()) + '-' + paddatepart(d.getDate()) + 'T' + paddatepart(d.getHours()) + ':' + paddatepart(d.getMinutes()) + ':' + paddatepart(d.getSeconds()) + '+03:00'; }; var paddatepart = function(part) { return part >= 10 ? part.toString() : '0' + part.toString(); }; BX24.callMethod( "crm.invoice.add", { "fields": { "ORDER_TOPIC": "Invoice for a legal entity", "STATUS_ID": "P", "DATE_INSERT": date2str(current), "PAY_VOUCHER_DATE": date2str(current), "PAY_VOUCHER_NUM": "876", "DATE_MARKED": date2str(current), "REASON_MARKED": "Paid immediately.", "COMMENTS": "comment", "USER_DESCRIPTION": "client comments", "DATE_BILL": date2str(current), "DATE_PAY_BEFORE": date2str(nextMonth), "RESPONSIBLE_ID": 1, "UF_DEAL_ID": 10, "UF_COMPANY_ID": 5, "UF_CONTACT_ID": 2, "PERSON_TYPE_ID": 2, "PAY_SYSTEM_ID": 6, "INVOICE_PROPERTIES": { "COMPANY": "Advanced Technology LLC", // Company name "COMPANY_ADR": "687, New Broadway, London, A5 2XA", // Legal address "REG_ID": "17863734634", // Company registration number "CONTACT_PERSON": "Jhon Smith", // Contact person "EMAIL": "pr@logistics-north.com", // E-Mail "PHONE": "8 (495) 234-54-32", // Phone "FAX": "", // Fax "ZIP": "", // Postal code "CITY": "", // City "LOCATION": "", // Location "ADDRESS": "" // Delivery address }, "PRODUCT_ROWS": [ {"ID": 0, "PRODUCT_ID": 438, "PRODUCT_NAME": "Product 01", "QUANTITY": 1, "PRICE": 100}, {"ID": 0, "PRODUCT_ID": 515, "PRODUCT_NAME": "Product 77", "QUANTITY": 1, "PRICE": 118} ] } }, function(result) { if(result.error()) console.error(result.error()); else console.info("Invoice ID = " + result.data() + " has been created."); } );
Example 2
var current = new Date(); var nextMonth = new Date(); nextMonth.setMonth(current.getMonth() + 1); var date2str = function(d) { return d.getFullYear() + '-' + paddatepart(1 + d.getMonth()) + '-' + paddatepart(d.getDate()) + 'T' + paddatepart(d.getHours()) + ':' + paddatepart(d.getMinutes()) + ':' + paddatepart(d.getSeconds()) + '+03:00'; }; var paddatepart = function(part) { return part >= 10 ? part.toString() : '0' + part.toString(); }; BX24.callMethod( "crm.invoice.add", { "fields": { "ORDER_TOPIC": "Invoice for a private individual", "STATUS_ID": "P", "DATE_INSERT": date2str(current), "PAY_VOUCHER_DATE": date2str(current), "PAY_VOUCHER_NUM": "876", "DATE_MARKED": date2str(current), "REASON_MARKED": "paid", "COMMENTS": "comment", "USER_DESCRIPTION": "client comments", "DATE_BILL": date2str(current), "DATE_PAY_BEFORE": date2str(nextMonth), "RESPONSIBLE_ID": 1, "UF_DEAL_ID": 8, "UF_COMPANY_ID": 0, "UF_CONTACT_ID": 3, "PERSON_TYPE_ID": 1, "PAY_SYSTEM_ID": 6, "INVOICE_PROPERTIES": { "FIO": "John Smith", // full name "EMAIL": "boss@yt-soft.net", // E-Mail "PHONE": "", // phone "ZIP": "", // postal code "CITY": "", // city "LOCATION": "", // location "ADDRESS": "" // delivery address }, "PRODUCT_ROWS": [ {"ID": 0, "PRODUCT_ID": 438, "PRODUCT_NAME": "Product 01", "QUANTITY": 1, "PRICE": 100}, {"ID": 0, "PRODUCT_ID": 515, "PRODUCT_NAME": "Product 77", "QUANTITY": 1, "PRICE": 118} ] } }, function(result) { if(result.error()) console.error(result.error()); else console.info("Invoice ID = " + result.data() + " has been created."); } );
© «Bitrix24», 2001-2024