Skip to content

Commit

Permalink
Calculating the fields in the child table CostType in Costing Note do…
Browse files Browse the repository at this point in the history
…ctype
  • Loading branch information
Andro0o0o0w-Romany committed Jul 24, 2024
1 parent d5462fc commit 5586957
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "naming_series:",
"creation": "2024-07-17 17:24:17.584874",
"doctype": "DocType",
"editable_grid": 1,
Expand All @@ -12,7 +11,6 @@
"project_classification",
"clause",
"uom",
"naming_series",
"column_break_cawa",
"qty",
"costing_note",
Expand Down Expand Up @@ -83,18 +81,12 @@
"fieldname": "total",
"fieldtype": "Int",
"label": "Total"
},
{
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "series",
"options": "BUSINESS-CLS-.YYYY.-"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-07-21 13:03:47.429120",
"modified": "2024-07-23 17:09:30.507334",
"modified_by": "Administrator",
"module": "Contracta",
"name": "Business Clause",
Expand Down
14 changes: 10 additions & 4 deletions contracta/contracta/doctype/clearance/clearance.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
"section_break_gfmf",
"amended_from",
"naming_series",
"company",
"clearance_date",
"sales_invoice",
"status",
"column_break_cjfp",
"clearance_number",
"description",
"clearance_type",
"company",
"sales_invoice",
"description_section",
"description",
"section_break_iywj",
"down_payment_discount_rate",
"column_break_hltc",
Expand Down Expand Up @@ -103,12 +104,17 @@
"fieldtype": "Select",
"label": "Series",
"options": "CLEARANCE-.YYYY.-"
},
{
"fieldname": "description_section",
"fieldtype": "Section Break",
"label": "description"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-07-21 14:53:42.557905",
"modified": "2024-07-23 17:16:13.068922",
"modified_by": "Administrator",
"module": "Contracta",
"name": "Clearance",
Expand Down
14 changes: 9 additions & 5 deletions contracta/contracta/doctype/costing_note/costing_note.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Copyright (c) 2024, Andrew Romany and contributors
// For license information, please see license.txt

// frappe.ui.form.on("Costing Note", {
// refresh(frm) {

// },
// });
frappe.ui.form.on("Costing Note", {
validate: function(frm) {
frm.doc.costtype.forEach(function(row){
row.total_cost = row.qty * row.unit_cost;
row.tax_value = row.tax * row.total_cost;
row.grand_total_with_tax = row.total_cost + row.tax_value;
});
},
});
11 changes: 9 additions & 2 deletions contracta/contracta/doctype/costing_note/costing_note.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"equipment_costs",
"contractors_costs",
"expense_schedule",
"totals"
"totals",
"costtype"
],
"fields": [
{
Expand Down Expand Up @@ -140,12 +141,18 @@
"fieldtype": "Select",
"label": "Series",
"options": "COST-NOTE-.YYYY.-"
},
{
"fieldname": "costtype",
"fieldtype": "Table",
"label": "CostType",
"options": "CostType"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-07-21 12:51:23.651208",
"modified": "2024-07-23 13:43:04.997310",
"modified_by": "Administrator",
"module": "Contracta",
"name": "Costing Note",
Expand Down
6 changes: 5 additions & 1 deletion contracta/contracta/doctype/costing_note/costing_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@


class CostingNote(Document):
pass
def validate(self):
for calucate in self.costtype:
calucate.total_cost = calucate.qty * calucate.unit_cost
calucate.tax_value = calucate.tax * calucate.total_cost
calucate.grand_total_with_tax = calucate.total_cost + calucate.tax_value
5 changes: 1 addition & 4 deletions contracta/contracta/doctype/costtype/costtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@


class CostType(Document):
def validate(self):
self.total_cost = self.qty * self.unit_cost
self.tax_value = self.tax * self.total_cost
self.grand_total_with_tax = self.total_cost + self.tax_value
pass
5 changes: 4 additions & 1 deletion contracta/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
# page_js = {"page" : "public/js/file.js"}

# include js in doctype views
# doctype_js = {"doctype" : "public/js/doctype.js"}
doctype_js = {
"Quotation": "public/js/quotation.js",
"CostType": "public/js/costtype.js",
}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
Expand Down
Empty file added contracta/public/js/costtype.js
Empty file.
23 changes: 23 additions & 0 deletions contracta/public/js/quotation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
frappe.ui.form.on('Quotation', {
refresh(frm) {
frm.add_custom_button('Contract', function() {
frappe.call({
method: 'frappe.client.insert',
args: {
doc: {
doctype: "Contract",
party_name: frm.doc.customer_name,
contract_terms: frm.doc.terms,
quotation: frm.doc.name
}
},
callback: function(response) {
let contract = response.message;
if (contract && contract.name) {
frappe.set_route("Form", "Contract", contract.name);
}
}
});
}, __("Create"));
}
});

0 comments on commit 5586957

Please sign in to comment.