mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 23:48:38 +00:00
fix(selling): update sales order per billed on credit note submission
(cherry picked from commit 224cf19f33)
This commit is contained in:
@@ -9,6 +9,7 @@ from frappe import _
|
|||||||
from frappe.contacts.doctype.address.address import get_company_address
|
from frappe.contacts.doctype.address.address import get_company_address
|
||||||
from frappe.contacts.doctype.contact.contact import get_default_contact
|
from frappe.contacts.doctype.contact.contact import get_default_contact
|
||||||
from frappe.desk.notifications import clear_doctype_notifications
|
from frappe.desk.notifications import clear_doctype_notifications
|
||||||
|
from frappe.model.document import Document
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.model.utils import get_fetch_values
|
from frappe.model.utils import get_fetch_values
|
||||||
from frappe.query_builder import DocType
|
from frappe.query_builder import DocType
|
||||||
@@ -910,7 +911,9 @@ def get_returned_qty_map(delivery_note):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_sales_invoice(source_name, target_doc=None, args=None):
|
def make_sales_invoice(
|
||||||
|
source_name: str, target_doc: Document | str | None = None, args: dict | str | None = None
|
||||||
|
):
|
||||||
if args is None:
|
if args is None:
|
||||||
args = {}
|
args = {}
|
||||||
if isinstance(args, str):
|
if isinstance(args, str):
|
||||||
@@ -1015,7 +1018,12 @@ def make_sales_invoice(source_name, target_doc=None, args=None):
|
|||||||
frappe.db.get_single_value("Accounts Settings", "automatically_fetch_payment_terms")
|
frappe.db.get_single_value("Accounts Settings", "automatically_fetch_payment_terms")
|
||||||
)
|
)
|
||||||
|
|
||||||
if not doc.is_return:
|
if doc.is_return:
|
||||||
|
# A credit note made from a return Delivery Note should roll back the billed
|
||||||
|
# amount on the linked Sales Order too, so that per_billed stays consistent with
|
||||||
|
# per_delivered (which the return already reset).
|
||||||
|
doc.update_billed_amount_in_sales_order = True
|
||||||
|
else:
|
||||||
so, doctype, fieldname = doc.get_order_details()
|
so, doctype, fieldname = doc.get_order_details()
|
||||||
if (
|
if (
|
||||||
doc.linked_order_has_payment_terms(so, fieldname, doctype)
|
doc.linked_order_has_payment_terms(so, fieldname, doctype)
|
||||||
|
|||||||
Reference in New Issue
Block a user