# ERPNext

> Manage customers, suppliers, inventory, sales, purchases and HR in ERPNext, the open-source ERP system.

App · Accounting & Finance · 18 actions. Web page: https://docs.lodol.com/docs/integrations/erpnext

## Actions

### Create customer

Create a new customer in ERPNext.

**Inputs**

- Customer name (`customer_name`, text, required): The customer's name.
- Customer type (`customer_type`, text, required): Either 'Individual' or 'Company'. One of: `Individual`, `Company`.
- Email (`email`, text): The customer's email address.
- Phone (`phone`, text): The customer's mobile number.

**Outputs**

- `customer` (object): The created customer record

**Example output**

```json
{
  "customer": {
    "name": "example_value"
  }
}
```

### Create employee

Create a new employee record.

**Inputs**

- Employee name (`employee_name`, text, required): The employee's first name.
- Gender (`gender`, text, required): A Gender record in ERPNext, e.g. 'Male' or 'Female'.
- Date of birth (`date_of_birth`, date, required): The employee's date of birth.
- Date of joining (`date_of_joining`, date): The employee's start date.

**Outputs**

- `employee` (object): The created employee record

**Example output**

```json
{
  "employee": {
    "name": "example_value"
  }
}
```

### Create expense claim

Create an employee expense claim.

**Inputs**

- Employee (`employee`, text, required): The employee's ERPNext document name.
- Posting date (`posting_date`, date): The date the claim is posted. Defaults to today.
- Expenses (`expenses`, list, required): The claim's expense lines; at least one is required. Each entry needs 'expense_type' (an Expense Claim Type, e.g. 'Travel') and 'amount', and may include 'sanctioned_amount', 'expense_date', 'description' and 'default_account' (needed when the expense type has no default account for the employee's company).
- Expense approver (`expense_approver`, text): The user who approves the claim. Defaults to the employee's expense approver, or the connected ERPNext user.

**Outputs**

- `expense_claim` (object): The created expense claim

**Example output**

```json
{
  "expense_claim": {}
}
```

### Create item

Create a new inventory item.

**Inputs**

- Item code (`item_code`, text, required): A unique code identifying the item.
- Item name (`item_name`, text, required): The item's display name.
- Item group (`item_group`, text): The item group this item belongs to. Defaults to 'All Item Groups'.
- Track stock (`is_stock_item`, true/false): Whether ERPNext tracks inventory for this item. Stock items need a warehouse on every order; turn this off for services. Defaults to ERPNext's own setting (tracked).

**Outputs**

- `item` (object): The created item record

**Example output**

```json
{
  "item": {}
}
```

### Create leave application

Submit a leave application for an employee.

**Inputs**

- Employee (`employee`, text, required): The employee's ERPNext document name.
- From date (`from_date`, date, required): The first day of leave.
- To date (`to_date`, date, required): The last day of leave.
- Leave type (`leave_type`, text, required): The type of leave, e.g. 'Casual Leave'. Every type except 'Leave Without Pay' needs a Leave Allocation covering the dates.
- Leave approver (`leave_approver`, text): The user who approves the leave. Defaults to the employee's leave approver, or the connected ERPNext user.

**Outputs**

- `leave_application` (object): The created leave application

**Example output**

```json
{
  "leave_application": {}
}
```

### Create purchase invoice

Create a draft purchase invoice from a supplier.

**Inputs**

- Supplier (`supplier`, text, required): The supplier's ERPNext document name.
- Items (`items`, list, required): The document's line items; at least one is required. Each entry needs 'item_code' and 'qty', and may include 'rate', 'warehouse', and a per-line 'delivery_date' (sales orders) or 'schedule_date' (purchase orders).
- Posting date (`posting_date`, date): The date the invoice is posted.

**Outputs**

- `purchase_invoice` (object): The created purchase invoice

**Example output**

```json
{
  "purchase_invoice": {}
}
```

### Create purchase order

Create a new purchase order for a supplier.

**Inputs**

- Supplier (`supplier`, text, required): The supplier's ERPNext document name.
- Items (`items`, list, required): The document's line items; at least one is required. Each entry needs 'item_code' and 'qty', and may include 'rate', 'warehouse', and a per-line 'delivery_date' (sales orders) or 'schedule_date' (purchase orders).
- Order date (`transaction_date`, date): The date the order was placed. Defaults to today.
- Required by (`schedule_date`, date): The date the goods are needed. Defaults to the order date.
- Target warehouse (`warehouse`, text): The warehouse every line is received into unless it names its own. Needed for stock items when the site has no default warehouse.

