default purchase taxes and charges master will be automatically fetched in pur transactions
This commit is contained in:
parent
f039c8b58f
commit
0170b2b4bc
@ -173,15 +173,13 @@ class DocType(TransactionBase):
|
|||||||
self.doclist = get_obj('GL Control').get_advances(self, self.doc.credit_to, 'Purchase Invoice Advance','advance_allocation_details','debit')
|
self.doclist = get_obj('GL Control').get_advances(self, self.doc.credit_to, 'Purchase Invoice Advance','advance_allocation_details','debit')
|
||||||
|
|
||||||
|
|
||||||
# ============= OTHER CHARGES ====================
|
|
||||||
|
|
||||||
# Get Tax rate if account type is TAX
|
|
||||||
# ------------------------------------
|
|
||||||
def get_rate(self,arg):
|
def get_rate(self,arg):
|
||||||
return get_obj('Purchase Common').get_rate(arg,self)
|
return get_obj('Purchase Common').get_rate(arg,self)
|
||||||
|
|
||||||
# Get Purchase Taxes and Charges Master
|
def load_default_taxes(self):
|
||||||
# -----------------------------------------------------------
|
self.doclist = get_obj('Purchase Common').load_default_taxes(self)
|
||||||
|
|
||||||
|
|
||||||
def get_purchase_tax_details(self):
|
def get_purchase_tax_details(self):
|
||||||
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
# These values are common in all dictionaries
|
# These values are common in all dictionaries
|
||||||
{
|
{
|
||||||
'creation': '2012-03-27 14:35:51',
|
'creation': '2012-05-15 12:14:32',
|
||||||
'docstatus': 0,
|
'docstatus': 0,
|
||||||
'modified': '2012-03-27 14:35:51',
|
'modified': '2012-08-17 09:57:04',
|
||||||
'modified_by': u'Administrator',
|
'modified_by': u'Administrator',
|
||||||
'owner': u'wasim@webnotestech.com'
|
'owner': u'wasim@webnotestech.com'
|
||||||
},
|
},
|
||||||
@ -24,7 +24,7 @@
|
|||||||
'section_style': u'Simple',
|
'section_style': u'Simple',
|
||||||
'server_code_error': u' ',
|
'server_code_error': u' ',
|
||||||
'show_in_menu': 0,
|
'show_in_menu': 0,
|
||||||
'version': 18
|
'version': 1
|
||||||
},
|
},
|
||||||
|
|
||||||
# These values are common for all DocField
|
# These values are common for all DocField
|
||||||
@ -106,6 +106,14 @@
|
|||||||
'search_index': 0
|
'search_index': 0
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# DocField
|
||||||
|
{
|
||||||
|
'doctype': u'DocField',
|
||||||
|
'fieldname': u'is_default',
|
||||||
|
'fieldtype': u'Check',
|
||||||
|
'label': u'Default'
|
||||||
|
},
|
||||||
|
|
||||||
# DocField
|
# DocField
|
||||||
{
|
{
|
||||||
'doctype': u'DocField',
|
'doctype': u'DocField',
|
||||||
|
@ -29,10 +29,26 @@ cur_frm.cscript.get_default_schedule_date = function(doc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.load_taxes = function(doc, cdt, cdn, callback) {
|
||||||
|
// run if this is not executed from dt_map...
|
||||||
|
doc = locals[doc.doctype][doc.name];
|
||||||
|
if(doc.supplier || getchildren('Purchase Taxes and Charges', doc.name, 'purchase_tax_details', doc.doctype).length) {
|
||||||
|
if(callback) {
|
||||||
|
callback(doc, cdt, cdn);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$c_obj(make_doclist(doc.doctype, doc.name),'load_default_taxes','',function(r,rt){
|
||||||
|
refresh_field('purchase_tax_details');
|
||||||
|
if(callback) callback(doc, cdt, cdn);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Gets called after existing item details are update to fill in
|
// Gets called after existing item details are update to fill in
|
||||||
// remaining default values
|
// remaining default values
|
||||||
cur_frm.cscript.load_defaults = function(doc, dt, dn) {
|
cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
|
||||||
if(!cur_frm.doc.__islocal) { return; }
|
if(!cur_frm.doc.__islocal) { return; }
|
||||||
|
|
||||||
doc = locals[doc.doctype][doc.name];
|
doc = locals[doc.doctype][doc.name];
|
||||||
@ -46,6 +62,7 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) {
|
|||||||
LocalDB.set_default_values(children[i]);
|
LocalDB.set_default_values(children[i]);
|
||||||
}
|
}
|
||||||
refresh_field(cur_frm.cscript.fname);
|
refresh_field(cur_frm.cscript.fname);
|
||||||
|
cur_frm.cscript.load_taxes(doc, dt, dn, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update existing item details
|
// Update existing item details
|
||||||
@ -58,10 +75,11 @@ cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) {
|
|||||||
if(!r.exc) {
|
if(!r.exc) {
|
||||||
refresh_field(cur_frm.cscript.fname);
|
refresh_field(cur_frm.cscript.fname);
|
||||||
doc = locals[doc.doctype][doc.name];
|
doc = locals[doc.doctype][doc.name];
|
||||||
cur_frm.cscript.load_defaults(doc, dt, dn);
|
cur_frm.cscript.load_defaults(doc, dt, dn, callback);
|
||||||
if(callback) callback(doc, dt, dn);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
cur_frm.cscript.load_taxes(doc, dt, dn, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,15 +623,23 @@ class DocType(TransactionBase):
|
|||||||
msgprint("'%s' Not Within The Fiscal Year"%(dn))
|
msgprint("'%s' Not Within The Fiscal Year"%(dn))
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
def load_default_taxes(self, obj):
|
||||||
|
return self.get_purchase_tax_details(obj, 1)
|
||||||
|
|
||||||
#---Other charges starting point------------------------
|
def get_purchase_tax_details(self,obj, default = 0):
|
||||||
|
|
||||||
# Get other charges from Master
|
|
||||||
# =================================================================================
|
|
||||||
def get_purchase_tax_details(self,obj):
|
|
||||||
obj.doclist = self.doc.clear_table(obj.doclist,'purchase_tax_details')
|
obj.doclist = self.doc.clear_table(obj.doclist,'purchase_tax_details')
|
||||||
|
|
||||||
|
if default: add_cond = " and ifnull(t2.is_default,0) = 1"
|
||||||
|
else: add_cond = " and t1.parent = '"+cstr(obj.doc.purchase_other_charges)+"'"
|
||||||
|
|
||||||
|
other_charge = sql("""
|
||||||
|
select t1.*
|
||||||
|
from `tabPurchase Taxes and Charges` t1, `tabPurchase Taxes and Charges Master` t2
|
||||||
|
where t1.parent = t2.name %s
|
||||||
|
order by t1.idx
|
||||||
|
"""% add_cond, as_dict = 1)
|
||||||
|
|
||||||
idx = 0
|
idx = 0
|
||||||
other_charge = sql("select category, add_deduct_tax, charge_type,row_id,description,account_head,rate,tax_amount from `tabPurchase Taxes and Charges` where parent = '%s' order by idx" %(obj.doc.purchase_other_charges), as_dict = 1)
|
|
||||||
for other in other_charge:
|
for other in other_charge:
|
||||||
d = addchild(obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1, obj.doclist)
|
d = addchild(obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1, obj.doclist)
|
||||||
d.category = other['category']
|
d.category = other['category']
|
||||||
|
@ -36,7 +36,10 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||||
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
|
var callback = function(doc, dt, dn) {
|
||||||
|
if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
|
||||||
|
}
|
||||||
|
cur_frm.cscript.update_item_details(doc, dt, dn, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
|
@ -56,6 +56,7 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
# Get Item Details
|
# Get Item Details
|
||||||
def get_item_details(self, arg =''):
|
def get_item_details(self, arg =''):
|
||||||
|
import json
|
||||||
if arg:
|
if arg:
|
||||||
return get_obj(dt='Purchase Common').get_item_details(self,arg)
|
return get_obj(dt='Purchase Common').get_item_details(self,arg)
|
||||||
else:
|
else:
|
||||||
@ -359,13 +360,11 @@ class DocType(TransactionBase):
|
|||||||
self.update_rw_material_detail()
|
self.update_rw_material_detail()
|
||||||
|
|
||||||
|
|
||||||
# OTHER CHARGES TRIGGER FUNCTIONS
|
|
||||||
# ====================================================================================
|
|
||||||
|
|
||||||
# *********** Get Tax rate if account type is TAX ********************
|
|
||||||
def get_rate(self,arg):
|
def get_rate(self,arg):
|
||||||
return get_obj('Purchase Common').get_rate(arg,self)
|
return get_obj('Purchase Common').get_rate(arg,self)
|
||||||
|
|
||||||
# **** Pull details from other charges master (Get Other Charges) ****
|
def load_default_taxes(self):
|
||||||
|
self.doclist = get_obj('Purchase Common').load_default_taxes(self)
|
||||||
|
|
||||||
def get_purchase_tax_details(self):
|
def get_purchase_tax_details(self):
|
||||||
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
||||||
|
@ -38,6 +38,7 @@ cur_frm.cscript.onload = function(doc, dt, dn) {
|
|||||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||||
erpnext.hide_naming_series();
|
erpnext.hide_naming_series();
|
||||||
cur_frm.cscript.dynamic_label(doc, dt, dn);
|
cur_frm.cscript.dynamic_label(doc, dt, dn);
|
||||||
|
cur_frm.cscript.load_taxes(doc, dt, dn);
|
||||||
|
|
||||||
cur_frm.cscript.toggle_contact_section(doc);
|
cur_frm.cscript.toggle_contact_section(doc);
|
||||||
|
|
||||||
|
@ -72,6 +72,9 @@ class DocType(TransactionBase):
|
|||||||
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0
|
d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0
|
||||||
d.import_ref_rate = d.import_rate = 0.0
|
d.import_ref_rate = d.import_rate = 0.0
|
||||||
|
|
||||||
|
def load_default_taxes(self):
|
||||||
|
self.doclist = get_obj('Purchase Common').load_default_taxes(self)
|
||||||
|
|
||||||
def get_purchase_tax_details(self):
|
def get_purchase_tax_details(self):
|
||||||
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
||||||
|
|
||||||
|
@ -468,15 +468,11 @@ class DocType(TransactionBase):
|
|||||||
d.current_stock = bin and flt(bin[0]['actual_qty']) or 0
|
d.current_stock = bin and flt(bin[0]['actual_qty']) or 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# OTHER CHARGES TRIGGER FUNCTIONS
|
|
||||||
# ====================================================================================
|
|
||||||
|
|
||||||
# *********** Get Tax rate if account type is TAX ********************
|
|
||||||
def get_rate(self,arg):
|
def get_rate(self,arg):
|
||||||
return get_obj('Purchase Common').get_rate(arg,self)
|
return get_obj('Purchase Common').get_rate(arg,self)
|
||||||
|
|
||||||
# **** Pull details from other charges master (Get Other Charges) ****
|
def load_default_taxes(self):
|
||||||
|
self.doclist = get_obj('Purchase Common').load_default_taxes(self)
|
||||||
|
|
||||||
def get_purchase_tax_details(self):
|
def get_purchase_tax_details(self):
|
||||||
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user