Rohit Waghchaure
4 years ago
11 changed files with 234 additions and 16 deletions
@ -0,0 +1,9 @@ |
|||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
/* eslint-disable */ |
|||
|
|||
frappe.query_reports["Cost of Poor Quality Report"] = { |
|||
"filters": [ |
|||
|
|||
] |
|||
}; |
@ -0,0 +1,33 @@ |
|||
{ |
|||
"add_total_row": 0, |
|||
"columns": [], |
|||
"creation": "2021-01-11 11:10:58.292896", |
|||
"disable_prepared_report": 0, |
|||
"disabled": 0, |
|||
"docstatus": 0, |
|||
"doctype": "Report", |
|||
"filters": [], |
|||
"idx": 0, |
|||
"is_standard": "Yes", |
|||
"json": "{}", |
|||
"modified": "2021-01-11 11:11:03.594242", |
|||
"modified_by": "Administrator", |
|||
"module": "Manufacturing", |
|||
"name": "Cost of Poor Quality Report", |
|||
"owner": "Administrator", |
|||
"prepared_report": 0, |
|||
"ref_doctype": "Job Card", |
|||
"report_name": "Cost of Poor Quality Report", |
|||
"report_type": "Script Report", |
|||
"roles": [ |
|||
{ |
|||
"role": "System Manager" |
|||
}, |
|||
{ |
|||
"role": "Manufacturing User" |
|||
}, |
|||
{ |
|||
"role": "Manufacturing Manager" |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,136 @@ |
|||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
from frappe import _ |
|||
from frappe.utils import flt |
|||
|
|||
def execute(filters=None): |
|||
columns, data = [], [] |
|||
|
|||
columns = get_columns(filters) |
|||
data = get_data(filters) |
|||
|
|||
return columns, data |
|||
|
|||
def get_data(filters): |
|||
data = [] |
|||
operations = frappe.get_all("Operation", filters = {"cost_of_poor_quality_operation": 1}) |
|||
if operations: |
|||
operations = [d.name for d in operations] |
|||
fields = ["production_item as item_code", "item_name", "work_order", "operation", |
|||
"workstation", "total_time_in_mins", "name", "hour_rate"] |
|||
|
|||
job_cards = frappe.get_all("Job Card", fields = fields, |
|||
filters = {"docstatus": 1, "operation": ("in", operations)}) |
|||
|
|||
for row in job_cards: |
|||
row.operating_cost = flt(row.hour_rate) * (flt(row.total_time_in_mins) / 60.0) |
|||
update_raw_material_cost(row, filters) |
|||
update_time_details(row, filters, data) |
|||
|
|||
return data |
|||
|
|||
def update_raw_material_cost(row, filters): |
|||
row.rm_cost = 0.0 |
|||
for data in frappe.get_all("Job Card Item", fields = ["amount"], |
|||
filters={"parent": row.name, "docstatus": 1}): |
|||
row.rm_cost += data.amount |
|||
|
|||
def update_time_details(row, filters, data): |
|||
args = frappe._dict({"item_code": "", "item_name": "", "name": "", "work_order":"", |
|||
"operation": "", "workstation":"", "operating_cost": "", "rm_cost": "", "total_time_in_mins": ""}) |
|||
|
|||
i=0 |
|||
for time_log in frappe.get_all("Job Card Time Log", fields = ["from_time", "to_time", "time_in_mins"], |
|||
filters={"parent": row.name, "docstatus": 1}): |
|||
|
|||
if i==0: |
|||
i += 1 |
|||
row.update(time_log) |
|||
data.append(row) |
|||
else: |
|||
args.update(time_log) |
|||
data.append(args) |
|||
|
|||
def get_columns(filters): |
|||
return [ |
|||
{ |
|||
"label": _("Job Card"), |
|||
"fieldtype": "Link", |
|||
"fieldname": "name", |
|||
"options": "Job Card", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Work Order"), |
|||
"fieldtype": "Link", |
|||
"fieldname": "work_order", |
|||
"options": "Work Order", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Item Code"), |
|||
"fieldtype": "Link", |
|||
"fieldname": "item_code", |
|||
"options": "Item", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Item Name"), |
|||
"fieldtype": "Data", |
|||
"fieldname": "item_name", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Operation"), |
|||
"fieldtype": "Link", |
|||
"fieldname": "operation", |
|||
"options": "Operation", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Workstation"), |
|||
"fieldtype": "Link", |
|||
"fieldname": "workstation", |
|||
"options": "Workstation", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Operating Cost"), |
|||
"fieldtype": "Currency", |
|||
"fieldname": "operating_cost", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Raw Material Cost"), |
|||
"fieldtype": "Currency", |
|||
"fieldname": "rm_cost", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Total Time (in Mins)"), |
|||
"fieldtype": "Float", |
|||
"fieldname": "total_time_in_mins", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("From Time"), |
|||
"fieldtype": "Datetime", |
|||
"fieldname": "from_time", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("To Time"), |
|||
"fieldtype": "Datetime", |
|||
"fieldname": "to_time", |
|||
"width": "100" |
|||
}, |
|||
{ |
|||
"label": _("Time in Mins"), |
|||
"fieldtype": "Float", |
|||
"fieldname": "time_in_mins", |
|||
"width": "100" |
|||
}, |
|||
] |
@ -0,0 +1,16 @@ |
|||
# Copyright (c) 2019, Frappe and Contributors |
|||
# License: GNU General Public License v3. See license.txt |
|||
|
|||
from __future__ import unicode_literals |
|||
import frappe |
|||
|
|||
def execute(): |
|||
frappe.reload_doc("manufacturing", "doctype", "job_card") |
|||
frappe.reload_doc("manufacturing", "doctype", "job_card_item") |
|||
frappe.reload_doc("manufacturing", "doctype", "work_order_operation") |
|||
|
|||
frappe.db.sql(""" update `tabJob Card` jc, `tabWork Order Operation` wo |
|||
SET jc.hour_rate = wo.hour_rate |
|||
WHERE |
|||
jc.operation_id = wo.name and jc.docstatus < 2 and wo.hour_rate > 0 |
|||
""") |
Loading…
Reference in new issue