**Outputs**

- `purchase_order` (object): The created purchase order

**Example output**

```json
{
  "purchase_order": {}
}
```

### Create sales invoice

Create a draft sales invoice for a customer.

**Inputs**

- Customer (`customer`, text, required): The customer's ERPNext document name.
- Items (`items`, list, required): The document's line items; at least one is required. Each entry needs 'item_code' and 'qty', and may include 'rate', 'warehouse', and a per-line 'delivery_date' (sales orders) or 'schedule_date' (purchase orders).
- Posting date (`posting_date`, date): The date the invoice is posted.
- Due date (`due_date`, date): The date payment is due.

**Outputs**

- `sales_invoice` (object): The created sales invoice

**Example output**

```json
{
  "sales_invoice": {
    "name": "example_value"
  }
}
```

### Create sales order

Create a new sales order for a customer.

**Inputs**

- Customer (`customer`, text, required): The customer's ERPNext document name.
- Items (`items`, list, required): The document's line items; at least one is required. Each entry needs 'item_code' and 'qty', and may include 'rate', 'warehouse', and a per-line 'delivery_date' (sales orders) or 'schedule_date' (purchase orders).
- Order date (`transaction_date`, date): The date the order was placed.
- Delivery date (`delivery_date`, date): The date the order is expected to be delivered.
- Source warehouse (`warehouse`, text): The warehouse every line ships from unless it names its own. Needed for stock items when the site has no default warehouse.

**Outputs**

- `sales_order` (object): The created sales order

**Example output**

```json
{
  "sales_order": {
    "name": "example_value"
  }
}
```

### Get customer

Retrieve a specific customer by name (ERPNext's document id).

**Inputs**

- Customer (`customer_name`, text, required): The customer's ERPNext document name.

**Outputs**

- `customer` (object): The customer record

**Example output**

```json
{
  "customer": {}
}
```

### Get invoice

Retrieve a specific sales invoice by name.

**Inputs**

- Invoice (`invoice_name`, text, required): The sales invoice's ERPNext document name.

**Outputs**

- `invoice` (object): The sales invoice

**Example output**

```json
{
  "invoice": {}
}
```

### Get sales order

Retrieve a specific sales order by name.

**Inputs**

- Sales order (`order_name`, text, required): The sales order's ERPNext document name.

**Outputs**

- `sales_order` (object): The sales order

**Example output**

```json
{
  "sales_order": {}
}
```

### List customers

Fetch a list of customers from ERPNext.

**Inputs**

- Limit (`limit`, number): Maximum number of customers to return. From 1 to 500. Default: `10`.
- Offset (`offset`, number): Number of customers to skip before the first one returned. At least 0. Default: `0`.

**Outputs**

- `count` (number): Customers returned
- `customers` (list): Customer records

**Example output**

```json
{
  "count": 1,
  "customers": []
}
```

### List employees

Fetch a list of employees from ERPNext.

**Inputs**

- Limit (`limit`, number): Maximum number of employees to return. From 1 to 500. Default: `10`.

**Outputs**

- `count` (number): Employees returned
- `employees` (list): Employee records

**Example output**

```json
{
  "count": 1,
  "employees": []
}
```

### List invoices

Fetch a list of sales invoices from ERPNext.

**Inputs**

- Limit (`limit`, number): Maximum number of invoices to return. From 1 to 500. Default: `10`.

**Outputs**

- `count` (number): Invoices returned
- `invoices` (list): Sales invoice records

**Example output**

```json
{
  "count": 1,
  "invoices": []
}
```

### List items

Fetch a list of inventory items from ERPNext.

**Inputs**

- Limit (`limit`, number): Maximum number of items to return. From 1 to 500. Default: `10`.

**Outputs**

- `count` (number): Items returned
- `items` (list): Item records

**Example output**

```json
{
  "count": 1,
  "items": []
}
```

### List suppliers

Fetch a list of suppliers from ERPNext.

**Inputs**

- Limit (`limit`, number): Maximum number of suppliers to return. From 1 to 500. Default: `10`.

**Outputs**

- `count` (number): Suppliers returned
- `suppliers` (list): Supplier records

**Example output**

```json
{
  "count": 1,
  "suppliers": []
}
```

### Update customer

Update an existing customer's email or phone.

**Inputs**

- Customer (`customer_name`, text, required): The customer's ERPNext document name.
- Email (`email`, text): The customer's email address.
- Phone (`phone`, text): The customer's mobile number.

**Outputs**

- `customer` (object): The updated customer record

**Example output**

```json
{
  "customer": {}
}
```
