Objective
There are Multiple Price lists for various customers, example wholesale , wholesale max , Agent along with the normal standard selling price list -
I need for special customers to see what price they have got along side the standard rate ,
eg. for agents the selling price is lower for all items and stored in agent price list , when i print the invoice , i want it to show the actual price (standard price) and the price i am giving him .
Attempts
i have created a custom print format from the builder and put price list rate along with rate -
but i want somehow for the price list rate to fetch the standard price list no matter what price list is put only in the print format .
possible solutions
1 . somehow create a custom field in items table as standard price , and then just add it in the print format using the print builder .
but i dont know how to fetch the standard price of that item in that field
this is the easiest solution i can come up with –
how would one achieve it , or if there is any alternate better solution to acheive it ,
are calling data from a child table?
this is how i did it i have child table named item in my parent doctype
{%- for item in doc.items -%}
<tr class="lh2">
<td>{{ loop.index }}</td>
<td align="left"> {{ item.get_formatted("description") }}</td>
<td align="center">{{ item.qty }} </td>
<td class="text-right"> {{ frappe.utils.fmt_money(item.get("rate"),currency="$") }}</td>
<td class="text-right"> {{ frappe.utils.fmt_money(item.get("amount"),currency="$") }}</td>
</tr>
{%- endfor -%}
Unfortunately , the code above fetches the rate which is already there in the fields, while the objective is to always fetch a fixed rate and display that ,
I worked on a solution from my above option -
created a custom field called standard rate which will always fetch the standard selling rate no matter what price list is selected ,
below is the script to fetch it ,
$.each(cur_frm.doc.items || [], function(i, v) { // for each item on table do this
var pricelist;
frappe.call({
method: "frappe.client.get_list",
args: {
doctype: "Item Price",
filters: [
['price_list', "=", "Standard Selling"],
["item_code", "=", v.item_code],
],
fields: [
"price_list_rate",
"name"
]
},
callback: function(r) { // do this to found price list doc
pricelist = (r.message[0].price_list_rate);
v.standard_rate = pricelist;
frappe.model.set_value(i, v, "standard_rate", pricelist);
}
});
})
put this on validate and voila !and then just add the custom field along side the actual rate field in the print format !
2 Likes