Merge pull request #3996 from nabinhait/fix6

Check credit limit in Delivery Note / Sales Invoice, only if not created against Sales Order
This commit is contained in:
Anand Doshi
2015-09-09 15:11:12 +05:30
4 changed files with 29 additions and 7 deletions

View File

@@ -88,13 +88,13 @@ class SalesInvoice(SellingController):
self.update_status_updater_args() self.update_status_updater_args()
self.update_prevdoc_status() self.update_prevdoc_status()
# this sequence because outstanding may get -ve
self.make_gl_entries()
if not self.is_return: if not self.is_return:
self.update_billing_status_for_zero_amount_refdoc("Sales Order") self.update_billing_status_for_zero_amount_refdoc("Sales Order")
self.check_credit_limit() self.check_credit_limit()
# this sequence because outstanding may get -ve
self.make_gl_entries()
if not cint(self.is_pos) == 1 and not self.is_return: if not cint(self.is_pos) == 1 and not self.is_return:
self.update_against_document_in_jv() self.update_against_document_in_jv()
@@ -162,6 +162,17 @@ class SalesInvoice(SellingController):
} }
]) ])
def check_credit_limit(self):
from erpnext.selling.doctype.customer.customer import check_credit_limit
validate_against_credit_limit = False
for d in self.get("items"):
if not (d.sales_order or d.delivery_note):
validate_against_credit_limit = True
break
if validate_against_credit_limit:
check_credit_limit(self.customer, self.company)
def set_missing_values(self, for_validate=False): def set_missing_values(self, for_validate=False):
pos = self.set_pos_fields(for_validate) pos = self.set_pos_fields(for_validate)

View File

@@ -32,10 +32,6 @@ class SellingController(StockController):
self.validate_max_discount() self.validate_max_discount()
check_active_sales_items(self) check_active_sales_items(self)
def check_credit_limit(self):
from erpnext.selling.doctype.customer.customer import check_credit_limit
check_credit_limit(self.customer, self.company)
def set_missing_values(self, for_validate=False): def set_missing_values(self, for_validate=False):
super(SellingController, self).set_missing_values(for_validate) super(SellingController, self).set_missing_values(for_validate)

View File

@@ -176,6 +176,10 @@ class SalesOrder(SellingController):
frappe.db.set(self, 'status', 'Cancelled') frappe.db.set(self, 'status', 'Cancelled')
def check_credit_limit(self):
from erpnext.selling.doctype.customer.customer import check_credit_limit
check_credit_limit(self.customer, self.company)
def check_nextdoc_docstatus(self): def check_nextdoc_docstatus(self):
# Checks Delivery Note # Checks Delivery Note
submit_dn = frappe.db.sql_list("""select t1.name from `tabDelivery Note` t1,`tabDelivery Note Item` t2 submit_dn = frappe.db.sql_list("""select t1.name from `tabDelivery Note` t1,`tabDelivery Note Item` t2

View File

@@ -215,6 +215,17 @@ class DeliveryNote(SellingController):
self.make_gl_entries_on_cancel() self.make_gl_entries_on_cancel()
def check_credit_limit(self):
from erpnext.selling.doctype.customer.customer import check_credit_limit
validate_against_credit_limit = False
for d in self.get("items"):
if not (d.against_sales_order or d.against_sales_invoice):
validate_against_credit_limit = True
break
if validate_against_credit_limit:
check_credit_limit(self.customer, self.company)
def validate_packed_qty(self): def validate_packed_qty(self):
""" """
Validate that if packed qty exists, it should be equal to qty Validate that if packed qty exists, it should be equal to qty