[selling/buying] [fixes] fixes in client side code, server side code, print formats

This commit is contained in:
Anand Doshi 2013-05-28 17:23:36 +05:30
parent a3d8494c77
commit 923d41dfd2
37 changed files with 352 additions and 324 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -18,16 +18,11 @@ cur_frm.cscript.tname = "Purchase Invoice Item";
cur_frm.cscript.fname = "entries";
cur_frm.cscript.other_fname = "purchase_tax_details";
wn.provide("erpnext.accounts");
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.provide("erpnext.accounts");
erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.extend({
setup: function() {
this._super();
},
onload: function() {
this._super();
@ -44,13 +39,13 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext
// Show / Hide button
if(doc.docstatus==1 && doc.outstanding_amount > 0)
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
this.frm.add_custom_button('Make Payment Entry', this.make_bank_voucher);
if(doc.docstatus==1) {
cur_frm.add_custom_button('View Ledger', cur_frm.cscript.view_ledger_entry);
this.frm.add_custom_button('View Ledger', this.view_ledger_entry);
}
cur_frm.cscript.is_opening(doc);
this.is_opening(doc);
},
credit_to: function() {
@ -63,13 +58,13 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext
},
allocated_amount: function() {
this.calculate_total_advance();
this.calculate_total_advance("Purchase Invoice", "advance_allocation_details");
this.frm.refresh_fields();
},
}
});
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new erpnext.buying.PurchaseInvoiceController({frm: cur_frm}));
$.extend(cur_frm.cscript, new erpnext.accounts.PurchaseInvoiceController({frm: cur_frm}));
cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {

View File

@ -92,7 +92,7 @@ class DocType(BuyingController):
return ret
def set_supplier_defaults(self):
# TODO cleanup these methods
self.doc.fields.update(self.get_cust())
self.doc.fields.update(self.get_credit_to())
super(DocType, self).set_supplier_defaults()

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-05-07 13:50:30",
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-05-13 11:12:56",
"modified": "2013-05-28 12:18:35",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -89,10 +89,11 @@
"read_only": 0
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "supplier_name",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"in_list_view": 1,
"label": "Name",
"oldfieldname": "supplier_name",
@ -100,34 +101,38 @@
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Address",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Contact",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@ -392,6 +397,7 @@
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
@ -399,7 +405,6 @@
"read_only": 0
},
{
"depends_on": "eval:doc.supplier",
"doctype": "DocField",
"fieldname": "supplier_address",
"fieldtype": "Link",
@ -415,7 +420,6 @@
"width": "50%"
},
{
"depends_on": "eval:doc.supplier",
"doctype": "DocField",
"fieldname": "contact_person",
"fieldtype": "Link",

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-04-19 11:00:06",
"creation": "2013-05-21 16:16:04",
"docstatus": 0,
"modified": "2013-05-07 11:23:56",
"modified": "2013-05-28 12:02:02",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -101,7 +101,7 @@
"oldfieldname": "tax_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"read_only": 0,
"read_only": 1,
"reqd": 0
},
{
@ -159,35 +159,5 @@
"print_hide": 1,
"read_only": 0,
"search_index": 0
},
{
"description": "Cheating Field\nPlease do not delete ",
"doctype": "DocField",
"fieldname": "total_tax_amount",
"fieldtype": "Currency",
"hidden": 1,
"label": "Total +Tax",
"no_copy": 1,
"oldfieldname": "total_tax_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
"description": "Cheating Field\nPlease do not delete ",
"doctype": "DocField",
"fieldname": "total_amount",
"fieldtype": "Currency",
"hidden": 1,
"label": "Tax Amount",
"no_copy": 1,
"oldfieldname": "total_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
}
]

View File

