refactor: use DocStatus (#33594)
This commit is contained in:
parent
906ad10d16
commit
67cf7e1728
@ -27,7 +27,7 @@ def start_payment_ledger_repost(docname=None):
|
|||||||
"""
|
"""
|
||||||
if docname:
|
if docname:
|
||||||
repost_doc = frappe.get_doc("Repost Payment Ledger", docname)
|
repost_doc = frappe.get_doc("Repost Payment Ledger", docname)
|
||||||
if repost_doc.docstatus == 1 and repost_doc.repost_status in ["Queued", "Failed"]:
|
if repost_doc.docstatus.is_submitted() and repost_doc.repost_status in ["Queued", "Failed"]:
|
||||||
try:
|
try:
|
||||||
for entry in repost_doc.repost_vouchers:
|
for entry in repost_doc.repost_vouchers:
|
||||||
doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
|
doc = frappe.get_doc(entry.voucher_type, entry.voucher_no)
|
||||||
|
@ -37,7 +37,7 @@ def validate_return_against(doc):
|
|||||||
if (
|
if (
|
||||||
ref_doc.company == doc.company
|
ref_doc.company == doc.company
|
||||||
and ref_doc.get(party_type) == doc.get(party_type)
|
and ref_doc.get(party_type) == doc.get(party_type)
|
||||||
and ref_doc.docstatus == 1
|
and ref_doc.docstatus.is_submitted()
|
||||||
):
|
):
|
||||||
# validate posting date time
|
# validate posting date time
|
||||||
return_posting_datetime = "%s %s" % (doc.posting_date, doc.get("posting_time") or "00:00:00")
|
return_posting_datetime = "%s %s" % (doc.posting_date, doc.get("posting_time") or "00:00:00")
|
||||||
|
@ -6,6 +6,7 @@ import json
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _, scrub
|
||||||
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cint, flt, round_based_on_smallest_currency_fraction
|
from frappe.utils import cint, flt, round_based_on_smallest_currency_fraction
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
@ -20,7 +21,7 @@ from erpnext.stock.get_item_details import _get_item_tax_template
|
|||||||
|
|
||||||
|
|
||||||
class calculate_taxes_and_totals(object):
|
class calculate_taxes_and_totals(object):
|
||||||
def __init__(self, doc):
|
def __init__(self, doc: Document):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
frappe.flags.round_off_applicable_accounts = []
|
frappe.flags.round_off_applicable_accounts = []
|
||||||
get_round_off_applicable_accounts(self.doc.company, frappe.flags.round_off_applicable_accounts)
|
get_round_off_applicable_accounts(self.doc.company, frappe.flags.round_off_applicable_accounts)
|
||||||
@ -677,7 +678,7 @@ class calculate_taxes_and_totals(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def calculate_total_advance(self):
|
def calculate_total_advance(self):
|
||||||
if self.doc.docstatus < 2:
|
if not self.doc.docstatus.is_cancelled():
|
||||||
total_allocated_amount = sum(
|
total_allocated_amount = sum(
|
||||||
flt(adv.allocated_amount, adv.precision("allocated_amount"))
|
flt(adv.allocated_amount, adv.precision("allocated_amount"))
|
||||||
for adv in self.doc.get("advances")
|
for adv in self.doc.get("advances")
|
||||||
@ -708,7 +709,7 @@ class calculate_taxes_and_totals(object):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.doc.docstatus == 0:
|
if self.doc.docstatus.is_draft():
|
||||||
if self.doc.get("write_off_outstanding_amount_automatically"):
|
if self.doc.get("write_off_outstanding_amount_automatically"):
|
||||||
self.doc.write_off_amount = 0
|
self.doc.write_off_amount = 0
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ class SalesOrder(SellingController):
|
|||||||
for quotation in set(d.prevdoc_docname for d in self.get("items")):
|
for quotation in set(d.prevdoc_docname for d in self.get("items")):
|
||||||
if quotation:
|
if quotation:
|
||||||
doc = frappe.get_doc("Quotation", quotation)
|
doc = frappe.get_doc("Quotation", quotation)
|
||||||
if doc.docstatus == 2:
|
if doc.docstatus.is_cancelled():
|
||||||
frappe.throw(_("Quotation {0} is cancelled").format(quotation))
|
frappe.throw(_("Quotation {0} is cancelled").format(quotation))
|
||||||
|
|
||||||
doc.set_status(update=True)
|
doc.set_status(update=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user