False positive with ValidationError: Due Date cannot be before Posting / Supplier Invoice Date

Error description

When sending a JSON payload to Frappe API, during the creation of a Sales Invoice, the following error is thrown:

frappe.exceptions.ValidationError: Due Date cannot be before Posting / Supplier Invoice Date

However, the due_date and the posting_date in the payload are the same.

Setup

I don’t currently know how to retrieve the ERPNext version I’m working with.

ERPNext is used as part of a n8n integration. The payload used to work in December 2025, and I don’t think changes to the payload have been made at all.

Payload

This is the payload being sent to the API endpoint:

[
  {
    "naming_series": "ACC-SINV-.YYYY.-",
    "company": "My company",
    "posting_date": "2026-01-17",
    "currency": "EUR",
    "conversion_rate": 1,
    "selling_price_list": "Standard Selling",
    "price_list_currency": "EUR",
    "plc_conversion_rate": 1,
    "items": [
      {
        "item_code": 14617,
        "item_group": "Abbonamenti",
        "stock_uom": "Nos",
        "qty": 1
      }
    ],
    "base_net_total": "47.04",
    "base_grand_total": 49,
    "grand_total": 49,
    "debit_to": "",
    "mepr_name": "si-ch_3SqWDEIsDhbetBxS1XRGOsfn",
    "customer": "alin.bordeianu",
    "customer_fiscal_code": "0",
    "taxes": [
      {
        "docstatus": 1,
        "charge_type": "On Net Total",
        "account_head": "IVA 4% - LI",
        "description": "IVA 4%",
        "included_in_print_rate": true,
        "tax_exemption_reason": "N4-Esenti",
        "included_in_paid_amount": true,
        "cost_center": "Some stuff",
        "rate": 4,
        "account_currency": "EUR",
        "total": "49.00",
        "base_total": "49.00",
        "dont_recompute_tax": false
      }
    ],
    "status": "Paid",
    "payment_schedule": [
      {
        "docstatus": 1,
        "payment_term": "Immediate",
        "due_date": "2026-01-17",
        "mode_of_payment": "Mode of payment",
        "invoice_portion": 100,
        "discount_type": "Percentage",
        "discount": 0,
        "payment_amount": "49.00",
        "outstanding": 0,
        "paid_amount": "49.00",
        "discounted_amount": 0,
        "base_payment_amount": "49.00"
      }
    ],
    "docstatus": 1
  }
]

As you can see, posting_date is ”2026-01-17”, and payment_schedule[0].due_date is the exact same value.

Stack trace

This is what the API responds with:
417 - “{\“exc_type\”:\“ValidationError\”,\“exception\”:\“frappe.exceptions.ValidationError: Due Date cannot be before Posting / Supplier Invoice Date\”,\“exc\”:\”[\\\“Traceback (most recent call last):\\\\n File \\\\\\\“apps/frappe/frappe/app.py\\\\\\\”, line 103, in application\\\\n response = frappe.api.handle()\\\\n File \\\\\\\“apps/frappe/frappe/api.py\\\\\\\”, line 143, in handle\\\\n doc = frappe.get_doc(data).insert()\\\\n File \\\\\\\“apps/frappe/frappe/model/document.py\\\\\\\”, line 279, in insert\\\\n self.run_before_save_methods()\\\\n File \\\\\\\“apps/frappe/frappe/model/document.py\\\\\\\”, line 1078, in run_before_save_methods\\\\n self.run_method(\\\\\\\“validate\\\\\\\”)\\\\n File \\\\\\\“apps/frappe/frappe/model/document.py\\\\\\\”, line 945, in run_method\\\\n out = Document.hook(fn)(self, *args, **kwargs)\\\\n File \\\\\\\“apps/frappe/frappe/model/document.py\\\\\\\”, line 1297, in composer\\\\n return composed(self, method, *args, **kwargs)\\\\n File \\\\\\\“apps/frappe/frappe/model/document.py\\\\\\\”, line 1279, in runner\\\\n add_to_return_value(self, fn(self, *args, **kwargs))\\\\n File \\\\\\\“apps/frappe/frappe/model/document.py\\\\\\\”, line 942, in fn\\\\n return method_object(*args, **kwargs)\\\\n File \\\\\\\“apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py\\\\\\\”, line 95, in validate\\\\n super().validate()\\\\n File \\\\\\\“apps/erpnext/erpnext/controllers/selling_controller.py\\\\\\\”, line 32, in validate\\\\n super().validate()\\\\n File \\\\\\\“apps/erpnext/erpnext/controllers/stock_controller.py\\\\\\\”, line 44, in validate\\\\n super().validate()\\\\n File \\\\\\\“apps/erpnext/erpnext/controllers/accounts_controller.py\\\\\\\”, line 238, in validate\\\\n self.validate_all_documents_schedule()\\\\n File \\\\\\\“apps/erpnext/erpnext/controllers/accounts_controller.py\\\\\\\”, line 509, in validate_all_documents_schedule\\\\n self.validate_invoice_documents_schedule()\\\\n File \\\\\\\“apps/erpnext/erpnext/controllers/accounts_controller.py\\\\\\\”, line 499, in validate_invoice_documents_schedule\\\\n self.validate_due_date()\\\\n File \\\\\\\“apps/erpnext/erpnext/controllers/accounts_controller.py\\\\\\\”, line 681, in validate_due_date\\\\n validate_due_date(\\\\n File \\\\\\\“apps/erpnext/erpnext/accounts/party.py\\\\\\\”, line 604, in validate_due_date\\\\n frappe.throw(_(\\\\\\\“Due Date cannot be before Posting / Supplier Invoice Date\\\\\\\”))\\\\n File \\\\\\\“apps/frappe/frappe/_init_.py\\\\\\\”, line 551, in throw\\\\n msgprint(\\\\n File \\\\\\\“apps/frappe/frappe/_init_.py\\\\\\\”, line 512, in msgprint\\\\n _raise_exception()\\\\n File \\\\\\\“apps/frappe/frappe/_init_.py\\\\\\\”, line 455, in _raise_exception\\\\n raise raise_exception(msg)\\\\nfrappe.exceptions.ValidationError: Due Date cannot be before Posting / Supplier Invoice Date\\\\n\\\”]\“,\”_server_messages\“:\”[\\\“{\\\\\\\“message\\\\\\\”: \\\\\\\“Due Date cannot be before Posting / Supplier Invoice Date\\\\\\\”, \\\\\\\“title\\\\\\\”: \\\\\\\“Message\\\\\\\”, \\\\\\\“indicator\\\\\\\”: \\\\\\\“red\\\\\\\”, \\\\\\\“raise_exception\\\\\\\”: 1}\\\”]\“}”

Your ERPNext Version you can see by clicking “Help” → “About” on the top right of the UI (at least with V15).

Version is 14.92.3, and I’m running the Docker installation. Is support for this version discontinued?

Yes, V14 is EOL for 11 days.

Turns out the solution was to set the flag set_posting_time to 1 in the request for a Sales Invoice creation. This successfully avoids other mismatches. Thank you anyway for pointing me to the latest version!