fix in last sales and quote rate in quotation
This commit is contained in:
parent
e7c54a4714
commit
8499773db8
@ -283,34 +283,50 @@ cur_frm.cscript.validate = function(doc,cdt,cdn){
|
|||||||
//================ Last Quoted Price and Last Sold Price suggestion ======================
|
//================ Last Quoted Price and Last Sold Price suggestion ======================
|
||||||
cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= function(doc, cdt, cdn) {
|
cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= function(doc, cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
var cond = (doc.order_type == 'Maintenance')? " and tabItem.is_service_item = 'Yes'" : " and tabItem.is_sales_item = 'Yes'"
|
var cond = (doc.order_type == 'Maintenance') ? " and item.is_service_item = 'Yes'" : " and item.is_sales_item = 'Yes'";
|
||||||
if(doc.customer)
|
if(doc.customer) {
|
||||||
return repl("SELECT i.name,i.item_code,concat('Last quoted at - ',cast(quote_rate as char)) as quote_rate,concat('Last sold at - ',cast(sales_rate as char)) as sales_rate, i.item_name, i.description FROM\
|
var export_rate_field = wn.meta.get_docfield(cdt, 'export_rate', cdn);
|
||||||
(\
|
var precision = (export_rate_field && export_rate_field.fieldtype) === 'Float' ? 6 : 2;
|
||||||
select item_code,name, item_name, description from tabItem where tabItem.%(key)s like '%s' %(cond)s\
|
return repl("\
|
||||||
)i\
|
select \
|
||||||
left join\
|
item.name, \
|
||||||
(\
|
( \
|
||||||
select q.item_code,q.quote_rate from\
|
select concat('Last Quote @ ', q.currency, ' ', \
|
||||||
(\
|
format(q_item.export_rate, %(precision)s)) \
|
||||||
select q.transaction_date,qd.item_code,qd.basic_rate as quote_rate from `tabQuotation Item` qd, `tabQuotation` q where q.name=qd.parent and q.docstatus=1 and customer='%(cust)s'\
|
from `tabQuotation` q, `tabQuotation Item` q_item \
|
||||||
)q,\
|
where \
|
||||||
(\
|
q.name = q_item.parent \
|
||||||
select qd.item_code,max(q.transaction_date) as transaction_date from `tabQuotation Item` qd, `tabQuotation` q where q.name=qd.parent and q.docstatus=1 and customer='%(cust)s' group by qd.item_code\
|
and q_item.item_code = item.name \
|
||||||
)m where q.item_code=m.item_code and q.transaction_date=m.transaction_date\
|
and q.docstatus = 1 \
|
||||||
)q on i.item_code=q.item_code\
|
and q.customer = \"%(cust)s\" \
|
||||||
left join\
|
order by q.transaction_date desc \
|
||||||
(\
|
limit 1 \
|
||||||
select r.item_code,r.sales_rate from\
|
) as quote_rate, \
|
||||||
(\
|
( \
|
||||||
select r.voucher_date,rd.item_code,rd.basic_rate as sales_rate from `tabSales Invoice Item` rd, `tabSales Invoice` r where r.name=rd.parent and r.docstatus=1 and r.customer='%(cust)s'\
|
select concat('Last Sale @ ', si.currency, ' ', \
|
||||||
)r,\
|
format(si_item.basic_rate, %(precision)s)) \
|
||||||
(\
|
from `tabSales Invoice` si, `tabSales Invoice Item` si_item \
|
||||||
select rd.item_code,max(r.voucher_date) as voucher_date from `tabSales Invoice Item` rd, `tabSales Invoice` r where r.name=rd.parent and r.docstatus=1 and r.customer='%(cust)s' group by rd.item_code\
|
where \
|
||||||
)m where r.item_code=m.item_code and r.voucher_date=m.voucher_date\
|
si.name = si_item.parent \
|
||||||
)s on i.item_code=s.item_code ORDER BY i.item_code LIMIT 50",{cust:doc.customer, cond:cond});
|
and si_item.item_code = item.name \
|
||||||
else
|
and si.docstatus = 1 \
|
||||||
|
and si.customer = \"%(cust)s\" \
|
||||||
|
order by si.voucher_date desc \
|
||||||
|
limit 1 \
|
||||||
|
) as sales_rate, \
|
||||||
|
item.item_name, item.description \
|
||||||
|
from `tabItem` item \
|
||||||
|
where \
|
||||||
|
item.%(key)s like \"%s\" \
|
||||||
|
%(cond)s \
|
||||||
|
limit 25", {
|
||||||
|
cust: doc.customer,
|
||||||
|
cond: cond,
|
||||||
|
precision: precision
|
||||||
|
});
|
||||||
|
} else {
|
||||||
return repl("SELECT name, item_name, description FROM tabItem WHERE `tabItem`.%(key)s LIKE '%s' %(cond)s ORDER BY tabItem.item_code DESC LIMIT 50", {cond:cond});
|
return repl("SELECT name, item_name, description FROM tabItem WHERE `tabItem`.%(key)s LIKE '%s' %(cond)s ORDER BY tabItem.item_code DESC LIMIT 50", {cond:cond});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user