Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/frappe/erpnext/llms.txt

Use this file to discover all available pages before exploring further.

Accounts Module API

The Accounts module provides comprehensive financial management APIs for handling payments, invoices, journal entries, and accounting operations.

Payment Entry APIs

get_payment_entry

Create a payment entry document against various transaction types like invoices, orders, and expenses.
import frappe

# Create payment entry from Sales Invoice
payment_entry = frappe.call(
    "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry",
    dt="Sales Invoice",
    dn="SINV-0001",
    party_amount=1000,
    bank_account="Cash - C"
)
dt
string
required
Document type (e.g., “Sales Invoice”, “Purchase Invoice”, “Sales Order”, “Purchase Order”)
dn
string
required
Document name/ID
party_amount
float
default:"null"
Amount to be paid/received
bank_account
string
default:"null"
Bank or cash account for the transaction
bank_amount
float
default:"null"
Amount in bank account currency
party_type
string
default:"null"
Party type: “Customer” or “Supplier”
payment_type
string
default:"null"
Payment type: “Receive”, “Pay”, or “Internal Transfer”
reference_date
date
default:"null"
Reference date for payment
payment_entry
dict
A new Payment Entry document with pre-filled values
  • payment_type: Type of payment (Receive/Pay/Internal Transfer)
  • company: Company name
  • posting_date: Payment posting date
  • paid_from: Source account
  • paid_to: Destination account
  • paid_amount: Amount to be paid
  • received_amount: Amount to be received
  • references: List of reference documents

General Ledger APIs

get_balance_on

Get the balance of an account on a specific date with optional filters for party, cost center, and finance book.
frappe.call(
    "erpnext.accounts.utils.get_balance_on",
    account="Debtors - C",
    date="2024-03-31",
    party_type="Customer",
    party="CUST-0001",
    company="Company A"
)
account
string
default:"null"
Account name
date
date
default:"null"
Date for balance calculation
party_type
string
default:"null"
Party type: “Customer”, “Supplier”, “Employee”
party
string
default:"null"
Party name
company
string
default:"null"
Company name
in_account_currency
bool
default:"true"
Return balance in account currency
cost_center
string
default:"null"
Cost center for filtering
finance_book
string
default:"null"
Finance book for filtering
balance
float
Account balance as of the specified date

Fiscal Year APIs

get_fiscal_year

Retrieve fiscal year information for a given date and company.
fiscal_year = frappe.call(
    "erpnext.accounts.utils.get_fiscal_year",
    date="2024-03-15",
    company="Company A"
)
# Returns: ("2023-2024", "2023-04-01", "2024-03-31")
date
date
default:"null"
Transaction date
fiscal_year
string
default:"null"
Fiscal year name
company
string
default:"null"
Company name
as_dict
bool
default:"false"
Return as dictionary instead of tuple
fiscal_year
tuple
Returns tuple: (fiscal_year_name, year_start_date, year_end_date)

Outstanding Invoices

get_outstanding_invoices

Get list of outstanding invoices for a party with optional filters.
invoices = frappe.call(
    "erpnext.accounts.utils.get_outstanding_invoices",
    party_type="Customer",
    party="CUST-0001",
    account=["Debtors - C"],
    posting_date="2024-03-31"
)
party_type
string
required
Party type: “Customer” or “Supplier”
party
string
required
Party name
account
list
required
List of account names
posting_date
date
default:"null"
Filter invoices up to this date
min_outstanding
float
default:"null"
Minimum outstanding amount
max_outstanding
float
default:"null"
Maximum outstanding amount
invoices
list
List of outstanding invoice details
  • voucher_no: Invoice number
  • voucher_type: Document type
  • posting_date: Invoice date
  • invoice_amount: Total invoice amount
  • outstanding_amount: Pending amount
  • due_date: Payment due date
  • currency: Invoice currency

Account Management

get_account_currency

Get the currency of an account.
currency = frappe.call(
    "erpnext.accounts.doctype.account.account.get_account_currency",
    account="Cash - USD - C"
)
# Returns: "USD"
account
string
required
Account name
currency
string
Currency code of the account

get_children

Get child accounts for tree view navigation.
accounts = frappe.call(
    "erpnext.accounts.utils.get_children",
    doctype="Account",
    parent="Assets - C",
    company="Company A",
    is_root=False
)
doctype
string
required
Document type: “Account” or “Cost Center”
parent
string
required
Parent account name
company
string
required
Company name
is_root
bool
default:"false"
Whether fetching root level accounts
accounts
list
List of child accounts with hierarchy information

Reconciliation APIs

reconcile_against_document

Reconcile payment entries against invoices or other documents.
frappe.call(
    "erpnext.accounts.utils.reconcile_against_document",
    args=[{
        "voucher_type": "Payment Entry",
        "voucher_no": "PAY-0001",
        "against_voucher_type": "Sales Invoice",
        "against_voucher": "SINV-0001",
        "allocated_amount": 1000,
        "account": "Debtors - C",
        "party_type": "Customer",
        "party": "CUST-0001"
    }]
)
args
list
required
List of reconciliation entries
result
null
Updates the payment entry and linked documents

Company Defaults

get_company_default

Get default value for a company field.
default_account = frappe.call(
    "erpnext.accounts.utils.get_company_default",
    company="Company A",
    fieldname="default_cash_account"
)
company
string
required
Company name
fieldname
string
required
Field name from Company doctype
value
string
Default value for the specified field

Usage Examples

Creating a Payment Entry

import frappe

# Get payment entry template
payment = frappe.get_doc(
    frappe.call(
        "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry",
        dt="Sales Invoice",
        dn="SINV-00001",
        party_amount=5000
    )
)

# Modify if needed
payment.reference_no = "CHQ-12345"
payment.reference_date = "2024-03-15"

# Save and submit
payment.insert()
payment.submit()

Checking Account Balance

import frappe
from frappe.utils import nowdate

# Get current balance
balance = frappe.call(
    "erpnext.accounts.utils.get_balance_on",
    account="Cash - C",
    date=nowdate(),
    company="Company A"
)

print(f"Current Cash Balance: {balance}")

Getting Outstanding Invoices

import frappe

# Get all outstanding invoices for a customer
outstanding = frappe.call(
    "erpnext.accounts.utils.get_outstanding_invoices",
    party_type="Customer",
    party="CUST-00001",
    account=["Debtors - C"]
)

for invoice in outstanding:
    print(f"Invoice: {invoice['voucher_no']}, Outstanding: {invoice['outstanding_amount']}")

Build docs developers (and LLMs) love