mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
completed Time Log / Time Log Batch
This commit is contained in:
@@ -75,6 +75,7 @@ class DocType(SellingController):
|
||||
self.set_aging_date()
|
||||
self.set_against_income_account()
|
||||
self.validate_c_form()
|
||||
self.validate_time_logs_are_submitted()
|
||||
self.validate_recurring_invoice()
|
||||
|
||||
def on_submit(self):
|
||||
@@ -104,7 +105,7 @@ class DocType(SellingController):
|
||||
self.update_against_document_in_jv()
|
||||
|
||||
self.update_c_form()
|
||||
|
||||
self.update_time_log_batch(self.doc.name)
|
||||
self.convert_to_recurring()
|
||||
|
||||
|
||||
@@ -122,12 +123,28 @@ class DocType(SellingController):
|
||||
self.check_next_docstatus()
|
||||
sales_com_obj.update_prevdoc_detail(0, self)
|
||||
|
||||
self.update_time_log_batch(None)
|
||||
self.make_gl_entries(is_cancel=1)
|
||||
|
||||
def on_update_after_submit(self):
|
||||
self.validate_recurring_invoice()
|
||||
self.convert_to_recurring()
|
||||
|
||||
def update_time_log_batch(self, sales_invoice):
|
||||
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
||||
if d.time_log_batch:
|
||||
tlb = webnotes.bean("Time Log Batch", d.time_log_batch)
|
||||
tlb.doc.sales_invoice = sales_invoice
|
||||
tlb.update_after_submit()
|
||||
|
||||
def validate_time_logs_are_submitted(self):
|
||||
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
||||
if d.time_log_batch:
|
||||
status = webnotes.conn.get_value("Time Log Batch", d.time_log_batch, "status")
|
||||
if status!="Submitted":
|
||||
webnotes.msgprint(_("Time Log Batch status must be 'Submitted'") + ":" + d.time_log_batch,
|
||||
raise_exception=True)
|
||||
|
||||
def set_pos_fields(self):
|
||||
"""Set retail related fields from pos settings"""
|
||||
pos = webnotes.conn.sql("select * from `tabPOS Setting` where ifnull(user,'') = '%s' and company = '%s'" % (session['user'], self.doc.company), as_dict=1)
|
||||
|
||||
16
accounts/doctype/sales_invoice/sales_invoice_map.js
Normal file
16
accounts/doctype/sales_invoice/sales_invoice_map.js
Normal file
@@ -0,0 +1,16 @@
|
||||
wn.model.map_info["Sales Invoice"] = {
|
||||
"Time Log Batch": {
|
||||
table_map: {
|
||||
"Sales Invoice Item": "Time Log Batch",
|
||||
},
|
||||
field_map: {
|
||||
"Sales Invoice Item": {
|
||||
"basic_rate": "rate",
|
||||
"time_log_batch": "name",
|
||||
"qty": "total_hours",
|
||||
"stock_uom": "=Hour",
|
||||
"description": "=via Time Logs"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,31 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
jv.cancel()
|
||||
self.assertEquals(webnotes.conn.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
|
||||
561.8)
|
||||
|
||||
def test_time_log_batch(self):
|
||||
tlb = webnotes.bean("Time Log Batch", "_T-Time Log Batch-00001")
|
||||
tlb.submit()
|
||||
|
||||
w = webnotes.bean(webnotes.copy_doclist(test_records[0]))
|
||||
w.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
|
||||
w.insert()
|
||||
w.submit()
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001", "status"),
|
||||
"Billed")
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
|
||||
"Billed")
|
||||
|
||||
w.cancel()
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001", "status"),
|
||||
"Submitted")
|
||||
|
||||
self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
|
||||
"Batched for Billing")
|
||||
|
||||
|
||||
|
||||
test_dependencies = ["Journal Voucher"]
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-01-10 16:34:09",
|
||||
"creation": "2013-01-29 19:25:49",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-01-29 16:27:51",
|
||||
"modified": "2013-03-01 13:41:51",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -320,6 +320,13 @@
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "time_log_batch",
|
||||
"fieldtype": "Link",
|
||||
"label": "Time Log Batch",
|
||||
"options": "Time Log Batch"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_tax_rate",
|
||||
|
||||
Reference in New Issue
Block a user