Skip to content

Commit

Permalink
refactor: adopt new and shiny document caster
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Jul 4, 2024
1 parent 0a8d711 commit ae043a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
41 changes: 19 additions & 22 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,28 +1170,25 @@ def set_remarks(self):

self.set("remarks", "\n".join(remarks))

def make_payment_entry(
self,
dt,
dn,
party_amount=None,
bank_account=None,
bank_amount=None,
party_type=None,
payment_type=None,
reference_date=None,
):
def _from_sales_order(self, so):
frappe.flags.new_payment_entry = self
return get_payment_entry(
dt,
dn,
party_amount=None,
bank_account=None,
bank_amount=None,
party_type=None,
payment_type=None,
reference_date=None,
)
return get_payment_entry(so.doctype, so.name)

def _from_sales_invoice(self, si):
frappe.flags.new_payment_entry = self
return get_payment_entry(si.doctype, si.name)

def _from_purchase_order(self, po):
frappe.flags.new_payment_entry = self
return get_payment_entry(po.doctype, po.name)

def _from_purchase_invoice(self, pi):
frappe.flags.new_payment_entry = self
return get_payment_entry(pi.doctype, pi.name)

def _from_dunning(self, d):
frappe.flags.new_payment_entry = self
return get_payment_entry(d.doctype, d.name)

def build_gl_map(self):
if self.payment_type in ("Receive", "Pay") and not self.get("party_account_field"):
Expand Down Expand Up @@ -2413,7 +2410,7 @@ def get_payment_entry(
if doc.doctype in (
"Sales Invoice",
"Purchase Invoice",
"Purchase Order",
"Purchase Orde",
"Sales Order",
) and frappe.get_cached_value(
"Payment Terms Template",
Expand Down
4 changes: 2 additions & 2 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ def cancel_stock_reservation_entries(self, sre_list=None, notify=True) -> None:
voucher_type=self.doctype, voucher_no=self.name, sre_list=sre_list, notify=notify
)

def make_sales_invoice(self, target_doc=None, ignore_permissions=False):
make_sales_invoice(self.name, target_doc, ignore_permissions)
def _into_sales_invoice(self):
make_sales_invoice(self.name)


def get_unreserved_qty(item: object, reserved_qty_details: dict) -> float:
Expand Down

0 comments on commit ae043a0

Please sign in to comment.