mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
UOM Conversion in selling
This commit is contained in:
@@ -220,7 +220,7 @@ class SellingController(StockController):
|
||||
il.append(frappe._dict({
|
||||
'warehouse': d.warehouse,
|
||||
'item_code': d.item_code,
|
||||
'qty': d.qty,
|
||||
'qty': d.stock_qty,
|
||||
'uom': d.uom,
|
||||
'stock_uom': d.stock_uom,
|
||||
'conversion_factor': d.conversion_factor,
|
||||
@@ -294,8 +294,6 @@ class SellingController(StockController):
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 and flt(d.qty):
|
||||
if flt(d.conversion_factor)==0.0:
|
||||
d.conversion_factor = get_conversion_factor(d.item_code, d.uom).get("conversion_factor") or 1.0
|
||||
|
||||
qty_in_stock_uom = flt(d.qty * d.conversion_factor)
|
||||
return_rate = 0
|
||||
if cint(self.is_return) and self.return_against and self.docstatus==1:
|
||||
return_rate = self.get_incoming_rate_for_sales_return(d.item_code, self.return_against)
|
||||
@@ -306,13 +304,13 @@ class SellingController(StockController):
|
||||
if d.warehouse and ((not cint(self.is_return) and self.docstatus==1)
|
||||
or (cint(self.is_return) and self.docstatus==2)):
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": -1*qty_in_stock_uom,
|
||||
"actual_qty": -1*flt(d.qty),
|
||||
"incoming_rate": return_rate
|
||||
}))
|
||||
|
||||
if d.target_warehouse:
|
||||
target_warehouse_sle = self.get_sl_entries(d, {
|
||||
"actual_qty": qty_in_stock_uom,
|
||||
"actual_qty": flt(d.qty),
|
||||
"warehouse": d.target_warehouse
|
||||
})
|
||||
|
||||
@@ -338,7 +336,7 @@ class SellingController(StockController):
|
||||
if d.warehouse and ((not cint(self.is_return) and self.docstatus==2)
|
||||
or (cint(self.is_return) and self.docstatus==1)):
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": -1*qty_in_stock_uom,
|
||||
"actual_qty": -1*flt(d.qty),
|
||||
"incoming_rate": return_rate
|
||||
}))
|
||||
|
||||
|
||||
@@ -147,9 +147,9 @@ def period_wise_columns_query(filters, trans):
|
||||
else:
|
||||
pwc = [_(filters.get("fiscal_year")) + " ("+_("Qty") + "):Float:120",
|
||||
_(filters.get("fiscal_year")) + " ("+ _("Amt") + "):Currency:120"]
|
||||
query_details = " SUM(t2.qty), SUM(t2.base_net_amount),"
|
||||
query_details = " SUM(t2.stock_qty), SUM(t2.base_net_amount),"
|
||||
|
||||
query_details += 'SUM(t2.qty), SUM(t2.base_net_amount)'
|
||||
query_details += 'SUM(t2.stock_qty), SUM(t2.base_net_amount)'
|
||||
return pwc, query_details
|
||||
|
||||
def get_period_wise_columns(bet_dates, period, pwc):
|
||||
@@ -161,7 +161,7 @@ def get_period_wise_columns(bet_dates, period, pwc):
|
||||
_(get_mon(bet_dates[0])) + "-" + _(get_mon(bet_dates[1])) + " (" + _("Amt") + "):Currency:120"]
|
||||
|
||||
def get_period_wise_query(bet_dates, trans_date, query_details):
|
||||
query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)),
|
||||
query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.stock_qty, NULL)),
|
||||
SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.base_net_amount, NULL)),
|
||||
""" % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]}
|
||||
return query_details
|
||||
|
||||
Reference in New Issue
Block a user