@ -79,23 +79,19 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
},
allocated_amount: function() {
this.calculate_total_advance();
this.calculate_total_advance("Sales Invoice", "advance_adjustment_details");
this.frm.refresh_fields();
},
write_off_outstanding_amount_automatically: function() {
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
wn.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
// this will make outstanding amount 0
this.frm.set_value("write_off_amount",
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount), precision("write_off_amount"));
}
this.frm.runclientscript("write_off_amount");
// TODO doubt?
// if write off amount = grand total - paid amount
// then why is outstanding amount = grand total - write off amount - paid amount - advance
// when write off amount already is grand total - paid amount!
},
write_off_amount: function() {
@ -137,8 +133,6 @@ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], false);
}
cur_frm.toggle_display("contact_section", doc.customer);
// India related fields
var cp = wn.control_panel;
if (cp.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-05-21 16:16:41",
"creation": "2013-05-24 19:29:05",
"docstatus": 0,
"modified": "2013-05-21 18:25:07",
"modified": "2013-05-28 12:43:23",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -120,10 +120,11 @@
"read_only": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"in_list_view": 1,
"label": "Name",
"oldfieldname": "customer_name",
@ -131,34 +132,38 @@
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Address",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Contact",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@ -748,6 +753,7 @@
"read_only": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-02-22 01:27:41",
"creation": "2013-04-24 11:39:32",
"docstatus": 0,
"modified": "2013-04-17 14:05:50",
"modified": "2013-05-28 11:59:02",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -85,6 +85,7 @@
"oldfieldname": "tax_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"read_only": 1,
"reqd": 0
},
{
@ -128,34 +129,6 @@
"print_hide": 1,
"search_index": 1
},
{
"description": "Cheating Field\nPlease do not delete ",
"doctype": "DocField",
"fieldname": "total_tax_amount",
"fieldtype": "Currency",
"hidden": 1,
"label": "Total Tax Amount",
"no_copy": 1,
"oldfieldname": "total_tax_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"report_hide": 1
},
{
"description": "Cheating Field\nPlease do not delete ",
"doctype": "DocField",
"fieldname": "total_amount",
"fieldtype": "Currency",
"hidden": 1,
"label": "Total Amount",
"no_copy": 1,
"oldfieldname": "total_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"report_hide": 1
},
{
"allow_on_submit": 0,
"description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount",

View File

@ -53,10 +53,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
},
validate: function() {
this.calculate_taxes_and_totals();
},
supplier: function() {
if(this.frm.doc.supplier || this.frm.doc.credit_to) {
if(!this.frm.doc.company) {
@ -79,7 +75,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
});
}
}
}
},
item_code: function(doc, cdt, cdn) {
var me = this;
@ -133,7 +129,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
},
discount_rate: function(doc, cdt, cdn) {
this.import_rate(doc, cdt, cdn);
this.import_ref_rate(doc, cdt, cdn);
},
import_rate: function(doc, cdt, cdn) {
@ -159,7 +155,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
child: item,
args: {
item_code: item.item_code,
uom: item.uom,
uom: item.uom
},
callback: function(r) {
if(!r.exc) {
@ -178,7 +174,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
conversion_factor: function(doc, cdt, cdn) {
if(wn.meta.get_docfield(cdt, "stock_qty", cdn)) {
var item = wn.model.get_doc(cdt, cdn);
wn.model.round_floats_in(item, ["qty", "conversion_factor"])
wn.model.round_floats_in(item, ["qty", "conversion_factor"]);
item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
refresh_field("stock_qty", item.name, item.parentfield);
}
@ -192,7 +188,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
child: item,
args: {
item_code: item.item_code,
warehouse: item.warehouse,
warehouse: item.warehouse
}
});
}
@ -211,9 +207,16 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
}
},
category: function(doc, cdt, cdn) {
// should be the category field of tax table
if(cdt != doc.doctype) {
this.calculate_taxes_and_totals();
}
},
calculate_taxes_and_totals: function() {
this._super();
this.calculate_total_advance();
this.calculate_total_advance("Purchase Invoice", "advance_allocation_details");
this.frm.refresh_fields();
},
@ -305,10 +308,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
}
},
calculate_total_advance: function() {
this._super("Purchase Invoice", "advance_allocation_details");
},
calculate_outstanding_amount: function() {
if(this.frm.doc.doctype == "Purchase Invoice" && this.frm.doc.docstatus < 2) {
wn.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]);
@ -331,12 +330,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
},
show_item_wise_taxes: function() {
$(this.get_item_wise_taxes_html())
.appendTo($(this.frm.fields_dict.tax_calculation.wrapper).empty());
},
recalculate: function() {
this.calculate_taxes_and_totals();
if(this.frm.fields_dict.tax_calculation) {
$(this.get_item_wise_taxes_html())
.appendTo($(this.frm.fields_dict.tax_calculation.wrapper).empty());
}
},
set_dynamic_labels: function(doc, dt, dn) {
@ -354,7 +351,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
$.each(fields_list, function(i, fname) {
var docfield = wn.meta.get_docfield(me.frm.doc.doctype, fname);
if(docfield) {
var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, "");
var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
field_label_map[fname] = label.trim() + " (" + currency + ")";
}
});
@ -383,7 +380,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
this.frm.doc.currency != company_currency);
this.frm.toggle_display(["plc_conversion_rate"],
this.frm.price_list_currency != company_currency)
this.frm.price_list_currency != company_currency);
// set labels
$.each(field_label_map, function(fname, label) {
@ -400,12 +397,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
$.each(fields_list, function(i, fname) {
var docfield = wn.meta.get_docfield(grid_doctype, fname);
if(docfield) {
var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, "");
var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
field_label_map[grid_doctype + "-" + fname] =
label.trim() + " (" + currency + ")";
}
});
}
};
setup_field_label_map(["purchase_rate", "purchase_ref_rate", "amount", "rate"],
company_currency, this.fname);
@ -413,7 +410,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
setup_field_label_map(["import_rate", "import_ref_rate", "import_amount"],
this.frm.doc.currency, this.fname);
setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
if(this.frm.fields_dict[this.other_fname]) {
setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
}
if(this.frm.fields_dict["advance_allocation_details"]) {
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
@ -433,9 +432,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
$.each(field_label_map, function(fname, label) {
$wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label);
});
},
}
});
// to save previous state of cur_frm.cscript
@ -449,4 +446,4 @@ $.extend(cur_frm.cscript, prev_cscript);
var tname = cur_frm.cscript.tname;
var fname = cur_frm.cscript.fname;
var fname = cur_frm.cscript.fname;

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-25 16:01:24",
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-02-18 13:37:11",
"modified": "2013-05-28 12:20:33",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -65,43 +65,48 @@
"search_index": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "supplier_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"in_list_view": 1,
"label": "Name",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Address",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Contact",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@ -554,6 +559,7 @@
"oldfieldtype": "Text Editor"
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
@ -808,7 +814,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "Material User",
@ -831,7 +836,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "Purchase Manager",
@ -854,7 +858,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"match": "",
"permlevel": 0,
"report": 1,
"role": "Purchase User",
@ -866,7 +869,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"role": "All",
"submit": 0

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-07 11:42:55",
"creation": "2013-05-24 19:29:06",
"docstatus": 0,
"modified": "2013-05-22 11:59:52",
"modified": "2013-05-28 12:13:21",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -361,7 +361,7 @@
"oldfieldtype": "Currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"read_only": 1,
"width": "100px"
},
{

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-25 16:01:25",
"creation": "2013-05-21 16:16:45",
"docstatus": 0,
"modified": "2013-02-18 13:40:17",
"modified": "2013-05-28 12:19:41",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -65,43 +65,48 @@
"search_index": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "supplier_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"in_list_view": 1,
"label": "Name",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Address",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Contact",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@ -520,6 +525,7 @@
"oldfieldtype": "Text Editor"
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
@ -723,7 +729,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "All",

View File

@ -32,7 +32,7 @@ class AccountsController(TransactionBase):
validate_conversion_rate(self.doc.currency, self.doc.conversion_rate,
self.meta.get_label("conversion_rate"), self.doc.company)
# self.calculate_taxes_and_totals()
self.calculate_taxes_and_totals()
self.validate_value("grand_total", ">=", 0)
self.set_total_in_words()
@ -84,9 +84,6 @@ class AccountsController(TransactionBase):
def calculate_taxes_and_totals(self):
self.doc.conversion_rate = flt(self.doc.conversion_rate)
# TODO validate conversion rate
self.item_doclist = self.doclist.get({"parentfield": self.fname})
self.tax_doclist = self.doclist.get({"parentfield": self.other_fname})
@ -264,6 +261,15 @@ class AccountsController(TransactionBase):
item.fields[base_field] = flt((flt(item.fields[print_field],
self.precision(print_field, item)) * self.doc.conversion_rate),
self.precision(base_field, item))
def calculate_total_advance(self, parenttype, advance_parentfield):
if self.doc.doctype == parenttype and self.doc.docstatus < 2:
sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv))
for adv in self.doclist.get({"parentfield": advance_parentfield})])
self.doc.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance"))
self.calculate_outstanding_amount()
def get_gl_dict(self, args, cancel=None):
"""this method populates the common properties of a gl entry record"""

