feat: allow to create empty pi via email append to

This commit is contained in:
David
2024-09-18 19:22:43 +02:00
parent 256d0208d7
commit 0cab2ae644
5 changed files with 38 additions and 14 deletions

View File

@@ -148,14 +148,16 @@ class AccountsController(TransactionBase):
def ensure_supplier_is_not_blocked(self):
is_supplier_payment = self.doctype == "Payment Entry" and self.party_type == "Supplier"
is_buying_invoice = self.doctype in ["Purchase Invoice", "Purchase Order"]
supplier_name = self.supplier if is_buying_invoice else self.party if is_supplier_payment else None
supplier = None
supplier_name = None
if is_buying_invoice or is_supplier_payment:
supplier_name = self.supplier if is_buying_invoice else self.party
supplier = frappe.get_doc("Supplier", supplier_name)
if supplier_name:
supplier = frappe.get_doc(
"Supplier",
supplier_name,
)
if supplier and supplier_name and supplier.on_hold:
if supplier and supplier.on_hold:
if (is_buying_invoice and supplier.hold_type in ["All", "Invoices"]) or (
is_supplier_payment and supplier.hold_type in ["All", "Payments"]
):
@@ -2177,8 +2179,8 @@ class AccountsController(TransactionBase):
date = self.get("due_date")
due_date = date or posting_date
base_grand_total = self.get("base_rounded_total") or self.base_grand_total
grand_total = self.get("rounded_total") or self.grand_total
base_grand_total = flt(self.get("base_rounded_total") or self.base_grand_total)
grand_total = flt(self.get("rounded_total") or self.grand_total)
automatically_fetch_payment_terms = 0
if self.doctype in ("Sales Invoice", "Purchase Invoice"):
@@ -2252,6 +2254,8 @@ class AccountsController(TransactionBase):
self.ignore_default_payment_terms_template = 1
def get_order_details(self):
if not self.get("items"):
return None, None, None
if self.doctype == "Sales Invoice":
po_or_so = self.get("items")[0].get("sales_order")
po_or_so_doctype = "Sales Order"
@@ -2362,8 +2366,8 @@ class AccountsController(TransactionBase):
total += flt(d.payment_amount, d.precision("payment_amount"))
base_total += flt(d.base_payment_amount, d.precision("base_payment_amount"))
base_grand_total = self.get("base_rounded_total") or self.base_grand_total
grand_total = self.get("rounded_total") or self.grand_total
base_grand_total = flt(self.get("base_rounded_total") or self.base_grand_total)
grand_total = flt(self.get("rounded_total") or self.grand_total)
if self.doctype in ("Sales Invoice", "Purchase Invoice"):
base_grand_total = base_grand_total - flt(self.base_write_off_amount)