fix: ignore scrap items while distribute additional cost
This commit is contained in:
parent
879d31a588
commit
1504ff8b6c
@ -895,19 +895,24 @@ class SubcontractingController(StockController):
|
|||||||
|
|
||||||
if self.total_additional_costs:
|
if self.total_additional_costs:
|
||||||
if self.distribute_additional_costs_based_on == "Amount":
|
if self.distribute_additional_costs_based_on == "Amount":
|
||||||
total_amt = sum(flt(item.amount) for item in self.get("items"))
|
total_amt = sum(
|
||||||
|
flt(item.amount) for item in self.get("items") if not item.get("is_scrap_item")
|
||||||
|
)
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
item.additional_cost_per_qty = (
|
if not item.get("is_scrap_item"):
|
||||||
(item.amount * self.total_additional_costs) / total_amt
|
item.additional_cost_per_qty = (
|
||||||
) / item.qty
|
(item.amount * self.total_additional_costs) / total_amt
|
||||||
|
) / item.qty
|
||||||
else:
|
else:
|
||||||
total_qty = sum(flt(item.qty) for item in self.get("items"))
|
total_qty = sum(flt(item.qty) for item in self.get("items") if not item.get("is_scrap_item"))
|
||||||
additional_cost_per_qty = self.total_additional_costs / total_qty
|
additional_cost_per_qty = self.total_additional_costs / total_qty
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
item.additional_cost_per_qty = additional_cost_per_qty
|
if not item.get("is_scrap_item"):
|
||||||
|
item.additional_cost_per_qty = additional_cost_per_qty
|
||||||
else:
|
else:
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
item.additional_cost_per_qty = 0
|
if not item.get("is_scrap_item"):
|
||||||
|
item.additional_cost_per_qty = 0
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_current_stock(self):
|
def get_current_stock(self):
|
||||||
|
@ -201,12 +201,17 @@ frappe.ui.form.on('Subcontracting Receipt', {
|
|||||||
|
|
||||||
frappe.ui.form.on('Landed Cost Taxes and Charges', {
|
frappe.ui.form.on('Landed Cost Taxes and Charges', {
|
||||||
amount: function (frm, cdt, cdn) {
|
amount: function (frm, cdt, cdn) {
|
||||||
|
set_missing_values(frm);
|
||||||
frm.events.set_base_amount(frm, cdt, cdn);
|
frm.events.set_base_amount(frm, cdt, cdn);
|
||||||
},
|
},
|
||||||
|
|
||||||
expense_account: function (frm, cdt, cdn) {
|
expense_account: function (frm, cdt, cdn) {
|
||||||
frm.events.set_account_currency(frm, cdt, cdn);
|
frm.events.set_account_currency(frm, cdt, cdn);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
additional_costs_remove: function(frm) {
|
||||||
|
set_missing_values(frm);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on('Subcontracting Receipt Item', {
|
frappe.ui.form.on('Subcontracting Receipt Item', {
|
||||||
|
@ -169,12 +169,12 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
"item_name": scrap_item.item_name,
|
"item_name": scrap_item.item_name,
|
||||||
"qty": qty,
|
"qty": qty,
|
||||||
"stock_uom": scrap_item.stock_uom,
|
"stock_uom": scrap_item.stock_uom,
|
||||||
"recalculate_rate": 1,
|
"recalculate_rate": 0,
|
||||||
"rate": scrap_item.rate,
|
"rate": scrap_item.rate,
|
||||||
"rm_cost_per_qty": 0,
|
"rm_cost_per_qty": 0,
|
||||||
"service_cost_per_qty": 0,
|
"service_cost_per_qty": 0,
|
||||||
"additional_cost_per_qty": 0,
|
"additional_cost_per_qty": 0,
|
||||||
"scrap_cost_per_qty": scrap_item.rate,
|
"scrap_cost_per_qty": 0,
|
||||||
"amount": qty * scrap_item.rate,
|
"amount": qty * scrap_item.rate,
|
||||||
"warehouse": self.set_warehouse,
|
"warehouse": self.set_warehouse,
|
||||||
"rejected_warehouse": self.rejected_warehouse,
|
"rejected_warehouse": self.rejected_warehouse,
|
||||||
@ -244,9 +244,6 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
scrap_cost_map = {}
|
scrap_cost_map = {}
|
||||||
for item in self.get("items") or []:
|
for item in self.get("items") or []:
|
||||||
if item.is_scrap_item:
|
if item.is_scrap_item:
|
||||||
if item.recalculate_rate:
|
|
||||||
item.rate = flt(item.scrap_cost_per_qty) + flt(item.additional_cost_per_qty)
|
|
||||||
|
|
||||||
item.amount = flt(item.qty) * flt(item.rate)
|
item.amount = flt(item.qty) * flt(item.rate)
|
||||||
|
|
||||||
if item.reference_name in scrap_cost_map:
|
if item.reference_name in scrap_cost_map:
|
||||||
|
@ -237,6 +237,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
|
"depends_on": "eval: !doc.is_scrap_item",
|
||||||
"fieldname": "additional_cost_per_qty",
|
"fieldname": "additional_cost_per_qty",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Additional Cost Per Qty",
|
"label": "Additional Cost Per Qty",
|
||||||
@ -476,9 +477,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "1",
|
"default": "1",
|
||||||
|
"depends_on": "eval: !doc.is_scrap_item",
|
||||||
"fieldname": "recalculate_rate",
|
"fieldname": "recalculate_rate",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Recalculate Rate"
|
"label": "Recalculate Rate",
|
||||||
|
"read_only_depends_on": "eval: doc.is_scrap_item"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "serial_and_batch_bundle",
|
"fieldname": "serial_and_batch_bundle",
|
||||||
@ -508,6 +511,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
|
"depends_on": "eval: !doc.is_scrap_item",
|
||||||
"fieldname": "scrap_cost_per_qty",
|
"fieldname": "scrap_cost_per_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Scrap Cost Per Qty",
|
"label": "Scrap Cost Per Qty",
|
||||||
@ -527,7 +531,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-08-25 15:42:36.923833",
|
"modified": "2023-08-25 20:09:03.069417",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Subcontracting",
|
"module": "Subcontracting",
|
||||||
"name": "Subcontracting Receipt Item",
|
"name": "Subcontracting Receipt Item",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user