feat(Selling): Gross Profit In Quotation (#21795)

* added valuation rate and gross_profit in quotation item table

* modified code to not fetch valuation_rate manually, used set_gross_profit from selling controller
This commit is contained in:
Abhishek Balam 2020-05-26 18:37:02 +05:30 committed by GitHub
parent 49b2b155b6
commit 18e7b60acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 5 deletions

View File

@ -361,7 +361,7 @@ class SellingController(StockController):
self.po_no = ', '.join(list(set([d.po_no for d in po_nos if d.po_no])))
def set_gross_profit(self):
if self.doctype == "Sales Order":
if self.doctype in ["Sales Order", "Quotation"]:
for item in self.items:
item.gross_profit = flt(((item.base_rate - item.valuation_rate) * item.stock_qty), self.precision("amount", item))

View File

@ -1711,7 +1711,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
},
set_gross_profit: function(item) {
if (this.frm.doc.doctype == "Sales Order" && item.valuation_rate) {
if (["Sales Order", "Quotation"].includes(this.frm.doc.doctype) && item.valuation_rate) {
var rate = flt(item.rate) * flt(this.frm.doc.conversion_rate || 1);
item.gross_profit = flt(((rate - item.valuation_rate) * item.stock_qty), precision("amount", item));
}

View File

@ -197,9 +197,9 @@ def set_expired_status():
cond = "qo.docstatus = 1 and qo.status != 'Expired' and qo.valid_till < %s"
# check if those QUO have SO against it
so_against_quo = """
SELECT
SELECT
so.name FROM `tabSales Order` so, `tabSales Order Item` so_item
WHERE
WHERE
so_item.docstatus = 1 and so.docstatus = 1
and so_item.parent = so.name
and so_item.prevdoc_docname = qo.name"""

View File

@ -48,6 +48,10 @@
"base_net_amount",
"pricing_rules",
"is_free_item",
"section_break_43",
"valuation_rate",
"column_break_45",
"gross_profit",
"item_weight_details",
"weight_per_unit",
"total_weight",
@ -602,12 +606,40 @@
"label": "Against Blanket Order",
"no_copy": 1,
"print_hide": 1
},
{
"fieldname": "section_break_43",
"fieldtype": "Section Break"
},
{
"fieldname": "valuation_rate",
"fieldtype": "Currency",
"label": "Valuation Rate",
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1,
"report_hide": 1
},
{
"fieldname": "column_break_45",
"fieldtype": "Column Break"
},
{
"fieldname": "gross_profit",
"fieldtype": "Currency",
"label": "Gross Profit",
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1,
"report_hide": 1
}
],
"idx": 1,
"istable": 1,
"links": [],
"modified": "2020-03-30 18:40:28.782720",
"modified": "2020-05-19 20:48:43.222229",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation Item",