mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 19:19:17 +00:00
Re-written update_against_document_in_jv function in RV and PV
This commit is contained in:
@@ -447,12 +447,38 @@ class DocType(TransactionBase):
|
|||||||
if not submitted:
|
if not submitted:
|
||||||
msgprint("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted")
|
msgprint("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted")
|
||||||
raise Exception , "Validation Error."
|
raise Exception , "Validation Error."
|
||||||
|
|
||||||
def update_against_document_in_jv(self, against_document_no, against_document_doctype):
|
|
||||||
get_obj('GL Control').update_against_document_in_jv( self,'advance_allocation_details', against_document_no, against_document_doctype, self.doc.credit_to, 'debit',self.doc.doctype)
|
#--------------------------------------------------------------------
|
||||||
|
def update_against_document_in_jv(self):
|
||||||
|
"""
|
||||||
|
Links invoice and advance voucher:
|
||||||
|
1. cancel advance voucher
|
||||||
|
2. split into multiple rows if partially adjusted, assign against voucher
|
||||||
|
3. submit advance voucher
|
||||||
|
"""
|
||||||
|
|
||||||
|
lst = []
|
||||||
|
for d in getlist(self.doclist, 'advance_allocation_details'):
|
||||||
|
if flt(d.allocated_amount) > 0:
|
||||||
|
args = {
|
||||||
|
'voucher_no' : d.journal_voucher,
|
||||||
|
'voucher_detail_no' : d.jv_detail_no,
|
||||||
|
'against_voucher_type' : 'Payable Voucher',
|
||||||
|
'against_voucher' : self.doc.name,
|
||||||
|
'account' : self.doc.credit_to,
|
||||||
|
'is_advance' : 'Yes',
|
||||||
|
'dr_or_cr' : 'debit',
|
||||||
|
'unadjusted_amt' : flt(d.advance_amount),
|
||||||
|
'allocated_amt' : flt(d.allocated_amount)
|
||||||
|
}
|
||||||
|
lst.append(args)
|
||||||
|
|
||||||
|
if lst:
|
||||||
|
get_obj('GL Control').reconcile_against_document(lst)
|
||||||
|
|
||||||
# On Submit
|
# On Submit
|
||||||
# ----------
|
#--------------------------------------------------------------------
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.check_prev_docstatus()
|
self.check_prev_docstatus()
|
||||||
|
|
||||||
@@ -462,7 +488,9 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
# this sequence because outstanding may get -negative
|
# this sequence because outstanding may get -negative
|
||||||
get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist)
|
get_obj(dt='GL Control').make_gl_entries(self.doc, self.doclist)
|
||||||
self.update_against_document_in_jv(self.doc.name, self.doc.doctype)
|
|
||||||
|
self.update_against_document_in_jv()
|
||||||
|
|
||||||
get_obj(dt = 'Purchase Common').update_prevdoc_detail(self, is_submit = 1)
|
get_obj(dt = 'Purchase Common').update_prevdoc_detail(self, is_submit = 1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -225,40 +225,47 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------
|
#-----------------------------------------------------------------
|
||||||
# ADVANCE ALLOCATION
|
def update_against_document_in_jv(self):
|
||||||
#-----------------------------------------------------------------
|
"""
|
||||||
def update_against_document_in_jv(self,against_document_no, against_document_doctype):
|
Links invoice and advance voucher:
|
||||||
get_obj('GL Control').update_against_document_in_jv( self, 'advance_adjustment_details', against_document_no, against_document_doctype, self.doc.debit_to, 'credit', self.doc.doctype)
|
1. cancel advance voucher
|
||||||
|
2. split into multiple rows if partially adjusted, assign against voucher
|
||||||
|
3. submit advance voucher
|
||||||
|
"""
|
||||||
|
|
||||||
|
lst = []
|
||||||
|
for d in getlist(self.doclist, 'advance_adjustment_details'):
|
||||||
|
if flt(d.allocated_amount) > 0:
|
||||||
|
args = {
|
||||||
|
'voucher_no' : d.journal_voucher,
|
||||||
|
'voucher_detail_no' : d.jv_detail_no,
|
||||||
|
'against_voucher_type' : 'Receivable Voucher',
|
||||||
|
'against_voucher' : self.doc.name,
|
||||||
|
'account' : self.doc.debit_to,
|
||||||
|
'is_advance' : 'Yes',
|
||||||
|
'dr_or_cr' : 'credit',
|
||||||
|
'unadjusted_amt' : flt(d.advance_amount),
|
||||||
|
'allocated_amt' : flt(d.allocated_amount)
|
||||||
|
}
|
||||||
|
lst.append(args)
|
||||||
|
|
||||||
|
if lst:
|
||||||
|
get_obj('GL Control').reconcile_against_document(lst)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ************************************* VALIDATE **********************************************
|
|
||||||
# Get Customer Name and address based on Debit To Account selected
|
|
||||||
# This case arises in case of direct RV where user doesn't enter customer name.
|
|
||||||
# Hence it should be fetched from Account Head.
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
#def get_customer_details(self):
|
|
||||||
# get_obj('Sales Common').get_customer_details(self, inv_det_reqd = 1)
|
|
||||||
# self.get_cust_and_due_date()
|
|
||||||
|
|
||||||
|
|
||||||
# Validate Customer Name with SO or DN if items are fetched from SO or DN
|
|
||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
def validate_customer(self):
|
def validate_customer(self):
|
||||||
|
"""
|
||||||
|
Validate customer name with SO and DN
|
||||||
|
"""
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
customer = ''
|
dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or ''
|
||||||
if d.sales_order:
|
if dt:
|
||||||
customer = sql("select customer from `tabSales Order` where name = '%s'" % d.sales_order)[0][0]
|
dt_no = d.delivery_note or d.sales_order
|
||||||
doctype = 'sales order'
|
cust = sql("select customer from `tab%s` where name = %s" % (dt, '%s'), dt_no)
|
||||||
doctype_no = cstr(d.sales_order)
|
if cust and cstr(cust[0][0]) != cstr(self.doc.customer):
|
||||||
if d.delivery_note:
|
msgprint("Customer %s does not match with customer of %s: %s." %(self.doc.customer, dt, dt_no), raise_exception=1)
|
||||||
customer = sql("select customer from `tabDelivery Note` where name = '%s'" % d.delivery_note)[0][0]
|
|
||||||
doctype = 'delivery note'
|
|
||||||
doctype_no = cstr(d.delivery_note)
|
|
||||||
if customer and not cstr(self.doc.customer) == cstr(customer):
|
|
||||||
msgprint("Customer %s do not match with customer of %s %s." %(self.doc.customer,doctype,doctype_no))
|
|
||||||
raise Exception , " Validation Error "
|
|
||||||
|
|
||||||
|
|
||||||
# Validates Debit To Account and Customer Matches
|
# Validates Debit To Account and Customer Matches
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------
|
||||||
@@ -545,7 +552,7 @@ class DocType(TransactionBase):
|
|||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
|
|
||||||
if not cint(self.doc.is_pos) == 1:
|
if not cint(self.doc.is_pos) == 1:
|
||||||
self.update_against_document_in_jv(self.doc.name, self.doc.doctype)
|
self.update_against_document_in_jv()
|
||||||
|
|
||||||
# on submit notification
|
# on submit notification
|
||||||
# get_obj('Notification Control').notify_contact('Sales Invoice', self.doc.doctype,self.doc.name, self.doc.email_id, self.doc.contact_person)
|
# get_obj('Notification Control').notify_contact('Sales Invoice', self.doc.doctype,self.doc.name, self.doc.email_id, self.doc.contact_person)
|
||||||
|
|||||||
Reference in New Issue
Block a user