[pos] pos view fixed for all purchase & sales cycle

This commit is contained in:
Akhilesh Darjee 2013-09-25 11:09:33 +05:30
parent dd68de824d
commit 10dce341c8
8 changed files with 83 additions and 31 deletions

View File

@ -62,13 +62,14 @@ class DocType(BuyingController):
"purchase_receipt_details") "purchase_receipt_details")
def get_credit_to(self): def get_credit_to(self):
ret = {}
if self.doc.supplier:
acc_head = sql("""select name, credit_days from `tabAccount` acc_head = sql("""select name, credit_days from `tabAccount`
where (name = %s or (master_name = %s and master_type = 'supplier')) where (name = %s or (master_name = %s and master_type = 'supplier'))
and docstatus != 2 and company = %s""", and docstatus != 2 and company = %s""",
(cstr(self.doc.supplier) + " - " + self.company_abbr, (cstr(self.doc.supplier) + " - " + self.company_abbr,
self.doc.supplier, self.doc.company)) self.doc.supplier, self.doc.company))
ret = {}
if acc_head and acc_head[0][0]: if acc_head and acc_head[0][0]:
ret['credit_to'] = acc_head[0][0] ret['credit_to'] = acc_head[0][0]
if not self.doc.due_date: if not self.doc.due_date:

View File