View File

@ -50,7 +50,7 @@ class BuyingController(StockController):
self.set_missing_item_details(get_item_details)
def set_supplier_defaults(self):
self.get_default_supplier_address()
self.get_default_supplier_address(self.doc.fields)
def get_purchase_tax_details(self):
self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")
@ -93,7 +93,7 @@ class BuyingController(StockController):
def calculate_taxes_and_totals(self):
self.other_fname = "purchase_tax_details"
super(BuyingController, self).calculate_taxes_and_totals()
self.calculate_outstanding_amount()
self.calculate_total_advance("Purchase Invoice", "advance_allocation_details")
def calculate_item_values(self):
# hack! - cleaned up in _cleanup()
@ -168,6 +168,10 @@ class BuyingController(StockController):
item.purchase_rate = item.rate
del item.fields["rate"]
if not self.meta.get_field("item_tax_amount", parentfield=self.fname):
for item in self.item_doclist:
del item.fields["item_tax_amount"]
def set_item_tax_amount(self, item, tax, current_tax_amount):
"""
item_tax_amount is the total tax amount applied on that item

View File

@ -102,9 +102,9 @@ class SellingController(StockController):
super(SellingController, self).calculate_taxes_and_totals()
self.calculate_total_advance("Sales Invoice", "advance_adjustment_details")
self.calculate_commission()
self.calculate_contribution()
# self.calculate_outstanding_amount()
def determine_exclusive_rate(self):
if not any((cint(tax.included_in_print_rate) for tax in self.tax_doclist)):
@ -201,15 +201,27 @@ class SellingController(StockController):
self.doc.rounded_total = round(self.doc.grand_total)
self.doc.rounded_total_export = round(self.doc.grand_total_export)
def calculate_commission(self):
self.round_floats_in(self.doc, ["net_total", "commission_rate"])
if self.doc.commission_rate > 100.0:
msgprint(_(self.meta.get_label("commission_rate")) + " " +
_("cannot be greater than 100"), raise_exception=True)
self.doc.total_commission = flt(self.doc.net_total * self.doc.commission_rate / 100.0,
self.precision("total_commission"))
def calculate_outstanding_amount(self):
# NOTE:
# write_off_amount is only for POS Invoice
# total_advance is only for non POS Invoice
if self.doc.doctype == "Sales Invoice" and self.doc.docstatus < 2:
self.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount",
"paid_amount"])
total_amount_to_pay = self.doc.grand_total - self.doc.write_off_amount
self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount,
self.precision("outstanding_amount"))
def calculate_commission(self):
if self.meta.get_field("commission_rate"):
self.round_floats_in(self.doc, ["net_total", "commission_rate"])
if self.doc.commission_rate > 100.0:
msgprint(_(self.meta.get_label("commission_rate")) + " " +
_("cannot be greater than 100"), raise_exception=True)
self.doc.total_commission = flt(self.doc.net_total * self.doc.commission_rate / 100.0,
self.precision("total_commission"))
def calculate_contribution(self):
total = 0.0

View File

@ -13,17 +13,4 @@ def execute():
for module, doctype in (("Accounts", "Sales Invoice Item"), ("Selling", "Sales Order Item"), ("Selling", "Quotation Item"),
("Stock", "Delivery Note Item")):
if cint(webnotes.conn.get_value("DocField", {"parent": doctype, "fieldname": "ref_rate"}, "read_only")) == 0 and \
not webnotes.conn.sql("""select name from `tabProperty Setter` where doc_type=%s and doctype_or_field='DocField'
and field_name='ref_rate' and property='read_only'""", doctype):
webnotes.bean({
"doctype": "Property Setter",
"doc_type": doctype,
"doctype_or_field": "DocField",
"field_name": "ref_rate",
"property": "read_only",
"property_type": "Check",
"value": "0"
}).insert()
webnotes.reload_doc(module, "DocType", doctype)

View File

@ -46,9 +46,7 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({
this.frm.clear_custom_buttons();
erpnext.hide_naming_series();
this.show_item_wise_taxes();
if(this.frm.fields_dict.currency)
this.currency();
this.frm.fields_dict.currency ? this.currency() : this.set_dynamic_labels();
},
onload_post_render: function() {
@ -67,6 +65,10 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({
}
},
validate: function() {
this.calculate_taxes_and_totals();
},
company: function() {
if(this.frm.doc.company) {
var me = this;
@ -132,6 +134,30 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({
this.calculate_taxes_and_totals();
},
tax_rate: function(doc, cdt, cdn) {
this.calculate_taxes_and_totals();
},
row_id: function(doc, cdt, cdn) {
var tax = wn.model.get_doc(cdt, cdn);
try {
this.validate_on_previous_row(tax);
this.calculate_taxes_and_totals();
} catch(e) {
tax.row_id = null;
refresh_field("row_id", tax.name, tax.parentfield);
throw e;
}
},
recalculate: function() {
this.calculate_taxes_and_totals();
},
recalculate_values: function() {
this.calculate_taxes_and_totals();
},
included_in_print_rate: function(doc, cdt, cdn) {
var tax = wn.model.get_doc(cdt, cdn);
try {
@ -267,14 +293,25 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({
});
},
_validate_before_fetch: function(fieldname) {
var me = this;
if(!me.frm.doc[fieldname]) {
return (wn._("Please specify") + ": " +
wn.meta.get_label(me.frm.doc.doctype, fieldname, me.frm.doc.name) +
". " + wn._("It is needed to fetch Item Details."));
}
return null;
},
validate_company_and_party: function(party_field) {
var me = this;
var valid = true;
var msg = "";
$.each(["company", party_field], function(i, fieldname) {
if(!me.frm.doc[fieldname]) {
var msg_for_fieldname = me._validate_before_fetch(fieldname);
if(msg_for_fieldname) {
msgprint(msg_for_fieldname);
valid = false;
msgprint(wn._("Please specify") + ": " +
wn.meta.get_label(me.frm.doc.doctype, fieldname, me.frm.doc.name) +
". " + wn._("It is needed to fetch Item Details."));
}
});
return valid;
@ -300,7 +337,7 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({
}
var company_currency = this.get_company_currency();
var valid_conversion_rate = conversion_rate ?
var valid_conversion_rate = this.frm.doc.conversion_rate ?
((this.frm.doc.currency == company_currency && this.frm.doc.conversion_rate == 1.0) ||
(this.frm.doc.currency != company_currency && this.frm.doc.conversion_rate != 1.0)) :
false;
@ -323,6 +360,7 @@ erpnext.TransactionController = wn.ui.form.Controller.extend({
this.calculate_taxes();
this.calculate_totals();
this._cleanup();
this.show_item_wise_taxes();
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -51,6 +51,18 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer");
},
validate_company_and_party: function(party_field) {
if(this.frm.doc.quotation_to == "Lead") {
return true;
} else if(!this.frm.doc.quotation_to) {
msgprint(wn._("Please select a value for" + " " + wn.meta.get_label(this.frm.doc.doctype,
"quotation_to", this.frm.doc.name)));
return false;
} else {
return this._super(party_field);
}
},
});
// for backward compatibility: combine new and previous states

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-05-22 12:10:46",
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
"modified": "2013-05-22 16:55:07",
"modified": "2013-05-28 14:50:59",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -78,6 +78,7 @@
"reqd": 1
},
{
"depends_on": "eval:doc.quotation_to == \"Customer\"",
"doctype": "DocField",
"fieldname": "customer",
"fieldtype": "Link",
@ -92,6 +93,7 @@
"search_index": 1
},
{
"depends_on": "eval:doc.quotation_to == \"Lead\"",
"doctype": "DocField",
"fieldname": "lead",
"fieldtype": "Link",
@ -105,19 +107,21 @@
"read_only": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"in_list_view": 1,
"label": "Customer Name",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"in_filter": 0,
"label": "Address",
"oldfieldname": "customer_address",
@ -128,29 +132,32 @@
"search_index": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"in_filter": 0,
"label": "Contact",
"print_hide": 0,
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"print_hide": 0,
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@ -614,6 +621,7 @@
"read_only": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "col_break98",
"fieldtype": "Column Break",
@ -667,6 +675,7 @@
"search_index": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_group",
"fieldtype": "Link",
@ -837,19 +846,6 @@
"read_only": 1,
"width": "150px"
},
{
"description": "The date at which current entry is corrected in the system.",
"doctype": "DocField",
"fieldname": "amendment_date",
"fieldtype": "Date",
"label": "Amendment Date",
"no_copy": 1,
"oldfieldname": "amendment_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 0,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "communication_history",
@ -886,23 +882,28 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales User",
"role": "Sales Manager",
"submit": 1,
"write": 1
},
{
"doctype": "DocPerm",
"role": "Customer"
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales Manager",
"role": "Sales User",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Customer",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,

View File

@ -29,29 +29,19 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
this.frm.add_fetch("sales_partner", "commission_rate", "commission_rate");
},
// 1
onload: function() {
this._super();
this.toggle_rounded_total();
// TODO set depends_on for customer related fields
},
validate: function() {
this.calculate_taxes_and_totals();
// TODO calc adjustment amount
},
customer: function() {
var me = this;
if(this.frm.doc.customer || this.frm.doc.debit_to) {
if(!this.frm.doc.company) {
this.frm.set_value("customer", null);
msgprint(wn._("Please specify Company"));
} else {
var me = this;
var price_list_name = this.frm.doc.price_list_name;
this.frm.call({
doc: this.frm.doc,
method: "set_customer_defaults",
@ -59,14 +49,14 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
callback: function(r) {
if(!r.exc) {
me.frm.refresh_fields();
if(me.frm.doc.price_list_name !== price_list_name) me.price_list_name();
(me.frm.doc.price_list_name !== price_list_name) ?
me.price_list_name() :
me.price_list_currency();
}
}
});
}
}
// TODO hide/unhide related fields
},
barcode: function(doc, cdt, cdn) {
@ -127,7 +117,12 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
adj_rate: function(doc, cdt, cdn) {
this.ref_rate(doc, cdt, cdn);
var item = wn.model.get_doc(cdt, cdn);
if(!item.ref_rate) {
item.adj_rate = 0.0;
} else {
this.ref_rate(doc, cdt, cdn);
}
},
export_rate: function(doc, cdt, cdn) {
@ -208,14 +203,11 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
calculate_taxes_and_totals: function() {
this._super();
this.calculate_total_advance();
this.calculate_total_advance("Sales Invoice", "advance_adjustment_details");
this.calculate_commission();
this.calculate_contribution();
// TODO
// outstanding amount
// check for custom_recalc in custom scripts of server
// TODO check for custom_recalc in custom scripts of server
this.frm.refresh_fields();
},
@ -325,14 +317,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
this.frm.doc.rounded_total_export = Math.round(this.frm.doc.grand_total_export);
},
calculate_total_advance: function() {
this._super("Sales Invoice", "advance_adjustment_details");
},
calculate_outstanding_amount: function() {
// TODO - I find this incorrect!
// see TODO of sales invoice.js / write_off_outstanding_amount_automatically
// NOTE:
// write_off_amount is only for POS Invoice
// total_advance is only for non POS Invoice
if(this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.docstatus < 2) {
wn.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount",
"paid_amount"]);
@ -343,15 +331,17 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
calculate_commission: function() {
if(this.frm.doc.commission_rate > 100) {
var msg = wn._(wn.meta.get_label(this.frm.doc.doctype, "commission_rate", this.frm.doc.name)) +
" " + wn._("cannot be greater than 100");
msgprint(msg);
throw msg;
}
if(this.frm.fields_dict.commission_rate) {
if(this.frm.doc.commission_rate > 100) {
var msg = wn._(wn.meta.get_label(this.frm.doc.doctype, "commission_rate", this.frm.doc.name)) +
" " + wn._("cannot be greater than 100");
msgprint(msg);
throw msg;
}
this.frm.doc.total_commission = flt(this.frm.doc.net_total * this.frm.doc.commission_rate / 100.0,
precision("total_commission"));
this.frm.doc.total_commission = flt(this.frm.doc.net_total * this.frm.doc.commission_rate / 100.0,
precision("total_commission"));
}
},
calculate_contribution: function() {
@ -373,8 +363,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
show_item_wise_taxes: function() {
$(this.get_item_wise_taxes_html())
.appendTo($(this.frm.fields_dict.other_charges_calculation.wrapper).empty());
if(this.frm.fields_dict.other_charges_calculation) {
$(this.get_item_wise_taxes_html())
.appendTo($(this.frm.fields_dict.other_charges_calculation.wrapper).empty());
}
},
get_charges: function() {
@ -407,7 +399,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
$.each(fields_list, function(i, fname) {
var docfield = wn.meta.get_docfield(me.frm.doc.doctype, fname);
if(docfield) {
var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, "");
var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
field_label_map[fname] = label.trim() + " (" + currency + ")";
}
});
@ -452,7 +444,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
$.each(fields_list, function(i, fname) {
var docfield = wn.meta.get_docfield(grid_doctype, fname);
if(docfield) {
var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, "");
var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
field_label_map[grid_doctype + "-" + fname] =
label.trim() + " (" + currency + ")";
}

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-05-21 16:16:41",
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
"modified": "2013-05-21 18:30:14",
"modified": "2013-05-28 15:05:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -76,42 +76,47 @@
"search_index": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"label": "Name",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Address",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Contact",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@ -448,7 +453,7 @@
"fieldname": "other_charges_total_export",
"fieldtype": "Currency",
"label": "Taxes and Charges Total (Export)",
"options": "company",
"options": "currency",
"print_hide": 1,
"read_only": 1
},
@ -596,6 +601,7 @@
"print_hide": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_info",
"fieldtype": "Section Break",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-05-21 16:16:31",
"creation": "2013-05-24 19:29:09",
"docstatus": 0,
"modified": "2013-05-21 18:30:32",
"modified": "2013-05-28 12:26:04",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -76,10 +76,11 @@
"search_index": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"in_list_view": 1,
"label": "Customer Name",
"read_only": 1
@ -96,34 +97,38 @@
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Shipping Address",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Contact",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@ -690,6 +695,7 @@
"width": "100px"
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_info",
"fieldtype": "Section Break",

View File

@ -17,8 +17,8 @@
cur_frm.cscript.tname = "Material Request Item";
cur_frm.cscript.fname = "indent_details";
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.extend({
refresh: function(doc) {
@ -48,13 +48,19 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
cur_frm.toggle_display("sales_order_no", false);
cur_frm.fields_dict.indent_details.grid.set_column_disp("sales_order_no", false);
}
},
validate_company_and_party: function(party_field) {
return true;
},
calculate_taxes_and_totals: function() {
return;
}
});
var new_cscript = new erpnext.buying.MaterialRequestController({frm: cur_frm});
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new_cscript);
$.extend(cur_frm.cscript, new erpnext.buying.MaterialRequestController({frm: cur_frm}));
cur_frm.cscript.qty = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-25 16:01:29",
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
"modified": "2013-02-02 19:09:37",
"modified": "2013-05-28 12:21:17",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -75,43 +75,48 @@
"width": "150px"
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "supplier_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"in_list_view": 1,
"label": "Supplier Name",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Address",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Contact",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@ -569,6 +574,7 @@
"oldfieldtype": "Text Editor"
},
{
"depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
@ -888,7 +894,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "Material Manager",
@ -911,7 +916,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "Material User",
@ -934,7 +938,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"match": "",
"permlevel": 0,
"report": 1,
"role": "Purchase User",
@ -946,7 +949,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"role": "Purchase User",
"submit": 0

View File

@ -1,8 +1,8 @@
[
{
"creation": "2013-03-07 11:42:59",
"creation": "2013-05-24 19:29:10",
"docstatus": 0,
"modified": "2013-05-22 12:01:08",
"modified": "2013-05-28 12:13:59",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -357,7 +357,7 @@
"oldfieldtype": "Currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"read_only": 1,
"width": "100px"
},
{
@ -370,7 +370,7 @@
"oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data",
"print_hide": 1,
"read_only": 0
"read_only": 1
},
{
"doctype": "DocField",

View File

@ -192,7 +192,8 @@ class TransactionBase(DocListController):
# Get Supplier Default Primary Address - first load
# -----------------------
def get_default_supplier_address(self, args):
args = load_json(args)
if isinstance(args, basestring):
args = load_json(args)
address_text, address_name = self.get_address_text(supplier=args['supplier'])
ret = {
'supplier_address' : address_name,