Costing added in Time log Batch, Sales Order added to Project + more fixes
This commit is contained in:
parent
4e6e4726a4
commit
d4b33d3c14
@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import get_fullname
|
||||
from frappe.utils import get_fullname, flt
|
||||
from frappe.model.document import Document
|
||||
from erpnext.hr.utils import set_employee_name
|
||||
from erpnext.accounts.utils import validate_fiscal_year
|
||||
@ -39,8 +39,8 @@ class ExpenseClaim(Document):
|
||||
self.total_claimed_amount = 0
|
||||
self.total_sanctioned_amount = 0
|
||||
for d in self.expenses:
|
||||
self.total_claimed_amount += d.claim_amount
|
||||
self.total_sanctioned_amount += d.sanctioned_amount
|
||||
self.total_claimed_amount += flt(d.claim_amount)
|
||||
self.total_sanctioned_amount += flt(d.sanctioned_amount)
|
||||
|
||||
def validate_exp_details(self):
|
||||
if not self.get('expenses'):
|
||||
@ -62,5 +62,5 @@ class ExpenseClaim(Document):
|
||||
|
||||
def validate_sanctioned_amount(self):
|
||||
for d in self.expenses:
|
||||
if d.sanctioned_amount > d.claim_amount:
|
||||
if flt(d.sanctioned_amount) > flt(d.claim_amount):
|
||||
frappe.throw(_("Sanctioned Amount cannot be greater than Claim Amount in Row {0}.").format(d.idx))
|
@ -1,6 +1,19 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.ui.form.on("Project", {
|
||||
onload: function(frm) {
|
||||
var so = frappe.meta.get_docfield("Project", "sales_order");
|
||||
so.get_route_options_for_new_doc = function(field) {
|
||||
if(frm.is_new()) return;
|
||||
return {
|
||||
"customer": frm.doc.customer,
|
||||
"project_name": frm.doc.name
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Project Task", "edit_task", function(frm, doctype, name) {
|
||||
var doc = frappe.get_doc(doctype, name);
|
||||
if(doc.task_id) {
|
||||
@ -37,3 +50,11 @@ cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) {
|
||||
query: "erpnext.controllers.queries.customer_query"
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['sales_order'].get_query = function(doc) {
|
||||
return {
|
||||
filters:{
|
||||
'project_name': doc.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
cur_frm.add_fetch("time_log", "activity_type", "activity_type");
|
||||
cur_frm.add_fetch("time_log", "owner", "created_by");
|
||||
cur_frm.add_fetch("time_log", "billing_amount", "billing_amount");
|
||||
cur_frm.add_fetch("time_log", "hours", "hours");
|
||||
|
||||
cur_frm.set_query("time_log", "time_logs", function(doc) {
|
||||
|
@ -32,6 +32,7 @@
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 0,
|
||||
"label": "Status",
|
||||
"no_copy": 1,
|
||||
"options": "Draft\nSubmitted\nBilled\nCancelled",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
@ -60,7 +61,14 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"description": "In Hours",
|
||||
"fieldname": "section_break_8",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "updated via Time Logs",
|
||||
"fieldname": "total_hours",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
@ -68,6 +76,22 @@
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_10",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "updated via Time Logs",
|
||||
"fieldname": "total_billing_amount",
|
||||
"fieldtype": "Float",
|
||||
"label": "Total Billing Amount",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
@ -83,7 +107,7 @@
|
||||
"icon": "icon-time",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2015-02-05 05:11:48.360822",
|
||||
"modified": "2015-04-15 06:07:41.771962",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Time Log Batch",
|
||||
|
@ -7,6 +7,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
from frappe.utils import flt
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
@ -14,12 +15,12 @@ class TimeLogBatch(Document):
|
||||
|
||||
def validate(self):
|
||||
self.set_status()
|
||||
self.total_hours = 0.0
|
||||
for d in self.get("time_logs"):
|
||||
tl = frappe.get_doc("Time Log", d.time_log)
|
||||
self.update_time_log_values(d, tl)
|
||||
self.validate_time_log_is_submitted(tl)
|
||||
self.total_hours += float(tl.hours or 0.0)
|
||||
self.total_hours += flt(tl.hours)
|
||||
self.total_billing_amount += flt(tl.billing_amount)
|
||||
|
||||
def update_time_log_values(self, d, tl):
|
||||
d.update({
|
||||
@ -29,7 +30,9 @@ class TimeLogBatch(Document):
|
||||
})
|
||||
|
||||
def validate_time_log_is_submitted(self, tl):
|
||||
if tl.status != "Submitted" and self.docstatus == 0:
|
||||
if tl.status == "Batched for Billing":
|
||||
frappe.throw(_("Time Log {0} already billed").format(tl.name))
|
||||
elif tl.status != "Submitted":
|
||||
frappe.throw(_("Time Log {0} must be 'Submitted'").format(tl.name))
|
||||
|
||||
def set_status(self):
|
||||
@ -65,15 +68,15 @@ def make_sales_invoice(source_name, target=None):
|
||||
def update_item(source_doc, target_doc, source_parent):
|
||||
target_doc.stock_uom = "Hour"
|
||||
target_doc.description = "via Time Logs"
|
||||
target_doc.qty = 1
|
||||
|
||||
target = frappe.new_doc("Sales Invoice")
|
||||
target.append("items", get_mapped_doc("Time Log Batch", source_name, {
|
||||
"Time Log Batch": {
|
||||
"doctype": "Sales Invoice Item",
|
||||
"field_map": {
|
||||
"rate": "base_rate",
|
||||
"name": "time_log_batch",
|
||||
"total_hours": "qty",
|
||||
"total_billing_amount": "rate",
|
||||
"name": "time_log_batch"
|
||||
},
|
||||
"postprocess": update_item
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"creation": "2013-03-05 09:11:06.000000",
|
||||
"creation": "2013-03-05 09:11:06",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"fields": [
|
||||
@ -15,14 +15,19 @@
|
||||
"width": "200px"
|
||||
},
|
||||
{
|
||||
"fieldname": "created_by",
|
||||
"fieldtype": "Link",
|
||||
"fieldname": "hours",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Created By",
|
||||
"options": "User",
|
||||
"label": "Hours",
|
||||
"permlevel": 0,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_3",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "activity_type",
|
||||
"fieldtype": "Data",
|
||||
@ -32,18 +37,21 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "hours",
|
||||
"fieldname": "billing_amount",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Hours",
|
||||
"permlevel": 0
|
||||
"label": "Billing Amount",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2013-12-20 19:21:54.000000",
|
||||
"modified": "2015-04-15 05:35:08.805589",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Time Log Batch Detail",
|
||||
"owner": "Administrator"
|
||||
"owner": "Administrator",
|
||||
"permissions": []
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user