update Dashboard on rate model and total show
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -57,7 +57,7 @@ def client_edit_rate(rate_id):
|
||||
|
||||
if result["success"]:
|
||||
flash(result["message"], "success")
|
||||
return redirect(url_for("engineering.client-rate"))
|
||||
return redirect(url_for("engineering.client_rate_master"))
|
||||
|
||||
flash(result["message"], "danger")
|
||||
|
||||
@@ -75,7 +75,7 @@ def client_edit_rate(rate_id):
|
||||
def client_delete_rate(rate_id):
|
||||
ClientRateService.delete_rate(rate_id)
|
||||
flash("Rate deleted successfully.", "success")
|
||||
return redirect(url_for("engineering.client-rate"))
|
||||
return redirect(url_for("engineering.client_rate_master"))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -142,11 +142,21 @@
|
||||
<tr>
|
||||
<th>Sr No</th>
|
||||
<th>Strata Type & Depth</th>
|
||||
|
||||
<th class="text-end">Client Qty</th>
|
||||
<th class="text-end">Client Rate</th>
|
||||
<th class="text-end">Client Amount</th>
|
||||
|
||||
<th class="text-end">Sub Contractor Qty</th>
|
||||
<th class="text-end">Difference</th>
|
||||
<th class="text-end">Sub Rate</th>
|
||||
<th class="text-end">Sub Amount</th>
|
||||
|
||||
<th class="text-end">Qty Difference</th>
|
||||
<th class="text-end">Rate Difference</th>
|
||||
<th class="text-end">Amount Difference</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -162,13 +172,11 @@
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
let barChart;
|
||||
let raBillChoice;
|
||||
|
||||
/* Load RA Bills */
|
||||
function loadRABills(){
|
||||
|
||||
let subcontractor = document.getElementById("subcontractor").value
|
||||
let category = document.getElementById("category").value
|
||||
|
||||
@@ -176,30 +184,21 @@
|
||||
return;
|
||||
|
||||
if (!subcontractor || !category) {
|
||||
|
||||
raBillChoice.clearStore();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/dashboard/api/get-ra-bills?subcontractor=${subcontractor}&category=${category}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
||||
raBillChoice.clearStore();
|
||||
|
||||
let choices = [];
|
||||
|
||||
data.ra_bills.forEach(function(bill){
|
||||
|
||||
choices.push({
|
||||
|
||||
value: bill,
|
||||
|
||||
label: bill
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
raBillChoice.setChoices(
|
||||
@@ -208,7 +207,6 @@
|
||||
"label",
|
||||
true
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
@@ -328,37 +326,86 @@
|
||||
|
||||
/* TABLE */
|
||||
function drawTable(data) {
|
||||
|
||||
let html='';
|
||||
let html = "";
|
||||
for (let i = 0; i < data.labels.length; i++) {
|
||||
|
||||
const clientQty = Number(data.client_qty[i] || 0);
|
||||
const subQty = Number(data.sub_qty[i] || 0);
|
||||
const diff = clientQty - subQty;
|
||||
|
||||
const clientRate = Number(data.client_rate[i] || 0);
|
||||
const subRate = Number(data.sub_rate[i] || 0);
|
||||
|
||||
const clientAmount = Number(data.client_amount[i] || 0);
|
||||
const subAmount = Number(data.sub_amount[i] || 0);
|
||||
|
||||
const qtyDiff = Number(data.qty_difference[i] || 0 );
|
||||
const rateDiff = Number(data.rate_difference[i] || 0 );
|
||||
const amountDiff = Number(data.amount_difference[i] || 0 );
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td class="text-center">${i + 1}</td>
|
||||
<td>${data.labels[i]}</td>
|
||||
<td class="text-end">${data.client_qty[i]}</td>
|
||||
<td class="text-end">${data.sub_qty[i]}</td>
|
||||
<td class="text-end fw-bold ${diff >= 0 ? 'text-success' : 'text-danger'}">${diff.toFixed(2)}</td>
|
||||
<td class="text-center">
|
||||
${i + 1}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
${data.labels[i]}
|
||||
</td>
|
||||
|
||||
<!-- CLIENT -->
|
||||
<td class="text-end">
|
||||
${clientQty.toFixed(2)}
|
||||
</td>
|
||||
|
||||
<td class="text-end">
|
||||
₹ ${clientRate.toFixed(2)}
|
||||
</td>
|
||||
|
||||
<td class="text-end fw-bold">
|
||||
₹ ${clientAmount.toFixed(2)}
|
||||
</td>
|
||||
|
||||
<!-- SUBCONTRACTOR -->
|
||||
<td class="text-end">
|
||||
${subQty.toFixed(2)}
|
||||
</td>
|
||||
|
||||
<td class="text-end">
|
||||
₹ ${subRate.toFixed(2)}
|
||||
</td>
|
||||
|
||||
<td class="text-end fw-bold">
|
||||
₹ ${subAmount.toFixed(2)}
|
||||
</td>
|
||||
|
||||
<!-- DIFFERENCES -->
|
||||
<td class="text-end fw-bold
|
||||
${qtyDiff >= 0 ? 'text-success' : 'text-danger'}">
|
||||
${qtyDiff.toFixed(2)}
|
||||
</td>
|
||||
|
||||
<td class="text-end fw-bold
|
||||
${rateDiff >= 0 ? 'text-success' : 'text-danger'}">
|
||||
₹ ${rateDiff.toFixed(2)}
|
||||
</td>
|
||||
|
||||
<td class="text-end fw-bold
|
||||
${amountDiff >= 0 ? 'text-success' : 'text-danger'}">
|
||||
₹ ${amountDiff.toFixed(2)}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
`;
|
||||
|
||||
}
|
||||
|
||||
document.querySelector("#resultTable tbody").innerHTML = html;
|
||||
|
||||
document.querySelector(
|
||||
"#resultTable tbody"
|
||||
).innerHTML = html;
|
||||
}
|
||||
|
||||
/* EVENTS */
|
||||
document.getElementById("subcontractor").addEventListener("change", loadRABills);
|
||||
|
||||
document.getElementById("category").addEventListener("change", loadRABills);
|
||||
|
||||
document.getElementById("searchBtn").addEventListener("click", loadDashboard);
|
||||
|
||||
document.getElementById("resetBtn").addEventListener("click", function () {location.reload();});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
Reference in New Issue
Block a user