@ -132,7 +132,7 @@ erpnext.POS = Class.extend({
"options": "Item Group", "options": "Item Group",
"label": "Item Group", "label": "Item Group",
"fieldname": "pos_item_group", "fieldname": "pos_item_group",
"placeholder": "Filter by Item Group" "placeholder": "Item Group"
}, },
parent: this.wrapper.find(".item-group-area") parent: this.wrapper.find(".item-group-area")
}); });
@ -150,7 +150,7 @@ erpnext.POS = Class.extend({
"options": "Item", "options": "Item",
"label": "Item", "label": "Item",
"fieldname": "pos_item", "fieldname": "pos_item",
"placeholder": "Select Item" "placeholder": "Item"
}, },
parent: this.wrapper.find(".search-area") parent: this.wrapper.find(".search-area")
}); });
@ -167,7 +167,7 @@ erpnext.POS = Class.extend({
"fieldtype": "Data", "fieldtype": "Data",
"label": "Barcode", "label": "Barcode",
"fieldname": "pos_barcode", "fieldname": "pos_barcode",
"placeholder": "Select Barcode" "placeholder": "Barcode"
}, },
parent: this.wrapper.find(".barcode-area") parent: this.wrapper.find(".barcode-area")
}); });
@ -215,7 +215,9 @@ erpnext.POS = Class.extend({
// if form is local then allow this function // if form is local then allow this function
if (cur_frm.doc.docstatus===0) { if (cur_frm.doc.docstatus===0) {
$("div.pos-item").on("click", function() { $("div.pos-item").on("click", function() {
if(!cur_frm.doc[me.party.toLowerCase()]) { if(!cur_frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" &&
cur_frm.doc.quotation_to == "Customer")
|| me.frm.doctype != "Quotation")) {
msgprint("Please select " + me.party + " first."); msgprint("Please select " + me.party + " first.");
return; return;
} }
@ -282,6 +284,16 @@ erpnext.POS = Class.extend({
$.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype), function(i, d) { this.frm.cscript.fname, this.frm.doctype), function(i, d) {
if (me.sales_or_purchase == "Sales") {
item_amount = d.export_amount;
rate = d.export_rate;
}
else {
item_amount = d.import_amount;
rate = d.import_rate;
}
$(repl('<tr id="%(item_code)s" data-selected="false">\ $(repl('<tr id="%(item_code)s" data-selected="false">\
<td>%(item_code)s%(item_name)s</td>\ <td>%(item_code)s%(item_name)s</td>\
<td><input type="text" value="%(qty)s" \ <td><input type="text" value="%(qty)s" \
@ -292,8 +304,8 @@ erpnext.POS = Class.extend({
item_code: d.item_code, item_code: d.item_code,
item_name: d.item_name===d.item_code ? "" : ("<br>" + d.item_name), item_name: d.item_name===d.item_code ? "" : ("<br>" + d.item_name),
qty: d.qty, qty: d.qty,
rate: format_currency(d.ref_rate, cur_frm.doc.currency), rate: format_currency(rate, cur_frm.doc.currency),
amount: format_currency(d.export_amount, cur_frm.doc.currency) amount: format_currency(item_amount, cur_frm.doc.currency)
} }
)).appendTo($items); )).appendTo($items);
}); });
@ -312,15 +324,24 @@ erpnext.POS = Class.extend({
<tr>', { <tr>', {
description: d.description, description: d.description,
rate: d.rate, rate: d.rate,
tax_amount: format_currency(d.tax_amount, me.frm.doc.currency) tax_amount: format_currency(flt(d.tax_amount)/flt(me.frm.doc.conversion_rate),
me.frm.doc.currency)
})).appendTo(".tax-table tbody"); })).appendTo(".tax-table tbody");
}); });
// set totals // set totals
if (this.sales_or_purchase == "Sales") {
this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_export, this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_export,
cur_frm.doc.currency)); cur_frm.doc.currency));
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export, this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export,
cur_frm.doc.currency)); cur_frm.doc.currency));
}
else {
this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_import,
cur_frm.doc.currency));
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_import,
cur_frm.doc.currency));
}
// if form is local then only run all these functions // if form is local then only run all these functions
if (cur_frm.doc.docstatus===0) { if (cur_frm.doc.docstatus===0) {
@ -366,9 +387,12 @@ erpnext.POS = Class.extend({
if (this.frm.doctype != "Sales Invoice") if (this.frm.doctype != "Sales Invoice")
$(".make-payment").hide(); $(".make-payment").hide();
if (this.frm.doctype == "Quotation") // If quotation to is not Customer then remove party
if (cur_frm.doc.quotation_to=="Customer") if (this.frm.doctype == "Quotation") {
this.party_field.remove(); this.party_field.$wrapper.remove();
if (cur_frm.doc.quotation_to == "Customer")
this.make_party();
}
}, },
refresh_delete_btn: function() { refresh_delete_btn: function() {
$(".delete-items").toggle($(".item-cart .warning").length ? true : false); $(".delete-items").toggle($(".item-cart .warning").length ? true : false);

View File

@ -3,7 +3,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes import msgprint, errprint
@webnotes.whitelist() @webnotes.whitelist()
def get_items(price_list, sales_or_purchase, item=None, item_group=None): def get_items(price_list, sales_or_purchase, item=None, item_group=None):
@ -36,6 +35,11 @@ def get_item_from_barcode(barcode):
return webnotes.conn.sql("""select name from `tabItem` where barcode=%s""", return webnotes.conn.sql("""select name from `tabItem` where barcode=%s""",
(barcode), as_dict=1) (barcode), as_dict=1)
@webnotes.whitelist()
def get_item_from_serial_no(serial_no):
return webnotes.conn.sql("""select name, item_code from `tabSerial No` where
name=%s""", (serial_no), as_dict=1)
@webnotes.whitelist() @webnotes.whitelist()
def get_mode_of_payment(): def get_mode_of_payment():
return webnotes.conn.sql("""select name from `tabMode of Payment`""", as_dict=1) return webnotes.conn.sql("""select name from `tabMode of Payment`""", as_dict=1)

View File

@ -108,8 +108,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
var item = wn.model.get_doc(cdt, cdn); var item = wn.model.get_doc(cdt, cdn);
if(item.item_code) { if(item.item_code) {
if(!this.validate_company_and_party("supplier")) { if(!this.validate_company_and_party("supplier")) {
item.item_code = null; cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove();
refresh_field("item_code", item.name, item.parentfield);
} else { } else {
return this.frm.call({ return this.frm.call({
method: "buying.utils.get_item_details", method: "buying.utils.get_item_details",

View File

@ -233,6 +233,29 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
this.calculate_taxes_and_totals(); this.calculate_taxes_and_totals();
}, },
// serial_no: function(doc, cdt, cdn) {
// var me = this;
// var item = wn.model.get_doc(cdt, cdn);
// if (!item.item_code) {
// wn.call({
// method: 'accounts.doctype.sales_invoice.pos.get_item_from_serial_no',
// args: {serial_no: this.serial_no.$input.val()},
// callback: function(r) {
// if (r.message) {
// var item_code = r.message[0].item_code;
// var child = wn.model.add_child(me.frm.doc, this.frm.doctype + " Item",
// this.frm.cscript.fname);
// child.item_code = item_code;
// me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name);
// }
// else
// msgprint(wn._("Invalid Serial No."));
// me.refresh();
// }
// });
// }
// },
row_id: function(doc, cdt, cdn) { row_id: function(doc, cdt, cdn) {
var tax = wn.model.get_doc(cdt, cdn); var tax = wn.model.get_doc(cdt, cdn);
try { try {

View File

@ -162,8 +162,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
var item = wn.model.get_doc(cdt, cdn); var item = wn.model.get_doc(cdt, cdn);
if(item.item_code || item.barcode) { if(item.item_code || item.barcode) {
if(!this.validate_company_and_party("customer")) { if(!this.validate_company_and_party("customer")) {
item.item_code = null; cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove();
refresh_field("item_code", item.name, item.parentfield);
} else { } else {
return this.frm.call({ return this.frm.call({
method: "selling.utils.get_item_details", method: "selling.utils.get_item_details",

View File

@ -34,6 +34,7 @@ def get_item_details(args):
"plc_conversion_rate": 1.0 "plc_conversion_rate": 1.0
} }
""" """
if isinstance(args, basestring): if isinstance(args, basestring):
args = json.loads(args) args = json.loads(args)
args = webnotes._dict(args) args = webnotes._dict(args)

View File

@ -425,6 +425,7 @@ def get_address_territory(address_doc):
def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company): def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
"""common validation for currency and price list currency""" """common validation for currency and price list currency"""
if conversion_rate == 0: if conversion_rate == 0:
msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True) msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True)