mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 23:48:38 +00:00
refactor(sales_invoice): drop loyalty delegation shims, call LoyaltyService directly
The make_/delete_/apply_loyalty_points methods on SalesInvoice only existed as an inheritance surface for POSInvoice (self.X()). Route all callers through LoyaltyService(doc).X() directly, consistent with how related-doc cases already worked, and remove the three forwarding methods.
This commit is contained in:
@@ -17,6 +17,7 @@ from erpnext.accounts.doctype.sales_invoice.sales_invoice import (
|
||||
get_mode_of_payment_info,
|
||||
update_multi_mode_option,
|
||||
)
|
||||
from erpnext.accounts.doctype.sales_invoice.services.loyalty import LoyaltyService
|
||||
from erpnext.accounts.party import get_due_date, get_party_account
|
||||
from erpnext.controllers.queries import item_query as _item_query
|
||||
from erpnext.controllers.sales_and_purchase_return import get_sales_invoice_item_from_consolidated_invoice
|
||||
@@ -241,13 +242,13 @@ class POSInvoice(SalesInvoice):
|
||||
def on_submit(self):
|
||||
# create the loyalty point ledger entry if the customer is enrolled in any loyalty program
|
||||
if not self.is_return and self.loyalty_program:
|
||||
self.make_loyalty_point_entry()
|
||||
LoyaltyService(self).make_loyalty_point_entry()
|
||||
elif self.is_return and self.return_against and self.loyalty_program:
|
||||
against_psi_doc = frappe.get_doc("POS Invoice", self.return_against)
|
||||
against_psi_doc.delete_loyalty_point_entry()
|
||||
against_psi_doc.make_loyalty_point_entry()
|
||||
LoyaltyService(against_psi_doc).delete_loyalty_point_entry()
|
||||
LoyaltyService(against_psi_doc).make_loyalty_point_entry()
|
||||
if self.redeem_loyalty_points and self.loyalty_points:
|
||||
self.apply_loyalty_points()
|
||||
LoyaltyService(self).apply_loyalty_points()
|
||||
self.check_phone_payments()
|
||||
self.set_status(update=True)
|
||||
self.make_bundle_for_sales_purchase_return()
|
||||
@@ -288,11 +289,11 @@ class POSInvoice(SalesInvoice):
|
||||
# run on cancel method of selling controller
|
||||
super(SalesInvoice, self).on_cancel()
|
||||
if not self.is_return and self.loyalty_program:
|
||||
self.delete_loyalty_point_entry()
|
||||
LoyaltyService(self).delete_loyalty_point_entry()
|
||||
elif self.is_return and self.return_against and self.loyalty_program:
|
||||
against_psi_doc = frappe.get_doc("POS Invoice", self.return_against)
|
||||
against_psi_doc.delete_loyalty_point_entry()
|
||||
against_psi_doc.make_loyalty_point_entry()
|
||||
LoyaltyService(against_psi_doc).delete_loyalty_point_entry()
|
||||
LoyaltyService(against_psi_doc).make_loyalty_point_entry()
|
||||
|
||||
self.db_set("status", "Cancelled")
|
||||
|
||||
|
||||
@@ -469,13 +469,13 @@ class SalesInvoice(SellingController):
|
||||
and self.loyalty_program
|
||||
and not self.dont_create_loyalty_points
|
||||
):
|
||||
self.make_loyalty_point_entry()
|
||||
LoyaltyService(self).make_loyalty_point_entry()
|
||||
elif self.is_return and self.return_against and not self.is_consolidated and self.loyalty_program:
|
||||
against_si_doc = frappe.get_doc("Sales Invoice", self.return_against)
|
||||
LoyaltyService(against_si_doc).delete_loyalty_point_entry()
|
||||
LoyaltyService(against_si_doc).make_loyalty_point_entry()
|
||||
if self.redeem_loyalty_points and not self.is_consolidated and self.loyalty_points:
|
||||
self.apply_loyalty_points()
|
||||
LoyaltyService(self).apply_loyalty_points()
|
||||
|
||||
self.process_common_party_accounting()
|
||||
self.update_billed_qty_in_scio()
|
||||
@@ -530,7 +530,7 @@ class SalesInvoice(SellingController):
|
||||
self.update_project()
|
||||
|
||||
if not self.is_return and not self.is_consolidated and self.loyalty_program:
|
||||
self.delete_loyalty_point_entry()
|
||||
LoyaltyService(self).delete_loyalty_point_entry()
|
||||
elif self.is_return and self.return_against and not self.is_consolidated and self.loyalty_program:
|
||||
against_si_doc = frappe.get_doc("Sales Invoice", self.return_against)
|
||||
LoyaltyService(against_si_doc).delete_loyalty_point_entry()
|
||||
@@ -1108,18 +1108,6 @@ class SalesInvoice(SellingController):
|
||||
self.validate_for_repost()
|
||||
self.repost_accounting_entries()
|
||||
|
||||
# Called by POS Invoice
|
||||
def make_loyalty_point_entry(self):
|
||||
LoyaltyService(self).make_loyalty_point_entry()
|
||||
|
||||
# Called by POS Invoice
|
||||
def delete_loyalty_point_entry(self):
|
||||
LoyaltyService(self).delete_loyalty_point_entry()
|
||||
|
||||
# Called by POS Invoice
|
||||
def apply_loyalty_points(self):
|
||||
LoyaltyService(self).apply_loyalty_points()
|
||||
|
||||
def set_status(self, update=False, status=None, update_modified=True):
|
||||
StatusService(self).set_status(update, status, update_modified)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user