mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 07:54:46 +00:00
[selling/buying] [fixes] fixes in client side code, server side code, print formats
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 + ")";
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user