Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/GL Mapper/Purchase Invoice with write off/Purchase Invoice with write off.txt b/accounts/GL Mapper/Purchase Invoice with write off/Purchase Invoice with write off.txt
index 9cb6116..acbe877 100644
--- a/accounts/GL Mapper/Purchase Invoice with write off/Purchase Invoice with write off.txt
+++ b/accounts/GL Mapper/Purchase Invoice with write off/Purchase Invoice with write off.txt
@@ -3,24 +3,24 @@
# These values are common in all dictionaries
{
- 'creation': '2012-04-23 11:43:56',
- 'docstatus': 0,
- 'modified': '2012-04-23 11:43:56',
- 'modified_by': u'Administrator',
- 'owner': u'Administrator'
+ u'creation': '2012-04-30 19:55:05',
+ u'docstatus': 0,
+ u'modified': '2012-10-03 11:08:09',
+ u'modified_by': u'Administrator',
+ u'owner': u'Administrator'
},
# These values are common for all GL Mapper
{
'doc_type': u'Purchase Invoice with write off',
- 'doctype': 'GL Mapper',
- 'name': '__common__'
+ u'doctype': u'GL Mapper',
+ u'name': u'__common__'
},
# These values are common for all GL Mapper Detail
{
- 'doctype': u'GL Mapper Detail',
- 'name': '__common__',
+ u'doctype': u'GL Mapper Detail',
+ u'name': u'__common__',
'parent': u'Purchase Invoice with write off',
'parentfield': u'fields',
'parenttype': u'GL Mapper'
@@ -28,8 +28,8 @@
# GL Mapper, Purchase Invoice with write off
{
- 'doctype': 'GL Mapper',
- 'name': u'Purchase Invoice with write off'
+ u'doctype': u'GL Mapper',
+ u'name': u'Purchase Invoice with write off'
},
# GL Mapper Detail
@@ -41,7 +41,7 @@
'cost_center': u'cost_center',
'credit': u'value:0',
'debit': u'amount',
- 'doctype': u'GL Mapper Detail',
+ u'doctype': u'GL Mapper Detail',
'fiscal_year': u'parent:fiscal_year',
'is_opening': u'parent:is_opening',
'posting_date': u'parent:posting_date',
@@ -59,9 +59,9 @@
'aging_date': u'parent:aging_date',
'company': u'parent:company',
'cost_center': u'cost_center',
- 'credit': u"value:d.fields.get('category') != 'For Valuation' and d.fields.get('add_deduct_tax') == 'Deduct' and d.fields.get('tax_amount') or 0",
- 'debit': u"value:d.fields.get('category') != 'For Valuation' and d.fields.get('add_deduct_tax') == 'Add' and d.fields.get('tax_amount') or 0",
- 'doctype': u'GL Mapper Detail',
+ 'credit': u"value:d.fields.get('category') != 'Valuation' and d.fields.get('add_deduct_tax') == 'Deduct' and d.fields.get('tax_amount') or 0",
+ 'debit': u"value:d.fields.get('category') != 'Valuation' and d.fields.get('add_deduct_tax') == 'Add' and d.fields.get('tax_amount') or 0",
+ u'doctype': u'GL Mapper Detail',
'fiscal_year': u'parent:fiscal_year',
'is_opening': u'parent:is_opening',
'posting_date': u'parent:posting_date',
@@ -80,7 +80,7 @@
'company': u'company',
'credit': u'ded_amount',
'debit': u'value:0',
- 'doctype': u'GL Mapper Detail',
+ u'doctype': u'GL Mapper Detail',
'fiscal_year': u'fiscal_year',
'is_opening': u'is_opening',
'posting_date': u'posting_date',
@@ -100,7 +100,7 @@
'company': u'company',
'credit': u'total_amount_to_pay',
'debit': u'value:0',
- 'doctype': u'GL Mapper Detail',
+ u'doctype': u'GL Mapper Detail',
'fiscal_year': u'fiscal_year',
'is_opening': u'is_opening',
'posting_date': u'posting_date',
@@ -119,7 +119,7 @@
'cost_center': u'write_off_cost_center',
'credit': u'write_off_amount',
'debit': u'value:0',
- 'doctype': u'GL Mapper Detail',
+ u'doctype': u'GL Mapper Detail',
'fiscal_year': u'fiscal_year',
'is_opening': u'is_opening',
'posting_date': u'posting_date',
diff --git a/accounts/GL Mapper/Purchase Invoice/Purchase Invoice.txt b/accounts/GL Mapper/Purchase Invoice/Purchase Invoice.txt
index 7fcf199..61851d9 100644
--- a/accounts/GL Mapper/Purchase Invoice/Purchase Invoice.txt
+++ b/accounts/GL Mapper/Purchase Invoice/Purchase Invoice.txt
@@ -1 +1,112 @@
-[{'doc_type': 'Purchase Invoice', 'modified_by': 'nabin@webnotestech.com', 'name': 'Purchase Invoice', 'parent': None, 'creation': '2009-03-12 12:09:24', 'modified': '2010-05-26 16:48:58', 'module': 'Accounts', 'doctype': 'GL Mapper', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'parentfield': None}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center', 'voucher_no': 'parent:name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': None, 'table_field': 'entries', 'transaction_date': 'parent:voucher_date', 'debit': 'amount', 'docstatus': 0, 'parent': 'Purchase Invoice', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': None, 'remarks': 'parent:remarks', 'account': 'expense_head', 'name': 'GLMDetail00002', 'idx': 1, 'against_voucher_type': None, 'modified': '2010-05-26 16:48:58', 'against': 'parent:credit_to', 'credit': 'value:0', 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'parent:doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': 'cost_center', 'voucher_no': 'parent:name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': None, 'table_field': 'purchase_tax_details', 'transaction_date': 'parent:voucher_date', 'debit': "value:d.fields.get('category') != 'For Valuation' and d.fields.get('add_deduct_tax') == 'Add' and d.fields.get('tax_amount') or 0", 'docstatus': 0, 'parent': 'Purchase Invoice', 'company': 'parent:company', 'aging_date': 'parent:aging_date', 'fiscal_year': 'parent:fiscal_year', 'is_advance': None, 'remarks': 'parent:remarks', 'account': 'account_head', 'name': 'GLMDetail00003', 'idx': 2, 'against_voucher_type': None, 'modified': '2010-05-26 16:48:58', 'against': 'parent:credit_to', 'credit': "value:d.fields.get('category') != 'For Valuation' and d.fields.get('add_deduct_tax') == 'Deduct' and d.fields.get('tax_amount') or 0", 'parenttype': 'GL Mapper', 'is_opening': 'parent:is_opening', 'posting_date': 'parent:posting_date', 'parentfield': 'fields'}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': '', 'voucher_no': 'name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': None, 'table_field': '', 'transaction_date': 'voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'Purchase Invoice', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': None, 'remarks': 'remarks', 'account': 'tax_code', 'name': 'GLMDetail00004', 'idx': 3, 'against_voucher_type': None, 'modified': '2010-05-26 16:48:58', 'against': 'credit_to', 'credit': 'ded_amount', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}, {'creation': '2009-03-12 12:09:24', 'voucher_type': 'doctype', 'doctype': 'GL Mapper Detail', 'owner': 'Administrator', 'cost_center': '', 'voucher_no': 'name', 'modified_by': 'nabin@webnotestech.com', 'against_voucher': 'name', 'table_field': '', 'transaction_date': 'voucher_date', 'debit': 'value:0', 'docstatus': 0, 'parent': 'Purchase Invoice', 'company': 'company', 'aging_date': 'aging_date', 'fiscal_year': 'fiscal_year', 'is_advance': None, 'remarks': 'remarks', 'account': 'credit_to', 'name': 'GLMDetail00005', 'idx': 4, 'against_voucher_type': "value:'Purchase Invoice'", 'modified': '2010-05-26 16:48:58', 'against': 'against_expense_account', 'credit': 'total_amount_to_pay', 'parenttype': 'GL Mapper', 'is_opening': 'is_opening', 'posting_date': 'posting_date', 'parentfield': 'fields'}]
\ No newline at end of file
+# GL Mapper, Purchase Invoice
+[
+
+ # These values are common in all dictionaries
+ {
+ u'creation': '2012-04-30 19:55:04',
+ u'docstatus': 0,
+ u'modified': '2012-10-03 11:07:26',
+ u'modified_by': u'Administrator',
+ u'owner': u'Administrator'
+ },
+
+ # These values are common for all GL Mapper
+ {
+ 'doc_type': u'Purchase Invoice',
+ u'doctype': u'GL Mapper',
+ u'name': u'__common__'
+ },
+
+ # These values are common for all GL Mapper Detail
+ {
+ u'doctype': u'GL Mapper Detail',
+ u'name': u'__common__',
+ 'parent': u'Purchase Invoice',
+ 'parentfield': u'fields',
+ 'parenttype': u'GL Mapper'
+ },
+
+ # GL Mapper, Purchase Invoice
+ {
+ u'doctype': u'GL Mapper',
+ u'name': u'Purchase Invoice'
+ },
+
+ # GL Mapper Detail
+ {
+ 'account': u'expense_head',
+ 'against': u'parent:credit_to',
+ 'aging_date': u'parent:aging_date',
+ 'company': u'parent:company',
+ 'cost_center': u'cost_center',
+ 'credit': u'value:0',
+ 'debit': u'amount',
+ u'doctype': u'GL Mapper Detail',
+ 'fiscal_year': u'parent:fiscal_year',
+ 'is_opening': u'parent:is_opening',
+ 'posting_date': u'parent:posting_date',
+ 'remarks': u'parent:remarks',
+ 'table_field': u'entries',
+ 'transaction_date': u'parent:voucher_date',
+ 'voucher_no': u'parent:name',
+ 'voucher_type': u'parent:doctype'
+ },
+
+ # GL Mapper Detail
+ {
+ 'account': u'account_head',
+ 'against': u'parent:credit_to',
+ 'aging_date': u'parent:aging_date',
+ 'company': u'parent:company',
+ 'cost_center': u'cost_center',
+ 'credit': u"value:d.fields.get('category') != 'Valuation' and d.fields.get('add_deduct_tax') == 'Deduct' and d.fields.get('tax_amount') or 0",
+ 'debit': u"value:d.fields.get('category') != 'Valuation' and d.fields.get('add_deduct_tax') == 'Add' and d.fields.get('tax_amount') or 0",
+ u'doctype': u'GL Mapper Detail',
+ 'fiscal_year': u'parent:fiscal_year',
+ 'is_opening': u'parent:is_opening',
+ 'posting_date': u'parent:posting_date',
+ 'remarks': u'parent:remarks',
+ 'table_field': u'purchase_tax_details',
+ 'transaction_date': u'parent:voucher_date',
+ 'voucher_no': u'parent:name',
+ 'voucher_type': u'parent:doctype'
+ },
+
+ # GL Mapper Detail
+ {
+ 'account': u'tax_code',
+ 'against': u'credit_to',
+ 'aging_date': u'aging_date',
+ 'company': u'company',
+ 'credit': u'ded_amount',
+ 'debit': u'value:0',
+ u'doctype': u'GL Mapper Detail',
+ 'fiscal_year': u'fiscal_year',
+ 'is_opening': u'is_opening',
+ 'posting_date': u'posting_date',
+ 'remarks': u'remarks',
+ 'transaction_date': u'voucher_date',
+ 'voucher_no': u'name',
+ 'voucher_type': u'doctype'
+ },
+
+ # GL Mapper Detail
+ {
+ 'account': u'credit_to',
+ 'against': u'against_expense_account',
+ 'against_voucher': u'name',
+ 'against_voucher_type': u"value:'Purchase Invoice'",
+ 'aging_date': u'aging_date',
+ 'company': u'company',
+ 'credit': u'total_amount_to_pay',
+ 'debit': u'value:0',
+ u'doctype': u'GL Mapper Detail',
+ 'fiscal_year': u'fiscal_year',
+ 'is_opening': u'is_opening',
+ 'posting_date': u'posting_date',
+ 'remarks': u'remarks',
+ 'transaction_date': u'voucher_date',
+ 'voucher_no': u'name',
+ 'voucher_type': u'doctype'
+ }
+]
\ No newline at end of file
diff --git a/accounts/doctype/gl_control/gl_control.py b/accounts/doctype/gl_control/gl_control.py
index d648ec7..470f813 100644
--- a/accounts/doctype/gl_control/gl_control.py
+++ b/accounts/doctype/gl_control/gl_control.py
@@ -182,7 +182,7 @@
if le_map['table_field']:
for d in getlist(doclist,le_map['table_field']):
# purchase_tax_details is the table of other charges in purchase cycle
- if le_map['table_field'] != 'purchase_tax_details' or (le_map['table_field'] == 'purchase_tax_details' and d.fields.get('category') != 'For Valuation'):
+ if le_map['table_field'] != 'purchase_tax_details' or (le_map['table_field'] == 'purchase_tax_details' and d.fields.get('category') != 'Valuation'):
self.make_single_entry(doc,d,le_map,cancel, merge_entries)
else:
self.make_single_entry(None,doc,le_map,cancel, merge_entries)
diff --git a/accounts/search_criteria/purchase_register/purchase_register.py b/accounts/search_criteria/purchase_register/purchase_register.py
index 5e77d5c..9c33e2a 100644
--- a/accounts/search_criteria/purchase_register/purchase_register.py
+++ b/accounts/search_criteria/purchase_register/purchase_register.py
@@ -37,7 +37,7 @@
from `tabPurchase Taxes and Charges`
where parenttype = 'Purchase Invoice'
and add_deduct_tax = 'Add'
- and category in ('For Total', 'For Both')
+ and category in ('Total', 'Valuation and Total')
and docstatus=1
order by account_head asc""")]
@@ -82,7 +82,7 @@
where parent = '%s'
and parenttype = 'Purchase Invoice'
and add_deduct_tax = 'Add'
- and category in ('For Total', 'For Both')
+ and category in ('Total', 'Valuation and Total')
group by account_head
""" %(r[col_idx['ID']],))
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index 33c05df..f295aa0 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -469,16 +469,18 @@
//--------------------------
$td(otc,i+1,0).innerHTML = cl[i].item_code;
- var tax = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
var total = net_total;
for(var t=0;t<tax.length;t++){
var account = tax[t].account_head;
$td(otc,0,t+1).innerHTML = account?account:'';
//Check For Rate
- if(cl[i].item_tax_rate && check_tax[account]!=null) {rate = flt(check_tax[account]);}
- else // if particular item doesn't have particular rate it will take other charges rate
+ if(cl[i].item_tax_rate && check_tax[account]!=null) {
+ rate = flt(check_tax[account]);
+ } else {
+ // if particular item doesn't have particular rate it will take other charges rate
rate = flt(tax[t].rate);
+ }
//Check For Rate and get tax amount
var tax_amount = cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t, cl[i], rate);
@@ -491,18 +493,18 @@
if(tax[t].add_deduct_tax == 'Add'){
// this is calculation part for all types
if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
- tax[t].total_amount = flt(tax_amount.toFixed(2)); //stores actual tax amount in virtual field
- tax[t].total_tax_amount = flt(prev_total.toFixed(2)); //stores total amount in virtual field
- tax[t].tax_amount += flt(tax_amount.toFixed(2));
+ tax[t].total_amount = flt(tax_amount); //stores actual tax amount in virtual field
+ tax[t].total_tax_amount = flt(prev_total); //stores total amount in virtual field
+ tax[t].tax_amount += flt(tax_amount);
var total_amount = flt(tax[t].tax_amount);
total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount);
- if(tax[t].category != "For Valuation"){
- set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':total_amount, 'total':flt(total)+flt(tax[t].tax_amount)/*_tax_amount)*/}, other_fname);
+ if(tax[t].category != "Valuation"){
+ set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':roundNumber(total_amount, 2), 'total':roundNumber(flt(total)+flt(tax[t].tax_amount), 2)}, other_fname);
prev_total += flt(tax[t].total_amount);
total += flt(tax[t].tax_amount); // for adding total to previous amount
}
else{
- set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':total_amount, 'total':flt(total)/*_tax_amount)*/}, other_fname);
+ set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':roundNumber(total_amount, 2), 'total':roundNumber(flt(total), 2)}, other_fname);
prev_total = prev_total;
}
//prev_total += flt(tax[t].total_amount); // for previous row total
@@ -512,25 +514,25 @@
else
$td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +fmt_money(tax[t].total_amount);
- if (tax[t].category != "For Total"){
+ if (tax[t].category != "Total"){
item_tax += tax[t].total_amount;
}
}
else if(tax[t].add_deduct_tax == 'Deduct'){
// this is calculation part for all types
if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
- tax[t].total_amount = flt(tax_amount.toFixed(2)); //stores actual tax amount in virtual field
- tax[t].total_tax_amount = flt(prev_total.toFixed(2)); //stores total amount in virtual field
- tax[t].tax_amount += flt(tax_amount.toFixed(2));
+ tax[t].total_amount = flt(tax_amount); //stores actual tax amount in virtual field
+ tax[t].total_tax_amount = flt(prev_total); //stores total amount in virtual field
+ tax[t].tax_amount += flt(tax_amount);
var total_amount = flt(tax[t].tax_amount);
total_tax_amount = flt(tax[t].total_tax_amount) - flt(total_amount);
- if(tax[t].category != "For Valuation"){
- set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'tax_amount':total_amount, 'total':flt(total)-flt(tax[t].tax_amount)/*_tax_amount)*/}, other_fname);
+ if(tax[t].category != "Valuation"){
+ set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'tax_amount':roundNumber(total_amount, 2), 'total':roundNumber(flt(total)-flt(tax[t].tax_amount), 2)}, other_fname);
prev_total -= flt(tax[t].total_amount);
total -= flt(tax[t].tax_amount); // for adding total to previous amount
}
else{
- set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'tax_amount':total_amount, 'total':flt(total)/*_tax_amount)*/}, other_fname);
+ set_multiple('Purchase Taxes and Charges', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'tax_amount':roundNumber(total_amount, 2), 'total':roundNumber(flt(total), 2)}, other_fname);
prev_total = prev_total;
}
//prev_total += flt(tax[t].total_amount); // for previous row total
@@ -540,7 +542,7 @@
else
$td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +fmt_money(tax[t].total_amount);
- if (tax[t].category != "For Total"){
+ if (tax[t].category != "Total"){
item_tax -= tax[t].total_amount;
}
}
@@ -549,66 +551,9 @@
}
set_multiple(tname, cl[i].name, {'item_tax_amount': item_tax }, fname);
}
-}
-
-
-
-
-// ******* Calculation of total amounts of document (item amount + other charges)****************
-cur_frm.cscript.calc_doc_values = function(doc, tname, fname, other_fname) {
- doc = locals[doc.doctype][doc.name];
- var net_total = 0; var total_tax = 0; var other_charges_added = 0;
- var other_charges_deducted = 0;
- var cl = getchildren(tname, doc.name, fname);
- for(var i = 0; i<cl.length; i++){
- net_total += flt(cl[i].amount);
+ for(var t=0;t<tax.length;t++){
+ tax[t].tax_amount = roundNumber(tax[t].tax_amount, 2);
}
- var d = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
- for(var j = 0; j<d.length; j++){
- if(d[j].category != 'For Valuation'){
-
- if(d[j].add_deduct_tax == 'Add'){
- other_charges_added += flt(d[j].tax_amount);
- total_tax += flt(d[j].tax_amount);
- }
- if(d[j].add_deduct_tax == 'Deduct'){
- other_charges_deducted += flt(d[j].tax_amount);
- total_tax -= flt(d[j].tax_amount);
- }
- }
- }
- doc.net_total = flt(net_total);
- doc.total_tax = flt(total_tax);
-
- doc.other_charges_added = flt(other_charges_added);
- doc.other_charges_deducted = flt(other_charges_deducted);
- doc.grand_total = flt(flt(net_total) + flt(other_charges_added) - flt(other_charges_deducted));
- doc.rounded_total = Math.round(doc.grand_total);
- doc.net_total_import = flt(flt(net_total) / flt(doc.conversion_rate));
- doc.other_charges_added_import = flt(flt(other_charges_added) / flt(doc.conversion_rate));
- doc.other_charges_deducted_import = flt(flt(other_charges_deducted) / flt(doc.conversion_rate));
- doc.grand_total_import = flt(flt(doc.grand_total) / flt(doc.conversion_rate));
- doc.rounded_total_import = Math.round(doc.grand_total_import);
-
- refresh_many(['net_total','total_taxes','grand_total']);
-
-
- if(doc.doctype == 'Purchase Invoice'){
- calculate_outstanding(doc);
- }
-}
-
-var calculate_outstanding = function(doc) {
- var t_tds_tax = 0.0;
- doc.total_tds_on_voucher = flt(doc.ded_amount);
-
- // total amount to pay
- doc.total_amount_to_pay = flt(flt(doc.net_total) + flt(doc.other_charges_added) - flt(doc.other_charges_deducted) - flt(doc.total_tds_on_voucher));
-
- // outstanding amount
- if(doc.docstatus==0) doc.outstanding_amount = flt(doc.net_total) + flt(doc.other_charges_added) - flt(doc.other_charges_deducted) - flt(doc.total_tds_on_voucher) - flt(doc.total_advance);
-
- refresh_many(['total_tds_on_voucher','total_amount_to_pay', 'outstanding_amount']);
}
@@ -652,6 +597,64 @@
}
}
+// ******* Calculation of total amounts of document (item amount + other charges)****************
+cur_frm.cscript.calc_doc_values = function(doc, tname, fname, other_fname) {
+ doc = locals[doc.doctype][doc.name];
+ var net_total = 0; var total_tax = 0; var other_charges_added = 0;
+ var other_charges_deducted = 0;
+ var cl = getchildren(tname, doc.name, fname);
+ for(var i = 0; i<cl.length; i++){
+ net_total += flt(cl[i].amount);
+ }
+ var d = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
+ for(var j = 0; j<d.length; j++){
+ if(d[j].category != 'Valuation'){
+
+ if(d[j].add_deduct_tax == 'Add'){
+ other_charges_added += flt(d[j].tax_amount);
+ total_tax += flt(d[j].tax_amount);
+ }
+ if(d[j].add_deduct_tax == 'Deduct'){
+ other_charges_deducted += flt(d[j].tax_amount);
+ total_tax -= flt(d[j].tax_amount);
+ }
+ }
+ }
+ doc.net_total = flt(net_total);
+ doc.total_tax = flt(total_tax);
+
+ doc.other_charges_added = roundNumber(flt(other_charges_added), 2);
+ doc.other_charges_deducted = roundNumber(flt(other_charges_deducted), 2);
+ doc.grand_total = roundNumber(flt(flt(net_total) + flt(other_charges_added) - flt(other_charges_deducted)), 2);
+ doc.rounded_total = Math.round(doc.grand_total);
+ doc.net_total_import = roundNumber(flt(flt(net_total) / flt(doc.conversion_rate)), 2);
+ doc.other_charges_added_import = roundNumber(flt(flt(other_charges_added) / flt(doc.conversion_rate)), 2);
+ doc.other_charges_deducted_import = roundNumber(flt(flt(other_charges_deducted) / flt(doc.conversion_rate)), 2);
+ doc.grand_total_import = roundNumber(flt(flt(doc.grand_total) / flt(doc.conversion_rate)), 2);
+ doc.rounded_total_import = Math.round(doc.grand_total_import);
+
+ refresh_many(['net_total','total_taxes','grand_total']);
+
+
+ if(doc.doctype == 'Purchase Invoice'){
+ calculate_outstanding(doc);
+ }
+}
+
+var calculate_outstanding = function(doc) {
+ var t_tds_tax = 0.0;
+ doc.total_tds_on_voucher = flt(doc.ded_amount);
+
+ // total amount to pay
+ doc.total_amount_to_pay = flt(flt(doc.net_total) + flt(doc.other_charges_added) - flt(doc.other_charges_deducted) - flt(doc.total_tds_on_voucher));
+
+ // outstanding amount
+ if(doc.docstatus==0) doc.outstanding_amount = flt(doc.net_total) + flt(doc.other_charges_added) - flt(doc.other_charges_deducted) - flt(doc.total_tds_on_voucher) - flt(doc.total_advance);
+
+ refresh_many(['total_tds_on_voucher','total_amount_to_pay', 'outstanding_amount']);
+}
+
+
cur_frm.cscript.toggle_contact_section = function(doc) {
cur_frm.toggle_display("contact_section", doc.supplier);
}
diff --git a/install_erpnext.py b/install_erpnext.py
deleted file mode 100644
index 0577d6a..0000000
--- a/install_erpnext.py
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/usr/bin/python
-from __future__ import unicode_literals
-import os, commands
-
-# ask for root mysql password
-import getpass
-
-root_pwd = None
-while not root_pwd:
- root_pwd = getpass.getpass("MySQL Root user's Password: ")
-
-# test root connection
-op = commands.getoutput("mysql -u root -p%s -e 'exit'" % \
- root_pwd.replace('$', '\$').replace(' ', '\ '))
-if "access denied" in op.lower():
- raise Exception("Incorrect MySQL Root user's password")
-
-# ask for new dbname
-new_dbname = None
-while not new_dbname:
- new_dbname = raw_input("New ERPNext Database Name: ")
-
-# ask for new dbpassword
-new_dbpassword = None
-while not new_dbpassword:
- new_dbpassword = raw_input("New ERPNext Database's Password: ")
-
-# get erpnext path
-erpnext_path = os.path.dirname(os.path.abspath(__file__))
-os.chdir(erpnext_path)
-
-# setup backups
-if not os.path.exists(os.path.join(erpnext_path, 'backups')):
- os.makedirs('backups')
- os.symlink(os.path.join(erpnext_path, 'backups'),
- os.path.join(erpnext_path, 'public', 'backups'))
-
-# setup files
-if not os.path.exists(os.path.join(erpnext_path, 'files')):
- os.makedirs('files')
- os.symlink(os.path.join(erpnext_path, 'files'),
- os.path.join(erpnext_path, 'public', 'files'))
-
-# setup logs
-if not os.path.exists(os.path.join(erpnext_path, 'logs')):
- os.makedirs('logs')
- os.system('touch logs/error_log.txt')
-
-# setup lib -- framework repo with read only access
-# change this if you have your own fork
-if not os.path.exists(os.path.join(erpnext_path, 'lib')):
- os.system('git clone https://github.com/webnotes/wnframework.git lib')
-
-# setup symlinks in public
-if not os.path.exists(os.path.join(erpnext_path, 'public', 'js', 'lib')):
- os.symlink(os.path.join(erpnext_path, 'lib', 'js', 'lib'),
- os.path.join(erpnext_path, 'public', 'js', 'lib'))
-if not os.path.exists(os.path.join(erpnext_path, 'public', 'images', 'lib')):
- os.symlink(os.path.join(erpnext_path, 'lib', 'images'),
- os.path.join(erpnext_path, 'public', 'images', 'lib'))
-
-# extract master
-if os.path.exists(os.path.join(erpnext_path, 'data', 'master.sql.gz')):
- os.system('gunzip data/master.sql.gz')
-
-# setup conf
-if not os.path.exists(os.path.join(erpnext_path, 'conf.py')):
- # read template conf file
- with open(os.path.join(erpnext_path, 'lib', 'conf', 'conf.py'), 'r') as template:
- content = template.read()
-
- # manipulate content
- import re
-
- # set new_dbname, new_dbpassword, files_path, backup_path, log_file_name
- content = re.sub("db_name.*", "db_name = '%s'" % new_dbname, content)
- content = re.sub("db_password.*", "db_password = '%s'" % new_dbpassword, content)
- content = re.sub("files_path.*", "files_path = '%s'" % \
- os.path.join(erpnext_path, 'files'), content)
- content = re.sub("backup_path.*", "backup_path = '%s'" % \
- os.path.join(erpnext_path, 'backups'), content)
- content = re.sub("log_file_name.*", "log_file_name = '%s'" % \
- os.path.join(erpnext_path, 'logs', 'error_log.txt'), content)
-
-
- # write conf file
- with open(os.path.join(erpnext_path, 'conf.py'), 'w') as new_conf:
- new_conf.write(content)
-
-# install db
-import sys
-sys.path.append('.')
-sys.path.append('lib')
-sys.path.append('app')
-
-from webnotes.install_lib.install import Installer
-inst = Installer('root', root_pwd)
-inst.import_from_db(new_dbname, source_path=os.path.join(erpnext_path, 'data', 'master.sql'), verbose = 1)
-
-# apply patches
-os.chdir(erpnext_path)
-os.system("lib/wnf.py --update origin master")
-
-# set filemode false
-os.system("git config core.filemode false")
-os.chdir(os.path.join(erpnext_path, 'lib'))
-os.system("git config core.filemode false")
-
-steps_remaining = """
-Notes:
-------
-
-sample apache conf file
-#-----------------------------------------------------------
-SetEnv PYTHON_EGG_CACHE /var/www
-
-# you can change 99 to any other port
-
-Listen 99
-NameVirtualHost *:99
-<VirtualHost *:99>
- ServerName localhost
- DocumentRoot {path to erpnext's folder}/public
- AddHandler cgi-script .cgi .xml .py
-
- <Directory {path to erpnext's folder}/public/>
- # directory specific options
- Options -Indexes +FollowSymLinks +ExecCGI
-
- # directory's index file
- DirectoryIndex web.py
-
- # rewrite rule
- RewriteEngine on
-
- # condition 1:
- # ignore login-page.html, app.html, blank.html, unsupported.html
- RewriteCond %{REQUEST_URI} ^((?!app\.html|blank\.html|unsupported\.html).)*$
-
- # condition 2: if there are no slashes
- # and file is .html or does not containt a .
- RewriteCond %{REQUEST_URI} ^(?!.+/)((.+\.html)|([^.]+))$
-
- # rewrite if both of the above conditions are true
- RewriteRule ^(.+)$ web.py?page=$1 [NC,L]
-
- AllowOverride all
- Order Allow,Deny
- Allow from all
- </Directory>
-</VirtualHost>
-#-----------------------------------------------------------
-
-To Do:
-
-* Configure apache/http conf file to point to public folder
-* chown recursively all files in your folder to apache user
-* login using: user="Administrator" and password="admin"
-
-"""
-
-print steps_remaining
-
diff --git a/patches/october_2012/reload_gl_mapper.py b/patches/october_2012/reload_gl_mapper.py
new file mode 100644
index 0000000..8d364ec
--- /dev/null
+++ b/patches/october_2012/reload_gl_mapper.py
@@ -0,0 +1,5 @@
+def execute():
+ import webnotes
+ from webnotes.modules import reload_doc
+ reload_doc("accounts", "GL Mapper", "Purchase Invoice")
+ reload_doc("accounts", "GL Mapper", "Purchase Invoice with write off")
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 340665b..d874e4d 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -611,4 +611,8 @@
'patch_module': 'patches.october_2012',
'patch_file': 'update_permission',
},
+ {
+ 'patch_module': 'patches.october_2012',
+ 'patch_file': 'reload_gl_mapper',
+ },
]
diff --git a/public/js/startup.js b/public/js/startup.js
index 2d3e258..fe9507f 100644
--- a/public/js/startup.js
+++ b/public/js/startup.js
@@ -143,7 +143,8 @@
}
erpnext.set_user_background = function(src) {
- set_style(repl('#body_div { background: url("files/%(src)s") repeat;}', {src:src}))
+ set_style(repl('#body_div { background: url("files/%(src)s") repeat fixed;}',
+ {src:src}))
}
// subject, sender, description
diff --git a/setup/doctype/email_digest/email_digest.py b/setup/doctype/email_digest/email_digest.py
index 421ae64..9c5a24f 100644
--- a/setup/doctype/email_digest/email_digest.py
+++ b/setup/doctype/email_digest/email_digest.py
@@ -338,8 +338,14 @@
def send():
from webnotes.model.code import get_obj
+ from webnotes.utils import getdate
now_date = now_datetime().date()
+ import conf
+ if hasattr(conf, "expires_on") and now_date > getdate(conf.expires_on):
+ # do not send email digests to expired accounts
+ return
+
for ed in webnotes.conn.sql("""select name from `tabEmail Digest`
where enabled=1 and docstatus<2""", as_list=1):
ed_obj = get_obj('Email Digest', ed[0])
diff --git a/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
index 6d235ae..d9a4cee 100644
--- a/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
+++ b/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
@@ -99,10 +99,10 @@
self.prwise_cost[pr] = self.prwise_cost.get(pr, 0) + amt
cumulative_grand_total += amt
- pr_oc_row = sql("select name from `tabPurchase Taxes and Charges` where parent = %s and category = 'For Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s",(pr, lc.account_head))
+ pr_oc_row = sql("select name from `tabPurchase Taxes and Charges` where parent = %s and category = 'Valuation' and add_deduct_tax = 'Add' and charge_type = 'Actual' and account_head = %s",(pr, lc.account_head))
if not pr_oc_row: # add if not exists
ch = addchild(pr_obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1)
- ch.category = 'For Valuation'
+ ch.category = 'Valuation'
ch.add_deduct_tax = 'Add'
ch.charge_type = 'Actual'
ch.description = lc.description
@@ -201,7 +201,7 @@
total_amount = flt(ocd[oc].tax_amount)
total_tax_amount = flt(ocd[oc].total_tax_amount) + (add_ded * flt(total_amount))
- if ocd[oc].category != "For Valuation":
+ if ocd[oc].category != "Valuation":
prev_total += add_ded * flt(ocd[oc].total_amount)
total += add_ded * flt(ocd[oc].tax_amount)
ocd[oc].total = total
@@ -210,7 +210,7 @@
ocd[oc].total = flt(total)
ocd[oc].save()
- if ocd[oc].category != "For Total":
+ if ocd[oc].category != "Total":
item_tax += add_ded * ocd[oc].total_amount
return total, prev_total, item_tax