Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait 2012-11-28 16:49:53 +05:30
commit c62fe40e85
7 changed files with 69 additions and 28 deletions

View File

@ -241,7 +241,6 @@ class DocType:
self.return_data.append([5, 'Profit/Loss (Provisional)'] + level0_diff)
for i in range(len(totals)): # make totals
level0_diff[i] = flt(totals[i]) + level0_diff[i]
self.return_data.append([4, 'Total '+c[0]] + level0_diff)
else:
self.return_data.append([4, 'Total '+c[0]] + totals)
@ -252,7 +251,6 @@ class DocType:
self.return_data.append([5, 'Profit/Loss (Provisional)'] + level0_diff)
for i in range(len(totals)): # make totals
level0_diff[i] = flt(totals[i]) + level0_diff[i]
self.return_data.append([4, 'Total Income'] + level0_diff)
else:
self.return_data.append([4, 'Total '+c[0]] + totals)

View File

@ -141,6 +141,43 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
}
this.update_groups();
this.accounts_initialized = true;
// show Net Profit / Loss
var net_profit = {
company: me.company,
id: "Net Profit / Loss",
name: "Net Profit / Loss",
indent: 0,
opening: 0,
checked: false,
is_pl_account: me.pl_or_bs=="Balance Sheet" ? "No" : "Yes",
};
$.each(me.data, function(i, ac) {
if(!ac.parent_account && me.apply_filter(ac, "company")) {
if(me.pl_or_bs == "Balance Sheet") {
var valid_account = ac.is_pl_account!="Yes";
var do_addition_for = "Debit";
} else {
var valid_account = ac.is_pl_account=="Yes";
var do_addition_for = "Credit";
}
if(valid_account) {
$.each(me.columns, function(i, col) {
if(col.formatter==me.currency_formatter) {
if(!net_profit[col.field]) net_profit[col.field] = 0;
if(ac.debit_or_credit==do_addition_for) {
net_profit[col.field] += ac[col.field];
} else {
net_profit[col.field] -= ac[col.field];
}
}
});
}
}
});
this.data.push(net_profit);
},
add_balance: function(field, account, gl) {
account[field] = flt(account[field]) +

View File

@ -75,6 +75,13 @@ cur_frm.cscript.make_contact = function() {
parent: cur_frm.fields_dict['contact_html'].wrapper,
page_length: 2,
new_doctype: "Contact",
custom_new_doc: function(doctype) {
var contact = LocalDB.create('Contact');
contact = locals['Contact'][contact];
contact.supplier = cur_frm.doc.name;
contact.supplier_name = cur_frm.doc.supplier_name;
wn.set_route("Form", "Contact", contact.name);
},
get_query: function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where supplier='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
},

View File

@ -84,12 +84,7 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({
},
prepare_data: function() {
var me = this;
if(this.data) {
// refresh -- only initialize
$.each(this.data, function(i, d) {
me.init_account(d);
})
} else {
if(!this.primary_data) {
// make accounts list
me.data = [];
me.parent_map = {};
@ -103,10 +98,16 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({
if(d.parent_account) {
me.parent_map[d.name] = d.parent_account;
}
me.init_account(d);
});
me.primary_data = [].concat(me.data);
}
me.data = [].concat(me.primary_data);
$.each(me.data, function(i, d) {
me.init_account(d);
});
this.set_indent();
this.prepare_balances();

View File

@ -93,6 +93,16 @@ cur_frm.cscript.make_contact = function() {
cur_frm.contact_list = new wn.ui.Listing({
parent: cur_frm.fields_dict['contact_html'].wrapper,
page_length: 2,
custom_new_doc: function(doctype) {
var contact = LocalDB.create('Contact');
contact = locals['Contact'][contact];
contact.customer = cur_frm.doc.name;
contact.customer_name = cur_frm.doc.customer_name;
if(cur_frm.doc.customer_type == 'Individual') {
contact.first_name = cur_frm.doc.customer_name;
}
wn.set_route("Form", "Contact", contact.name);
},
new_doctype: "Contact",
get_query: function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where customer='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"

View File

@ -76,6 +76,12 @@ cur_frm.cscript.make_contact = function() {
parent: cur_frm.fields_dict['contact_html'].wrapper,
page_length: 2,
new_doctype: "Contact",
custom_new_doc: function(doctype) {
var contact = LocalDB.create('Contact');
contact = locals['Contact'][contact];
contact.sales_partner = cur_frm.doc.name;
wn.set_route("Form", "Contact", contact.name);
},
get_query: function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
},
@ -92,7 +98,6 @@ cur_frm.cscript.make_contact = function() {
});
}
cur_frm.contact_list.run();
}
cur_frm.fields_dict['partner_target_details'].grid.get_field("item_group").get_query = function(doc, dt, dn) {

View File

@ -23,23 +23,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query;
var route = wn.get_route();
if(route[1]=='Supplier') {
var supplier = wn.container.page.frm.doc;
doc.supplier = supplier.name;
doc.supplier_name = supplier.supplier_name;
} else if(route[1]=='Customer') {
var customer = wn.container.page.frm.doc;
doc.customer = customer.name;
doc.customer_name = customer.customer_name;
if(customer.customer_type == 'Individual') {
doc.first_name = customer.customer_name;
}
} else if(route[1]=='Sales Partner') {
var sp = wn.container.page.frm.doc;
doc.sales_partner = sp.name;
}
}
cur_frm.cscript.refresh = function() {