Rest API Journal Entry - Error 417 - Both Debit and Credit values cannot be zero

My Request:

POST /api/resource/Journal Entry HTTP/1.1
Host: erp.domain.tld
Authorization: token [[token]]:[[secret]]
Content-Type: application/json
Content-Length: 3056

{
  "naming_series" : "ACC-JV-.YYYY.-",
  "company" : "Company Inc",
  "owner" : "email@company.com",
  "docstatus" : 1,
  "title" : "2022-12 Payroll Payable",
  "voucher_type" : "Journal Entry",
  "posting_date" : "2022-12-31",
  "doctype" : "Journal Entry",
  "total_debit" : 5271.15,
  "total_credit" : 5271.15,
  "accounts" : [ {
    "account" : "2120 - Payroll Payable - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 3963.14,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "5213 - Salary - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 0,
    "debit" : 4703.34,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "Employee FICA Tax - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 359.81,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "Employee Federal Income Tax - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 177.46,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "Employee SUTA Tax - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 2.82,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "Employer FICA Tax - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 359.81,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "Employer FUTA Tax - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 28.22,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "Employer Payroll Tax - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 0,
    "debit" : 567.81,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "Employer SUTA Tax - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 179.78,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "Local Tax Withholding - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 55.72,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  }, {
    "account" : "State Tax Withholding - SI",
    "doctype" : "Journal Entry Account",
    "credit" : 144.39,
    "debit" : 0,
    "docstatus" : 1,
    "owner" : "email@company.com",
    "is_advance" : "No",
    "cost_center" : "Main - SI"
  } ]
}

Below is the response I am getting:

{
    "exc_type": "ValidationError",
    "exception": "frappe.exceptions.ValidationError: Row 1: Both Debit and Credit values cannot be zero",
    "exc": "[\"Traceback (most recent call last):\\n  File \\\"apps/frappe/frappe/app.py\\\", line 69, in application\\n    response = frappe.api.handle()\\n  File \\\"apps/frappe/frappe/api.py\\\", line 138, in handle\\n    doc = frappe.get_doc(data).insert()\\n  File \\\"apps/frappe/frappe/model/document.py\\\", line 258, in insert\\n    self.run_before_save_methods()\\n  File \\\"apps/frappe/frappe/model/document.py\\\", line 1042, in run_before_save_methods\\n    self.run_method(\\\"validate\\\")\\n  File \\\"apps/frappe/frappe/model/document.py\\\", line 908, in run_method\\n    out = Document.hook(fn)(self, *args, **kwargs)\\n  File \\\"apps/frappe/frappe/model/document.py\\\", line 1258, in composer\\n    return composed(self, method, *args, **kwargs)\\n  File \\\"apps/frappe/frappe/model/document.py\\\", line 1240, in runner\\n    add_to_return_value(self, fn(self, *args, **kwargs))\\n  File \\\"apps/frappe/frappe/model/document.py\\\", line 905, in fn\\n    return method_object(*args, **kwargs)\\n  File \\\"apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py\\\", line 53, in validate\\n    self.validate_debit_credit_amount()\\n  File \\\"apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py\\\", line 610, in validate_debit_credit_amount\\n    frappe.throw(_(\\\"Row {0}: Both Debit and Credit values cannot be zero\\\").format(d.idx))\\n  File \\\"apps/frappe/frappe/__init__.py\\\", line 525, in throw\\n    msgprint(\\n  File \\\"apps/frappe/frappe/__init__.py\\\", line 493, in msgprint\\n    _raise_exception()\\n  File \\\"apps/frappe/frappe/__init__.py\\\", line 442, in _raise_exception\\n    raise raise_exception(msg)\\nfrappe.exceptions.ValidationError: Row 1: Both Debit and Credit values cannot be zero\\n\"]",
    "_server_messages": "[\"{\\\"message\\\": \\\"Row 1: Both Debit and Credit values cannot be zero\\\", \\\"title\\\": \\\"Message\\\", \\\"indicator\\\": \\\"red\\\", \\\"raise_exception\\\": 1}\"]"
}

I checked each of the individual Journal Entry Accounts lines and all of them have either a debit or credit values. So I am not sure why I am getting this error.

Any and All help is appreciated.

Thank you in Advance!

Solved it! Need to pass the below two fields for each of the accounts, instead of the debit and credit.

debit_in_account_currency
credit_in_account_currency
1 Like