From 8b2473cc4032516683092fa6f46c398dff9a8d03 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 17 May 2012 12:47:48 +0530 Subject: [PATCH 1/3] report fixed: sales persons target variance (item group wise) --- ...persons_target_variance_item_group_wise.js | 8 ++---- ...persons_target_variance_item_group_wise.py | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/erpnext/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js b/erpnext/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js index 9491bbb63a..8e46f42322 100644 --- a/erpnext/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js +++ b/erpnext/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.js @@ -49,13 +49,9 @@ report.get_query = function() { cond1 = 'ifnull(t1.target_amount,"")!=""'; cond2 = 'ifnull(t6.target_amount,"")!=""'; } - if(under =='Sales Invoice') - tab = 'RV'; - else - tab = under; - var q ='SELECT t1.item_group AS "Item Group", '+q1+', t2.distribution_id AS "Distribution Id" FROM `tabTarget Detail` t1, `tabSales Person` t2 WHERE t1.parenttype = "Sales Person" AND t1.parent = "'+sales_person+'" AND t1.parent=t2.name AND ifnull(t1.item_group,"") != "" AND '+cond1+' UNION SELECT t3.item_group AS "Item Group", '+q2+',"" AS "Distribution Id" FROM `tab'+tab+' Detail` t3,`tabSales Team` t4,`tab'+under+'` t5 where t3.item_group NOT IN (SELECT t6.item_group AS "Item Group" FROM `tabTarget Detail` t6, `tabSales Person` t7 WHERE t6.parenttype = "Sales Person" AND t6.parent = "'+sales_person+'" AND t6.parent=t7.name AND '+cond2+') AND t4.sales_person = "'+sales_person+'" AND t3.parent = t5.name AND t4.parent = t5.name AND t5.docstatus = 1'; + var q ='SELECT t1.item_group AS "Item Group", '+q1+', t2.distribution_id AS "Distribution Id" FROM `tabTarget Detail` t1, `tabSales Person` t2 WHERE t1.parenttype = "Sales Person" AND t1.parent = "'+sales_person+'" AND t1.parent=t2.name AND ifnull(t1.item_group,"") != "" AND '+cond1+' UNION SELECT t3.item_group AS "Item Group", '+q2+',"" AS "Distribution Id" FROM `tab'+under+' Item` t3,`tabSales Team` t4,`tab'+under+'` t5 where t3.item_group NOT IN (SELECT t6.item_group AS "Item Group" FROM `tabTarget Detail` t6, `tabSales Person` t7 WHERE t6.parenttype = "Sales Person" AND t6.parent = "'+sales_person+'" AND t6.parent=t7.name AND '+cond2+') AND t4.sales_person = "'+sales_person+'" AND t3.parent = t5.name AND t4.parent = t5.name AND t5.docstatus = 1'; return q; -} \ No newline at end of file +} diff --git a/erpnext/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py b/erpnext/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py index 83a6511828..e3f8d6730f 100644 --- a/erpnext/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py +++ b/erpnext/selling/search_criteria/sales_persons_target_variance_item_group_wise/sales_persons_target_variance_item_group_wise.py @@ -13,7 +13,6 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . - # validate Filters flt_dict = {'fiscal_year': 'Fiscal Year', 'period': 'Period', 'under' : 'Under', 'sales_person':'Sales Person', 'target_on':'Target On'} for f in flt_dict: @@ -22,14 +21,23 @@ for f in flt_dict: raise Exception # Get Values from fliters -fiscal_year = filter_values.get('fiscal_year') +fiscal_year = filter_values.get('fiscal_year')[0] period = filter_values.get('period') under = filter_values.get('under') -if under == 'Sales Invoice': under = 'Sales Invoice' sales_person = filter_values.get('sales_person') target_on = filter_values.get('target_on') +# set colnames +for d in ['Item Group', 'Total Target Allocated', 'Distribution Id']: + colnames.append(d) + coltypes.append('Data') + colwidths.append('150px') + coloptions.append('') + col_idx[d] = len(colnames) - 1 + + + # Set required field names based_on_fn = 'sales_person' @@ -89,9 +97,6 @@ def append_colnames(name, colnames, coltypes, colwidths, coloptions, col_idx): -# make default columns -#coltypes[col_idx['Item Group']] = 'Link' -#coloptions[col_idx['Item Group']]= 'Sales ' # get start date start_date = get_value('Fiscal Year', fiscal_year, 'year_start_date') @@ -104,7 +109,6 @@ start_date = start_date.strftime('%Y-%m-%d') make_month_list(append_colnames, start_date, mon_list, period, colnames, coltypes, colwidths, coloptions, col_idx) - bc_obj = get_obj('Budget Control') for r in res: @@ -120,16 +124,15 @@ for r in res: actual = 0 - #---------------------------------------------------------- if target_on == "Quantity": - actual = sql("select sum(ifnull(t2.qty,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t2.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, (under == 'Sales Invoice') and 'RV' or under, based_on_fn, sales_person, r[0].strip(), date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']])) + actual = sql("select sum(ifnull(t2.qty,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Item` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t2.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, under, based_on_fn, sales_person, r[0].strip(), date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']])) #---------------------------------------------------------- if target_on == "Amount": - actual = sql("select sum(ifnull(t2.amount,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Detail` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t2.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, (under == 'Sales Invoice') and 'RV' or under, based_on_fn, sales_person, r[0].strip(), date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']])) + actual = sql("select sum(ifnull(t2.amount,0) * ifnull(t3.allocated_percentage,0) / 100) from `tab%s` t1, `tab%s Item` t2, `tabSales Team` t3 where t2.parent = t1.name and t3.parent = t1.name and t3.%s = '%s' and t2.item_group = '%s' and t1.docstatus = 1 and t1.%s between '%s' and '%s' "%(under, under, based_on_fn, sales_person, r[0].strip(), date_fn, mon_list[count][data['start_date']], mon_list[count][data['end_date']])) #---------------------------------------------------------- actual = actual and flt(actual[0][0]) or 0 @@ -138,4 +141,4 @@ for r in res: r.append(r[idx] - r[idx + 1]) - count = count +1 \ No newline at end of file + count = count +1 From 57f9bd1d739cbbde25957f28b6df40418b723d0d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 17 May 2012 15:02:02 +0530 Subject: [PATCH 2/3] bom issue fixed --- erpnext/production/doctype/bom/bom.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/erpnext/production/doctype/bom/bom.py b/erpnext/production/doctype/bom/bom.py index 89e4d4b1a5..36df84e442 100644 --- a/erpnext/production/doctype/bom/bom.py +++ b/erpnext/production/doctype/bom/bom.py @@ -316,9 +316,6 @@ class DocType: def on_update(self): - if self.doc.item != cstr(self.doc.name.split('/')[1]): - msgprint("Cannot change Item once the Bill Of Material is created.") - raise Exception self.check_recursion() From dad93ce8a3c88fc07c4678fa2a0d6be04f8f2f40 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 17 May 2012 15:28:38 +0530 Subject: [PATCH 3/3] fix in payment reconciliation --- .../payment_to_invoice_matching_tool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js index 4057f7e475..93e6bffea1 100644 --- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js +++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js @@ -26,7 +26,7 @@ cur_frm.fields_dict.voucher_no.get_query = function(doc) { and voucher_type = '%(dt)s' \ and voucher_no LIKE '%s' \ ORDER BY posting_date DESC, voucher_no DESC LIMIT 50 \ - ", {dt:session.rev_dt_labels[doc.voucher_type] || doc.voucher_type, acc:doc.account}); + ", {dt:doc.voucher_type, acc:doc.account}); } }