[fix] [minor] set due date in sales invoice after mapping
This commit is contained in:
parent
01aa860e07
commit
30324b857a
@ -162,12 +162,22 @@ class DocType(SellingController):
|
|||||||
|
|
||||||
def set_missing_values(self, for_validate=False):
|
def set_missing_values(self, for_validate=False):
|
||||||
self.set_pos_fields(for_validate)
|
self.set_pos_fields(for_validate)
|
||||||
|
|
||||||
|
if not self.doc.debit_to:
|
||||||
|
self.doc.debit_to = self.get_customer_account()
|
||||||
|
if not self.doc.due_date:
|
||||||
|
self.doc.due_date = self.get_due_date()
|
||||||
|
|
||||||
super(DocType, self).set_missing_values(for_validate)
|
super(DocType, self).set_missing_values(for_validate)
|
||||||
|
|
||||||
def set_customer_defaults(self):
|
def set_customer_defaults(self):
|
||||||
# TODO cleanup these methods
|
# TODO cleanup these methods
|
||||||
self.doc.fields.update(self.get_debit_to())
|
if self.doc.customer:
|
||||||
self.get_cust_and_due_date()
|
self.doc.debit_to = self.get_customer_account()
|
||||||
|
elif self.doc.debit_to:
|
||||||
|
self.doc.customer = webnotes.conn.get_value('Account', self.doc.debit_to, 'master_name')
|
||||||
|
|
||||||
|
self.doc.due_date = self.get_due_date()
|
||||||
|
|
||||||
super(DocType, self).set_customer_defaults()
|
super(DocType, self).set_customer_defaults()
|
||||||
|
|
||||||
@ -243,16 +253,9 @@ class DocType(SellingController):
|
|||||||
You must first create it from the Customer Master" %
|
You must first create it from the Customer Master" %
|
||||||
(self.doc.customer, self.doc.company))
|
(self.doc.customer, self.doc.company))
|
||||||
|
|
||||||
def get_debit_to(self):
|
def get_due_date(self):
|
||||||
acc_head = self.get_customer_account()
|
|
||||||
return acc_head and {'debit_to' : acc_head} or {}
|
|
||||||
|
|
||||||
|
|
||||||
def get_cust_and_due_date(self):
|
|
||||||
"""Set Due Date = Posting Date + Credit Days"""
|
"""Set Due Date = Posting Date + Credit Days"""
|
||||||
if self.doc.debit_to:
|
due_date = None
|
||||||
self.doc.customer = webnotes.conn.get_value('Account', self.doc.debit_to, 'master_name')
|
|
||||||
|
|
||||||
if self.doc.posting_date:
|
if self.doc.posting_date:
|
||||||
credit_days = 0
|
credit_days = 0
|
||||||
if self.doc.debit_to:
|
if self.doc.debit_to:
|
||||||
@ -263,9 +266,11 @@ class DocType(SellingController):
|
|||||||
credit_days = webnotes.conn.get_value("Company", self.doc.company, "credit_days")
|
credit_days = webnotes.conn.get_value("Company", self.doc.company, "credit_days")
|
||||||
|
|
||||||
if credit_days:
|
if credit_days:
|
||||||
self.doc.due_date = add_days(self.doc.posting_date, credit_days)
|
due_date = add_days(self.doc.posting_date, credit_days)
|
||||||
else:
|
else:
|
||||||
self.doc.due_date = self.doc.posting_date
|
due_date = self.doc.posting_date
|
||||||
|
|
||||||
|
return due_date
|
||||||
|
|
||||||
def get_barcode_details(self, barcode):
|
def get_barcode_details(self, barcode):
|
||||||
return get_obj('Sales Common').get_barcode_details(barcode)
|
return get_obj('Sales Common').get_barcode_details(barcode)
|
||||||
|
@ -14,12 +14,8 @@ class SellingController(StockController):
|
|||||||
def onload_post_render(self):
|
def onload_post_render(self):
|
||||||
# contact, address, item details and pos details (if applicable)
|
# contact, address, item details and pos details (if applicable)
|
||||||
self.set_missing_values()
|
self.set_missing_values()
|
||||||
|
|
||||||
self.set_taxes("other_charges", "charge")
|
self.set_taxes("other_charges", "charge")
|
||||||
|
|
||||||
if self.meta.get_field("debit_to") and not self.doc.debit_to:
|
|
||||||
self.doc.debit_to = self.get_debit_to().get("debit_to")
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user