This library let you call REST API of erpnext.
var ERPNext = require('node-erpnext');
var erpnext = new ERPNext({
username : 'username',
password : 'password',
baseUrl : 'http://localhost:8000'
})
$ npm install node-erpnext
Get list of customers
erpnext.getCustomers().then(function(customers){
console.log(customers);
})
Get customer's name list.
erpnext.getCustomersName().then(function(customers){
console.log(customers);
})
Get customer's info by customer name
erpnext.getCustomerByName('ram').then(function(customer){
console.log(customer);
})
Create customer for parameters follow this.
erpnext.createCustomer({
"naming_series": "CUST-",
"customer_group": "Commercial",
"doctype": "Customer",
"communications": [],
"customer_type": "Company",
"accounts": [],
"docstatus": 0,
"territory": "India",
"sales_team": [],
"customer_name": "ram"
})
update customer by name. for parameters follow this.
erpnext.updateCustomerByName('ram',{
"customer_name": "shyam",
})
Create a new customer group. For parameters follow this.
erpnext.createCustomerGroup({
'customer_group_name' : 'new Group',
'parent_customer_group': 'All Customer Groups',
'is_group': 'No'
})
update an existing customer group by group name. For parameters follow this.
erpnext.updateCustomerGroupByName('new Group',{
'customer_group_name' : 'new group',
'parent_customer_group': 'All Customer Groups',
'is_group': 'No'
})
Get list of customer groups.
erpnext.getCustomerGroups().then(function(customerGroups){
console.log(customerGroups);
})
Get customer group's name list.
erpnext.getCustomerGroupsName().then(function(customerGroups){
console.log(customerGroups);
})
Get customer group's info by group name
erpnext.getCustomerGroupByName('new Group').then(function(customerGroups){
console.log(customerGroups);
})
Create a Sales Order. For parameters follow this.
erpnext.createSalesOrder({
"status": "Draft",
"naming_series": "SO-",
"currency": "INR",
"billing_status": "Not Billed",
"order_type": "Sales",
"transaction_date": "2017-05-10",
"territory": "India",
"delivery_status": "Not Delivered",
"customer": "Camelport Internal",
"items": [
{
"qty": 5,
"rate": 2000,
"stock_uom": "Nos",
"item_code": "i01",
"parentfield": "items"
}
],
"delivery_date": "2017-05-18",
"sales_team": []
})
update an existing sales order by sales order name. For parameters follow this.
erpnext.updateSalesOrderByName('SO-00003',{
"status": "Submitted",
"docstatus" : 1
})
Get list of sales order.
erpnext.getSalesOrder().then(function(salesOrder){
console.log(salesOrder);
})
Get sales order's name list.
erpnext.getSalesOrdersName().then(function(salesOrder){
console.log(salesOrder);
})
Get sales order's info by order name
erpnext.getSalesOrderByName('new Group').then(function(customer){
console.log(customer);
})
Create an Item. For param follow https://frappe.github.io/erpnext/current/models/accounts/sales_invoice_item.
erpnext.createAnItem({
"has_variants": 0,
"is_stock_item": "No",
"valuation_method": "",
"min_order_qty": 0,
"is_asset_item": "No",
"has_batch_no": "No",
"has_serial_no": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"inspection_required": "No",
"item_code": "item code",
"item_name": "item name",
"description": "description",
"item_group": "Services"
})
Update an Item. For param follow https://frappe.github.io/erpnext/current/models/selling/sales_order
erpnext.updateItemByName("item code",{
"has_variants": 0,
"is_stock_item": "No",
"valuation_method": "",
"min_order_qty": 0,
"is_asset_item": "No",
"has_batch_no": "No",
"has_serial_no": "No",
"is_purchase_item": "Yes",
"is_sales_item": "Yes",
"is_service_item": "No",
"inspection_required": "No",
"item_code": "item code",
"item_name": "item name",
"description": "description",
"item_group": "Services"
})
Create a Supplier. For param follow https://frappe.github.io/erpnext/current/models/buying/supplier.
erpnext.createSupplier({"supplier_type":"Services","supplier_name":"ram"});
Update Supplier. For param follow https://frappe.github.io/erpnext/current/models/buying/supplier.
erpnext.updateSupplierByName("ram",{
"supplier_type":"Services",
"supplier_name":"ram"
})
Create a Purchase Invoice For param follow https://frappe.github.io/erpnext/current/models/accounts/purchase_invoice
erpnext.createPurchaseInvoice({
"supplier": "ram",
"items": [{
"item_code": "item code",
"qty": 4,
"price_list_rate": 5000,
"schedule_date": "2017-05-31"
}]
})
Update Purchase Invoice. For param follow https://frappe.github.io/erpnext/current/models/accounts/purchase_invoice.
erpnext.updatePurchaseInvoiceByName("name",{
"supplier": "ram"
})
Create a Sales Invoice. For param follow https://frappe.github.io/erpnext/current/models/accounts/sales_invoice
erpnext.createSalesInvoice(
{
"due_date": "2017-05-14",
"customer": "ram",
"items":[{
"item_code": "item code",
"rate": 15000,
"qty": 3
}]
}
)
Update Sales Invoice. For param follow https://frappe.github.io/erpnext/current/models/accounts/sales_invoice
erpnext.updateSalesInvoiceByName(
"Sales Invoice",
{
"due_date": "2017-05-14",
"customer": "ram",
"items":[{
"item_code": "item code",
"rate": 15000,
"qty": 3
}]
}
)
Create a Purchase Order. For param follow https://frappe.github.io/erpnext/current/models/buying/purchase_order
erpnext.createPurchaseOrder({
"supplier": "ram",
"items": [{
"item_code": "item code",
"qty": 4,
"price_list_rate": 5000,
"schedule_date": "2017-05-31"
}
]
})
Update Purchase Order. For param follow https://frappe.github.io/erpnext/current/models/buying/purchase_order
erpnext.updatePurchaseOrderByName("name",{
"supplier": "ram",
"items": [{
"item_code": "item code",
"qty": 4,
"price_list_rate": 5000,
"schedule_date": "2017-05-31"
}
]
})