[mionr] fixes and cleanups
This commit is contained in:
parent
eac602304c
commit
26cf01aaba
@ -69,13 +69,13 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
var me = this;
|
var me = this;
|
||||||
// navigator.onLine
|
// navigator.onLine
|
||||||
this.connection_status = false;
|
this.connection_status = false;
|
||||||
this.page.set_indicator("Offline", "grey")
|
this.page.set_indicator(__("Offline"), "grey")
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method:"frappe.handler.ping",
|
method:"frappe.handler.ping",
|
||||||
callback: function(r){
|
callback: function(r){
|
||||||
if(r.message){
|
if(r.message){
|
||||||
me.connection_status = true;
|
me.connection_status = true;
|
||||||
me.page.set_indicator("Online", "green")
|
me.page.set_indicator(__("Online"), "green")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -278,7 +278,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Item",
|
"label": "Item",
|
||||||
"fieldname": "pos_item",
|
"fieldname": "pos_item",
|
||||||
"placeholder": "Search Item"
|
"placeholder": __("Search Item")
|
||||||
},
|
},
|
||||||
parent: this.wrapper.find(".search-area"),
|
parent: this.wrapper.find(".search-area"),
|
||||||
only_input: true,
|
only_input: true,
|
||||||
|
@ -167,9 +167,7 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
|||||||
target_doc.qty = -1* source_doc.qty
|
target_doc.qty = -1* source_doc.qty
|
||||||
if doctype == "Purchase Receipt":
|
if doctype == "Purchase Receipt":
|
||||||
target_doc.received_qty = -1* source_doc.qty
|
target_doc.received_qty = -1* source_doc.qty
|
||||||
target_doc.prevdoc_doctype = source_doc.prevdoc_doctype
|
target_doc.purchase_order = source_doc.purchase_order
|
||||||
target_doc.prevdoc_docname = source_doc.prevdoc_docname
|
|
||||||
target_doc.prevdoc_detail_docname = source_doc.prevdoc_detail_docname
|
|
||||||
elif doctype == "Purchase Invoice":
|
elif doctype == "Purchase Invoice":
|
||||||
target_doc.received_qty = -1* source_doc.qty
|
target_doc.received_qty = -1* source_doc.qty
|
||||||
target_doc.purchase_order = source_doc.purchase_order
|
target_doc.purchase_order = source_doc.purchase_order
|
||||||
|
@ -302,3 +302,4 @@ erpnext.patches.v7_0.setup_account_table_for_expense_claim_type_if_exists
|
|||||||
erpnext.patches.v7_0.migrate_schools_to_erpnext
|
erpnext.patches.v7_0.migrate_schools_to_erpnext
|
||||||
erpnext.patches.v7_0.remove_administrator_role_in_doctypes
|
erpnext.patches.v7_0.remove_administrator_role_in_doctypes
|
||||||
erpnext.patches.v7_0.rename_fee_amount_to_fee_component
|
erpnext.patches.v7_0.rename_fee_amount_to_fee_component
|
||||||
|
erpnext.patches.v7_0.calculate_total_costing_amount
|
||||||
|
14
erpnext/patches/v7_0/calculate_total_costing_amount.py
Normal file
14
erpnext/patches/v7_0/calculate_total_costing_amount.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe.utils import flt
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc('projects', 'doctype', 'timesheet')
|
||||||
|
|
||||||
|
for data in frappe.get_all('Timesheet', fields=["name, total_costing_amount"],
|
||||||
|
filters = [["docstatus", "<", "2"]]):
|
||||||
|
if flt(data.total_costing_amount) == 0.0:
|
||||||
|
ts = frappe.get_doc('Timesheet', data.name)
|
||||||
|
ts.update_cost()
|
||||||
|
ts.calculate_total_amounts()
|
||||||
|
ts.flags.ignore_validate_update_after_submit = True
|
||||||
|
ts.save()
|
@ -5,11 +5,11 @@ cur_frm.add_fetch('employee', 'employee_name', 'employee_name');
|
|||||||
frappe.ui.form.on("Timesheet", {
|
frappe.ui.form.on("Timesheet", {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frm.get_field('time_logs').grid.editable_fields = [
|
frm.get_field('time_logs').grid.editable_fields = [
|
||||||
{fieldname: 'billable', columns: 2},
|
{fieldname: 'billable', columns: 1},
|
||||||
{fieldname: 'activity_type', columns: 2},
|
{fieldname: 'activity_type', columns: 2},
|
||||||
{fieldname: 'from_time', columns: 2},
|
{fieldname: 'from_time', columns: 3},
|
||||||
{fieldname: 'hours', columns: 2},
|
{fieldname: 'hours', columns: 1},
|
||||||
{fieldname: 'to_time', columns: 2},
|
{fieldname: 'project', columns: 3}
|
||||||
];
|
];
|
||||||
|
|
||||||
frm.fields_dict.employee.get_query = function() {
|
frm.fields_dict.employee.get_query = function() {
|
||||||
@ -22,7 +22,8 @@ frappe.ui.form.on("Timesheet", {
|
|||||||
child = locals[cdt][cdn];
|
child = locals[cdt][cdn];
|
||||||
return{
|
return{
|
||||||
filters: {
|
filters: {
|
||||||
'project': child.project
|
'project': child.project,
|
||||||
|
'status': ["!=", "Closed"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,8 +38,7 @@ frappe.ui.form.on("Timesheet", {
|
|||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
if(frm.doc.docstatus==1) {
|
if(frm.doc.docstatus==1) {
|
||||||
if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0
|
if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0){
|
||||||
&& !frm.doc.production_order){
|
|
||||||
frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice") },
|
frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice") },
|
||||||
"icon-file-alt");
|
"icon-file-alt");
|
||||||
}
|
}
|
||||||
@ -147,13 +147,16 @@ var calculate_time_and_amount = function(frm) {
|
|||||||
var tl = frm.doc.time_logs || [];
|
var tl = frm.doc.time_logs || [];
|
||||||
total_hr = 0;
|
total_hr = 0;
|
||||||
total_billing_amount = 0;
|
total_billing_amount = 0;
|
||||||
|
total_costing_amount = 0;
|
||||||
for(var i=0; i<tl.length; i++) {
|
for(var i=0; i<tl.length; i++) {
|
||||||
if (tl[i].hours) {
|
if (tl[i].hours) {
|
||||||
total_hr += tl[i].hours;
|
total_hr += tl[i].hours;
|
||||||
total_billing_amount += tl[i].billing_amount;
|
total_billing_amount += tl[i].billing_amount;
|
||||||
|
total_costing_amount += tl[i].costing_amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.set_value("total_hours", total_hr);
|
cur_frm.set_value("total_hours", total_hr);
|
||||||
cur_frm.set_value("total_billing_amount", total_billing_amount);
|
cur_frm.set_value("total_billing_amount", total_billing_amount);
|
||||||
|
cur_frm.set_value("total_costing_amount", total_costing_amount);
|
||||||
}
|
}
|
@ -157,7 +157,7 @@
|
|||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Draft\nSubmitted\nBilled\nPayslip\nCompleted\nCancelled",
|
"options": "Draft\nSubmitted\nBilled\nPayslip\nCompleted\nCancelled",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 1,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
@ -478,7 +478,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"description": "updated via Time Logs",
|
"description": "",
|
||||||
"fieldname": "total_hours",
|
"fieldname": "total_hours",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -529,7 +529,7 @@
|
|||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"depends_on": "",
|
"depends_on": "",
|
||||||
"description": "updated via Time Logs",
|
"description": "",
|
||||||
"fieldname": "total_billing_amount",
|
"fieldname": "total_billing_amount",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -551,6 +551,31 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"fieldname": "total_costing_amount",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Total Costing Amount",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 1,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
@ -637,7 +662,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-07-13 23:44:05.086570",
|
"modified": "2016-07-26 00:01:56.055046",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Projects",
|
"module": "Projects",
|
||||||
"name": "Timesheet",
|
"name": "Timesheet",
|
||||||
|
@ -20,14 +20,21 @@ class OverProductionLoggedError(frappe.ValidationError): pass
|
|||||||
class Timesheet(Document):
|
class Timesheet(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.total_hours = 0.0
|
|
||||||
self.total_billing_amount = 0.0
|
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
self.validate_time_logs()
|
self.validate_time_logs()
|
||||||
self.update_cost()
|
self.update_cost()
|
||||||
|
self.calculate_total_amounts()
|
||||||
|
|
||||||
|
def calculate_total_amounts(self):
|
||||||
|
self.total_hours = 0.0
|
||||||
|
self.total_billing_amount = 0.0
|
||||||
|
self.total_costing_amount = 0.0
|
||||||
|
|
||||||
for d in self.get("time_logs"):
|
for d in self.get("time_logs"):
|
||||||
self.total_hours += flt(d.hours)
|
self.total_hours += flt(d.hours)
|
||||||
if d.billable: self.total_billing_amount += flt(d.billing_amount)
|
if d.billable:
|
||||||
|
self.total_billing_amount += flt(d.billing_amount)
|
||||||
|
self.total_costing_amount += flt(d.costing_amount)
|
||||||
|
|
||||||
def set_status(self):
|
def set_status(self):
|
||||||
self.status = {
|
self.status = {
|
||||||
@ -88,7 +95,7 @@ class Timesheet(Document):
|
|||||||
frappe.throw(_("Row {0}: Completed Qty must be greater than zero.").format(data.idx))
|
frappe.throw(_("Row {0}: Completed Qty must be greater than zero.").format(data.idx))
|
||||||
|
|
||||||
if self.production_order and flt(pending_qty) < flt(data.completed_qty):
|
if self.production_order and flt(pending_qty) < flt(data.completed_qty):
|
||||||
frappe.throw(_("Row {0}: Completed Qty cannot be more than {0} for operation {1}").format(data.idx, pending_qty, self.operation),
|
frappe.throw(_("Row {0}: Completed Qty cannot be more than {1} for operation {2}").format(data.idx, pending_qty, data.operation),
|
||||||
OverProductionLoggedError)
|
OverProductionLoggedError)
|
||||||
|
|
||||||
def update_production_order(self, time_sheet):
|
def update_production_order(self, time_sheet):
|
||||||
@ -220,7 +227,7 @@ class Timesheet(Document):
|
|||||||
|
|
||||||
def update_cost(self):
|
def update_cost(self):
|
||||||
for data in self.time_logs:
|
for data in self.time_logs:
|
||||||
if data.activity_type and not data.billing_amount:
|
if data.activity_type and (not data.billing_amount or not data.costing_amount):
|
||||||
rate = get_activity_cost(self.employee, data.activity_type)
|
rate = get_activity_cost(self.employee, data.activity_type)
|
||||||
hours = data.hours or 0
|
hours = data.hours or 0
|
||||||
if rate:
|
if rate:
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"depends_on": "eval:!parent.production_order",
|
"depends_on": "",
|
||||||
"fieldname": "billable",
|
"fieldname": "billable",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -27,7 +27,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 1,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
@ -163,7 +163,7 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"depends_on": "eval:!parent.production_order",
|
"depends_on": "billable",
|
||||||
"fieldname": "section_break_11",
|
"fieldname": "section_break_11",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -265,7 +265,7 @@
|
|||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"depends_on": "",
|
"depends_on": "",
|
||||||
"description": "To display value check Billable",
|
"description": "",
|
||||||
"fieldname": "billing_amount",
|
"fieldname": "billing_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -292,7 +292,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"description": "To display value check Billable",
|
"description": "",
|
||||||
"fieldname": "costing_amount",
|
"fieldname": "costing_amount",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -532,7 +532,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-07-21 09:59:01.622745",
|
"modified": "2016-07-26 00:07:58.267131",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Projects",
|
"module": "Projects",
|
||||||
"name": "Timesheet Detail",
|
"name": "Timesheet Detail",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user