[Minor] Do not allow change in credit limit
This commit is contained in:
parent
44e9195378
commit
e05656963a
@ -69,6 +69,7 @@ class Customer(TransactionBase):
|
|||||||
self.flags.old_lead = self.lead_name
|
self.flags.old_lead = self.lead_name
|
||||||
validate_party_accounts(self)
|
validate_party_accounts(self)
|
||||||
self.status = get_party_status(self)
|
self.status = get_party_status(self)
|
||||||
|
self.validate_credit_limit_on_change()
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.validate_name_with_customer_group()
|
self.validate_name_with_customer_group()
|
||||||
@ -125,6 +126,15 @@ class Customer(TransactionBase):
|
|||||||
if frappe.db.exists("Customer Group", self.name):
|
if frappe.db.exists("Customer Group", self.name):
|
||||||
frappe.throw(_("A Customer Group exists with same name please change the Customer name or rename the Customer Group"), frappe.NameError)
|
frappe.throw(_("A Customer Group exists with same name please change the Customer name or rename the Customer Group"), frappe.NameError)
|
||||||
|
|
||||||
|
def validate_credit_limit_on_change(self):
|
||||||
|
customer = frappe.get_doc('Customer', self.name)
|
||||||
|
companies = [c.name for c in frappe.get_all("Company")]
|
||||||
|
|
||||||
|
for company in companies:
|
||||||
|
outstanding_amt = get_customer_outstanding(customer.name, company)
|
||||||
|
if flt(self.credit_limit) < outstanding_amt:
|
||||||
|
frappe.throw(_("New credit limit is less than current outstanding amount for the customer. Credit limit has to be atleast {0}").format(outstanding_amt))
|
||||||
|
|
||||||
def delete_customer_address(self):
|
def delete_customer_address(self):
|
||||||
addresses = frappe.db.sql("""select name, lead from `tabAddress`
|
addresses = frappe.db.sql("""select name, lead from `tabAddress`
|
||||||
where customer=%s""", (self.name,))
|
where customer=%s""", (self.name,))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user