unreleased_gst will comment for not use
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify, redirect, url_for
|
from flask import Blueprint, render_template, request, jsonify, redirect, url_for
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
from model.HoldTypes import HoldTypes
|
from model.HoldTypes import HoldTypes
|
||||||
from model.GST import GST
|
# from model.GST import GST
|
||||||
|
|
||||||
hold_bp = Blueprint("hold_types", __name__)
|
hold_bp = Blueprint("hold_types", __name__)
|
||||||
|
|
||||||
@@ -58,13 +58,13 @@ def delete_hold_type(id):
|
|||||||
|
|
||||||
|
|
||||||
# ---------------- GST ----------------
|
# ---------------- GST ----------------
|
||||||
@hold_bp.route('/unreleased_gst')
|
# @hold_bp.route('/unreleased_gst')
|
||||||
@login_required
|
# @login_required
|
||||||
def unreleased_gst():
|
# def unreleased_gst():
|
||||||
|
|
||||||
data = GST.get_unreleased_gst()
|
# data = GST.get_unreleased_gst()
|
||||||
|
|
||||||
return render_template(
|
# return render_template(
|
||||||
"unreleased_gst.html",
|
# "unreleased_gst.html",
|
||||||
data=data
|
# data=data
|
||||||
)
|
# )
|
||||||
@@ -9761,3 +9761,14 @@ Timestamp: 2026-04-06 10:37:55 | User: Unknown | Action: Delete Payment | Detail
|
|||||||
Timestamp: 2026-04-06 10:38:07 | User: Unknown | Action: Delete GSTRelease | Details:
|
Timestamp: 2026-04-06 10:38:07 | User: Unknown | Action: Delete GSTRelease | Details:
|
||||||
Timestamp: 2026-04-06 10:38:07 | User: Unknown | Action: Delete GST Release | Details:
|
Timestamp: 2026-04-06 10:38:07 | User: Unknown | Action: Delete GST Release | Details:
|
||||||
Timestamp: 2026-04-06 10:39:39 | User: Unknown | Action: Get hold type | Details:
|
Timestamp: 2026-04-06 10:39:39 | User: Unknown | Action: Get hold type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:03:44 | User: Unknown | Action: Login | Details:
|
||||||
|
Timestamp: 2026-04-06 12:12:33 | User: Unknown | Action: Add Hold Type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:12:42 | User: Unknown | Action: Edit Hold Type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:12:46 | User: Unknown | Action: Delete Hold Type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:14:00 | User: Unknown | Action: Add Hold Type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:14:07 | User: Unknown | Action: Edit Hold Type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:14:10 | User: Unknown | Action: Delete Hold Type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:17:03 | User: Unknown | Action: Login | Details:
|
||||||
|
Timestamp: 2026-04-06 12:17:12 | User: Unknown | Action: Add Hold Type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:17:21 | User: Unknown | Action: Edit Hold Type | Details:
|
||||||
|
Timestamp: 2026-04-06 12:17:30 | User: Unknown | Action: Delete Hold Type | Details:
|
||||||
|
|||||||
80
model/GST.py
80
model/GST.py
@@ -1,51 +1,51 @@
|
|||||||
from model.ItemCRUD import ItemCRUD
|
# from model.ItemCRUD import ItemCRUD
|
||||||
from model.Utilities import ItemCRUDType
|
# from model.Utilities import ItemCRUDType
|
||||||
|
|
||||||
class GST:
|
# class GST:
|
||||||
|
|
||||||
@staticmethod
|
# @staticmethod
|
||||||
def get_unreleased_gst():
|
# def get_unreleased_gst():
|
||||||
# Use ItemCRUD for Invoices
|
# # Use ItemCRUD for Invoices
|
||||||
invoice_crud = ItemCRUD(itemType=ItemCRUDType.Invoice)
|
# invoice_crud = ItemCRUD(itemType=ItemCRUDType.Invoice)
|
||||||
invoices_rows = invoice_crud.GetAllData(storedproc="GetAllInvoicesBasic")
|
# invoices_rows = invoice_crud.GetAllData(storedproc="GetAllInvoicesBasic")
|
||||||
|
|
||||||
if not invoice_crud.isSuccess:
|
# if not invoice_crud.isSuccess:
|
||||||
return [] # Could also log invoice_crud.resultMessage
|
# return [] # Could also log invoice_crud.resultMessage
|
||||||
|
|
||||||
invoices = [
|
# invoices = [
|
||||||
dict(
|
# dict(
|
||||||
Invoice_No=row[1],
|
# Invoice_No=row[1],
|
||||||
GST_SD_Amount=float(row[2]) if row[2] is not None else 0
|
# GST_SD_Amount=float(row[2]) if row[2] is not None else 0
|
||||||
)
|
# )
|
||||||
for row in invoices_rows
|
# for row in invoices_rows
|
||||||
]
|
# ]
|
||||||
|
|
||||||
# Use ItemCRUD for GST Releases
|
# # Use ItemCRUD for GST Releases
|
||||||
gst_crud = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
# gst_crud = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||||
gst_rows = gst_crud.GetAllData(storedproc="GetAllGSTReleasesBasic")
|
# gst_rows = gst_crud.GetAllData(storedproc="GetAllGSTReleasesBasic")
|
||||||
|
|
||||||
if not gst_crud.isSuccess:
|
# if not gst_crud.isSuccess:
|
||||||
return [] # Could also log gst_crud.resultMessage
|
# return [] # Could also log gst_crud.resultMessage
|
||||||
|
|
||||||
gst_invoice_nos = {
|
# gst_invoice_nos = {
|
||||||
g[2] # Invoice_No is at index 2
|
# g[2] # Invoice_No is at index 2
|
||||||
for g in gst_rows
|
# for g in gst_rows
|
||||||
if g[2]
|
# if g[2]
|
||||||
}
|
# }
|
||||||
|
|
||||||
gst_basic_amounts = {
|
# gst_basic_amounts = {
|
||||||
float(g[3]) # Basic_Amount at index 3
|
# float(g[3]) # Basic_Amount at index 3
|
||||||
for g in gst_rows
|
# for g in gst_rows
|
||||||
if g[3] is not None
|
# if g[3] is not None
|
||||||
}
|
# }
|
||||||
|
|
||||||
# Filter unreleased invoices
|
# # Filter unreleased invoices
|
||||||
unreleased = []
|
# unreleased = []
|
||||||
for inv in invoices:
|
# for inv in invoices:
|
||||||
match_by_invoice = inv['Invoice_No'] in gst_invoice_nos
|
# match_by_invoice = inv['Invoice_No'] in gst_invoice_nos
|
||||||
match_by_gst_amount = inv['GST_SD_Amount'] in gst_basic_amounts
|
# match_by_gst_amount = inv['GST_SD_Amount'] in gst_basic_amounts
|
||||||
|
|
||||||
if not (match_by_invoice or match_by_gst_amount):
|
# if not (match_by_invoice or match_by_gst_amount):
|
||||||
unreleased.append(inv)
|
# unreleased.append(inv)
|
||||||
|
|
||||||
return unreleased
|
# return unreleased
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% block content %}
|
|
||||||
<head>
|
|
||||||
<title>Manage Purchases</title>
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="button-container">
|
|
||||||
<button id="addButton" class="action-button">Add Purchase</button>
|
|
||||||
<button id="displayButton" class="action-button">Display Purchases</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ADD PURCHASE FORM -->
|
|
||||||
<!-- ADD PURCHASE FORM -->
|
|
||||||
<div id="addForm" style="display: none;">
|
|
||||||
<h2>Add Purchase Entry</h2>
|
|
||||||
<form action="/add_purchase_order" method="POST">
|
|
||||||
<label for="purchase_date">Purchase Date:</label><br>
|
|
||||||
<input type="date" id="purchase_date" name="purchase_date" required><br><br>
|
|
||||||
|
|
||||||
<label for="supplier_name">Supplier Name:</label><br>
|
|
||||||
<input type="text" id="supplier_name" name="supplier_name" required><br><br>
|
|
||||||
|
|
||||||
<label for="Purchase Order No">Purchase Order No:</label><br>
|
|
||||||
<input type="text" name="purchase_order_no" required><br><br>
|
|
||||||
|
|
||||||
<label for="unit">Item Name:</label><br>
|
|
||||||
<input type="text" id="item_name" name="item_name" required><br><br>
|
|
||||||
|
|
||||||
<label for="quantity">Quantity:</label><br>
|
|
||||||
<input type="number" id="quantity" name="quantity" step="1" required><br><br>
|
|
||||||
|
|
||||||
<label for="unit">Unit:</label><br>
|
|
||||||
<input type="text" id="unit" name="unit" required><br><br>
|
|
||||||
|
|
||||||
<label for="rate">Rate:</label><br>
|
|
||||||
<input type="number" step="0.01" id="rate" name="rate" required><br><br>
|
|
||||||
|
|
||||||
<label for="amount">Amount:</label><br>
|
|
||||||
<input type="number" step="0.01" id="amount" name="amount" readonly><br><br>
|
|
||||||
|
|
||||||
<!-- GST input -->
|
|
||||||
<label for="gst_percent">GST %:</label><br>
|
|
||||||
<input type="number" step="0.01" id="gst_percent"><br><br>
|
|
||||||
|
|
||||||
<label>GST Amount:</label><br>
|
|
||||||
<input type="number" step="0.01" id="GST_Amount" name="GST_Amount" readonly><br><br>
|
|
||||||
|
|
||||||
<!-- TDS input -->
|
|
||||||
<label for="tds_percent">TDS %:</label><br>
|
|
||||||
<input type="number" step="0.01" id="tds_percent"><br><br>
|
|
||||||
|
|
||||||
<label>TDS:</label><br>
|
|
||||||
<input type="number" step="0.01" id="TDS" name="TDS" readonly><br><br>
|
|
||||||
|
|
||||||
<label>Final Amount:</label><br>
|
|
||||||
<input type="number" step="0.01" id="final_amount" name="final_amount" readonly><br><br>
|
|
||||||
|
|
||||||
<input type="submit" value="Submit">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- DISPLAY TABLE -->
|
|
||||||
<div id="displayTable" style="display: none;">
|
|
||||||
<h2>Purchase List</h2>
|
|
||||||
<table border="1">
|
|
||||||
<tr>
|
|
||||||
<th>ID</th>
|
|
||||||
<th>Purchase Date</th>
|
|
||||||
<th>Supplier Name</th>
|
|
||||||
<th>Purchase Order No</th>
|
|
||||||
<th>Item Name</th>
|
|
||||||
<th>Quantity</th>
|
|
||||||
<th>Unit</th>
|
|
||||||
<th>Rate</th>
|
|
||||||
<th>Amount</th>
|
|
||||||
<th>GST Amount</th>
|
|
||||||
<th>TDS</th>
|
|
||||||
<th>Final Amount</th>
|
|
||||||
<th>Edit</th>
|
|
||||||
<th>Delete</th>
|
|
||||||
</tr>
|
|
||||||
{% for purchase in purchases %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ purchase['purchase_id'] }}</td>
|
|
||||||
<td>{{ purchase['purchase_date'] }}</td>
|
|
||||||
<td>{{ purchase['supplier_name'] }}</td>
|
|
||||||
<td>{{ purchase['purchase_order_no'] }}</td>
|
|
||||||
<td>{{ purchase['item_name'] }}</td>
|
|
||||||
<td>{{ purchase['quantity'] }}</td>
|
|
||||||
<td>{{ purchase['unit'] }}</td>
|
|
||||||
<td>{{ purchase['rate'] }}</td>
|
|
||||||
<td>{{ purchase['amount'] }}</td>
|
|
||||||
<td>{{ purchase['GST_Amount'] }}</td>
|
|
||||||
<td>{{ purchase['TDS'] }}</td>
|
|
||||||
<td>{{ purchase['final_amount'] }}</td>
|
|
||||||
<td><a href="{{ url_for('update_purchase', id=purchase['purchase_id']) }}">Edit</a></td>
|
|
||||||
<td>
|
|
||||||
<form method="POST" action="{{ url_for('delete_purchase', id=purchase['purchase_id']) }}" style="display:inline;">
|
|
||||||
<button type="submit" onclick="return confirm('Are you sure?')">Delete</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$('#addButton').click(function() {
|
|
||||||
$('#addForm').toggle();
|
|
||||||
});
|
|
||||||
$('#displayButton').click(function() {
|
|
||||||
$('#displayTable').toggle();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
function calculateAmounts() {
|
|
||||||
const qty = parseFloat(document.getElementById('quantity').value) || 0;
|
|
||||||
const rate = parseFloat(document.getElementById('rate').value) || 0;
|
|
||||||
const gstPercent = parseFloat(document.getElementById('gst_percent').value) || 0;
|
|
||||||
const tdsPercent = parseFloat(document.getElementById('tds_percent').value) || 0;
|
|
||||||
|
|
||||||
const amount = qty * rate;
|
|
||||||
document.getElementById('amount').value = amount.toFixed(2);
|
|
||||||
|
|
||||||
const gstAmount = (gstPercent / 100) * amount;
|
|
||||||
document.getElementById('GST_Amount').value = gstAmount.toFixed(2);
|
|
||||||
|
|
||||||
const tdsAmount = (tdsPercent / 100) * amount;
|
|
||||||
document.getElementById('TDS').value = tdsAmount.toFixed(2);
|
|
||||||
|
|
||||||
const finalAmount = amount + gstAmount - tdsAmount;
|
|
||||||
document.getElementById('final_amount').value = finalAmount.toFixed(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach events
|
|
||||||
document.getElementById('quantity').addEventListener('input', calculateAmounts);
|
|
||||||
document.getElementById('rate').addEventListener('input', calculateAmounts);
|
|
||||||
document.getElementById('gst_percent').addEventListener('input', calculateAmounts);
|
|
||||||
document.getElementById('tds_percent').addEventListener('input', calculateAmounts);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% block content %}
|
|
||||||
<head>
|
|
||||||
<title>Manage Work Order</title>
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}">
|
|
||||||
|
|
||||||
</head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="button-container">
|
|
||||||
<button id="addButton" class="action-button">Add</button>
|
|
||||||
<button id="displayButton" class="action-button">Display</button>
|
|
||||||
</div>
|
|
||||||
<form action="/submit_work_order" method="POST">
|
|
||||||
<div id="addForm" style="display: none;">
|
|
||||||
<h2>Create Work Order</h2>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Subcontractor Dropdown -->
|
|
||||||
<label for="subcontractor_id">Select Vender Name:</label><br>
|
|
||||||
<select name="vendor_name" id="vendor_name" required>
|
|
||||||
<option value="">-- Select Subcontractor --</option>
|
|
||||||
{% for sc in subcontractor %}
|
|
||||||
<option value="{{ sc.Contractor_Name }}">{{ sc.Contractor_Name }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select><br><br>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<label for="work_order_number">Work Order Number:</label><br>
|
|
||||||
<input type="text" id="work_order_number" name="work_order_number" required><br><br>
|
|
||||||
|
|
||||||
<label for="work_order_amount">Work Order Amount</label><br>
|
|
||||||
<input type="number" step="0.01" id="work_order_amount" name="work_order_amount" required><br><br>
|
|
||||||
|
|
||||||
<label for="gst_amount">GST Amount:</label><br>
|
|
||||||
<input type="number" step="0.01" id="gst_amount" name="gst_amount" required><br><br>
|
|
||||||
|
|
||||||
<label for="tds_amount">TDS Amount:</label><br>
|
|
||||||
<input type="number" step="0.01" id="tds_amount" name="tds_amount" required><br><br>
|
|
||||||
|
|
||||||
<label for="security_deposit">Security Deposit:</label><br>
|
|
||||||
<input type="number" step="0.01" id="security_deposit" name="security_deposit" required><br><br>
|
|
||||||
|
|
||||||
<label for="sd_against_gst">SD Against GST:</label><br>
|
|
||||||
<input type="number" step="0.01" id="sd_against_gst" name="sd_against_gst" required><br><br>
|
|
||||||
|
|
||||||
<label for="final_total">Final Total:</label><br>
|
|
||||||
<input type="number" step="0.01" id="final_total" name="final_total" readonly><br><br>
|
|
||||||
|
|
||||||
<input type="submit" value="Submit">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{# display data #}
|
|
||||||
<div id="addTable" style="display: none;">
|
|
||||||
{# <div class="search-container">#}
|
|
||||||
{# <h2>Hold Type List</h2>#}
|
|
||||||
{# <input type="text" id="searchBar" placeholder="Searching..." onkeyup="searchTable()">#}
|
|
||||||
{# </div>#}
|
|
||||||
<table id="sortableTable" border="1">
|
|
||||||
<tr>
|
|
||||||
<th>ID</th>
|
|
||||||
<th class="sortable-header">
|
|
||||||
Vender Name
|
|
||||||
{# <span class="sort-buttons">#}
|
|
||||||
{# <span class="sort-asc">⬆️</span>#}
|
|
||||||
{# <span class="sort-desc">⬇️</span>#}
|
|
||||||
{# </span>#}
|
|
||||||
</th>
|
|
||||||
<th>Work Order Type</th>
|
|
||||||
<th>Work Order Amount</th>
|
|
||||||
<th>BOQ Amount</th>
|
|
||||||
<th>Work Done Percentage</th>
|
|
||||||
<th>Update</th>
|
|
||||||
<th>Delete</th>
|
|
||||||
</tr>
|
|
||||||
{% for htd in wo %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ htd.work_order_id }}</td>
|
|
||||||
<td>{{ htd['vendor_name'] }}</td>
|
|
||||||
<td>{{ htd['work_order_type'] }}</td>
|
|
||||||
<td>{{ htd['work_order_amount'] }}</td>
|
|
||||||
<td>{{ htd['boq_amount'] }}</td>
|
|
||||||
<td>{{ htd['work_done_percentage'] }}</td>
|
|
||||||
<td>{{ htd['work_order_number'] }}</td>
|
|
||||||
<td>{{ htd['gst_amount'] }}</td>
|
|
||||||
<td>{{ htd['tds_amount'] }}</td>
|
|
||||||
<td>{{ htd[''] }}</td>
|
|
||||||
<td><a href="{{ url_for('update_work_order', id=htd['work_order_id']) }}">Edit</a></td>
|
|
||||||
<td>
|
|
||||||
<form action="{{ url_for('delete_work_order', id=htd['work_order_id']) }}" method="POST" style="display:inline;">
|
|
||||||
<button type="submit" onclick="return confirm('Are you sure you want to delete this work order?');" class="delete-button">Delete</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<a href="/">Back to Dashboard</a>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
$('#displayButton').click(function () {
|
|
||||||
$('#addTable').toggle();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#addButton').click(function () {
|
|
||||||
$('#addForm').toggle();
|
|
||||||
|
|
||||||
// Bind input event handlers ONLY after form is shown
|
|
||||||
setTimeout(function () {
|
|
||||||
["work_order_amount", "gst_amount", "tds_amount", "security_deposit", "sd_against_gst"].forEach(function (id) {
|
|
||||||
document.getElementById(id).addEventListener("input", calculateFinalTotal);
|
|
||||||
});
|
|
||||||
}, 100); // Delay ensures elements are available in DOM
|
|
||||||
});
|
|
||||||
|
|
||||||
function calculateFinalTotal() {
|
|
||||||
const workOrderAmount = parseFloat(document.getElementById("work_order_amount").value) || 0;
|
|
||||||
const gstAmount = parseFloat(document.getElementById("gst_amount").value) || 0;
|
|
||||||
const tdsAmount = parseFloat(document.getElementById("tds_amount").value) || 0;
|
|
||||||
const securityDeposit = parseFloat(document.getElementById("security_deposit").value) || 0;
|
|
||||||
const sdAgainstGst = parseFloat(document.getElementById("sd_against_gst").value) || 0;
|
|
||||||
|
|
||||||
const finalTotal = workOrderAmount + gstAmount - (tdsAmount + securityDeposit + sdAgainstGst);
|
|
||||||
document.getElementById("final_total").value = finalTotal.toFixed(2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head><title>Edit GRN</title>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2>Edit GRN</h2>
|
|
||||||
<form method="POST">
|
|
||||||
<label>GRN Date:</label>
|
|
||||||
<input type="date" name="grn_date" value="{{ grn['grn_date'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Purchase ID:</label>
|
|
||||||
<input type="number" name="purchase_id" value="{{ grn['purchase_id'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Supplier Name:</label>
|
|
||||||
<input type="text" name="supplier_name" value="{{ grn['supplier_name'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Item Description:</label>
|
|
||||||
<input type="text" name="item_description" value="{{ grn['item_description'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Received Quantity:</label>
|
|
||||||
<input type="number" name="received_quantity" value="{{ grn['received_quantity'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Unit:</label>
|
|
||||||
<input type="text" name="unit" value="{{ grn['unit'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Rate:</label>
|
|
||||||
<input type="number" step="0.01" name="rate" value="{{ grn['rate'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Amount:</label>
|
|
||||||
<input type="number" step="0.01" name="amount" value="{{ grn['amount'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Remarks:</label>
|
|
||||||
<input type="text" name="remarks" value="{{ grn['remarks'] }}"><br><br>
|
|
||||||
|
|
||||||
<input type="submit" value="Update GRN">
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Edit Purchase</title>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2>Edit Purchase Order</h2>
|
|
||||||
<form method="POST">
|
|
||||||
<label>Purchase Date:</label>
|
|
||||||
<input type="date" name="purchase_date" value="{{ purchase['purchase_date'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Supplier Name:</label>
|
|
||||||
<input type="text" name="supplier_name" value="{{ purchase['supplier_name'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Purchase Order No:</label>
|
|
||||||
<input type="text" name="purchase_order_no" value="{{ purchase['purchase_order_no'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Item Name:</label>
|
|
||||||
<input type="text" name="item_name" value="{{ purchase['item_name'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Quantity:</label>
|
|
||||||
<input type="number" name="quantity" value="{{ purchase['quantity'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Unit:</label>
|
|
||||||
<input type="text" name="unit" value="{{ purchase['unit'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Rate:</label>
|
|
||||||
<input type="number" step="0.01" name="rate" value="{{ purchase['rate'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Amount:</label>
|
|
||||||
<input type="number" step="0.01" name="amount" value="{{ purchase['amount'] }}" required><br><br>
|
|
||||||
|
|
||||||
|
|
||||||
<label>GST Amount:</label>
|
|
||||||
<input type="text" name="GST_Amount" value="{{ purchase['GST_Amount'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>TDS:</label>
|
|
||||||
<input type="number" step="0.01" name="TDS" value="{{ purchase['TDS'] }}" required><br><br>
|
|
||||||
|
|
||||||
<label>Final Amount:</label>
|
|
||||||
<input type="number" step="0.01" name="final_amount" value="{{ purchase['final_amount'] }}" required><br><br>
|
|
||||||
|
|
||||||
<input type="submit" value="Update">
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>GRN Management</title>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2>Add GRN</h2>
|
|
||||||
<form method="POST" action="/add_grn">
|
|
||||||
<label>GRN Date:</label>
|
|
||||||
<input type="date" name="grn_date" required><br><br>
|
|
||||||
|
|
||||||
<label>Purchase ID:</label>
|
|
||||||
<input type="number" name="purchase_id" required><br><br>
|
|
||||||
{# <label for="purchase_id">Purchase Order:</label>#}
|
|
||||||
{# <select name="purchase_id" id="purchase_id" required>#}
|
|
||||||
{# {% for order in purchase_orders %}#}
|
|
||||||
{# <option value="{{ order['purchase_id'] }}">{{ order['supplier_name'] }}</option>#}
|
|
||||||
{# {% endfor %}#}
|
|
||||||
{#</select>#}
|
|
||||||
|
|
||||||
<label>Supplier Name:</label>
|
|
||||||
<input type="text" name="supplier_name" required><br><br>
|
|
||||||
|
|
||||||
<label>Item Description:</label>
|
|
||||||
<input type="text" name="item_description" required><br><br>
|
|
||||||
|
|
||||||
<label>Received Quantity:</label>
|
|
||||||
<input type="number" name="received_quantity" required><br><br>
|
|
||||||
|
|
||||||
<label>Unit:</label>
|
|
||||||
<input type="text" name="unit" required><br><br>
|
|
||||||
|
|
||||||
<label>Rate:</label>
|
|
||||||
<input type="number" step="0.01" name="rate" required><br><br>
|
|
||||||
|
|
||||||
<label>Amount:</label>
|
|
||||||
<input type="number" step="0.01" name="amount" required><br><br>
|
|
||||||
|
|
||||||
<label>Remarks:</label>
|
|
||||||
<input type="text" name="remarks"><br><br>
|
|
||||||
|
|
||||||
<input type="submit" value="Add GRN">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<h2>All GRNs</h2>
|
|
||||||
<table border="1">
|
|
||||||
<tr>
|
|
||||||
<th>ID</th><th>Date</th><th>Purchase ID</th><th>Supplier</th><th>Item</th>
|
|
||||||
<th>Qty</th><th>Unit</th><th>Rate</th><th>Amount</th><th>Remarks</th><th>Actions</th>
|
|
||||||
</tr>
|
|
||||||
{% for grn in grns %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ grn[0] }}</td>
|
|
||||||
<td>{{ grn[1] }}</td>
|
|
||||||
<td>{{ grn[2] }}</td>
|
|
||||||
<td>{{ grn[3] }}</td>
|
|
||||||
<td>{{ grn[4] }}</td>
|
|
||||||
<td>{{ grn[5] }}</td>
|
|
||||||
<td>{{ grn[6] }}</td>
|
|
||||||
<td>{{ grn[7] }}</td>
|
|
||||||
<td>{{ grn[8] }}</td>
|
|
||||||
<td>{{ grn[9] }}</td>
|
|
||||||
<td style="white-space: nowrap;">
|
|
||||||
<a href="/update_grn/{{ grn['grn_id'] }}" style="margin-right: 10px;">Edit</a>
|
|
||||||
|
|
||||||
<form action="/delete_grn/{{ grn[0] }}" method="POST" style="display:inline;">
|
|
||||||
<button type="submit" onclick="return confirm('Are you sure you want to delete this GRN?')" style="background:none;border:none;color:blue;cursor:pointer;text-decoration:underline;">
|
|
||||||
Delete
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -133,30 +133,7 @@
|
|||||||
<h2>Hold Types</h2>
|
<h2>Hold Types</h2>
|
||||||
<a class="btn" href="/add_hold_type">Go ➜</a>
|
<a class="btn" href="/add_hold_type">Go ➜</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
|
||||||
<h2>Work Order</h2>
|
|
||||||
<!-- <a class="btn" href="/add_work_order">Go ➜</a> -->
|
|
||||||
<a class="btn">Go ➜</a>
|
|
||||||
</div>
|
|
||||||
<!-- <div class="card">
|
|
||||||
<h2>Purchase Order</h2>
|
|
||||||
<a class="btn" href="/add_purchase_order">Go ➜</a>
|
|
||||||
</div> -->
|
|
||||||
<!-- <div class="card">
|
|
||||||
<h2>Goods Receive Note</h2>
|
|
||||||
<a class="btn" href="/add_grn">Go ➜</a>
|
|
||||||
</div> -->
|
|
||||||
<!-- <div class="card">
|
|
||||||
<h2>Unreleased GST</h2>
|
|
||||||
<a class="btn" href="/unreleased_gst">Go ➜</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{# <div class="card">#}
|
|
||||||
{# <h2>Hold Release </h2>#}
|
|
||||||
{# <a class="btn" href="/add_hold_release">Go ➜</a>#}
|
|
||||||
{# </div>#}
|
|
||||||
|
|
||||||
</div> -->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Purchase Order</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,205 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Purchase Order Report</title>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/subcontractor_report.css') }}">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
|
||||||
<style>
|
|
||||||
h2.report-title {
|
|
||||||
font-size: 28px;
|
|
||||||
color: #1a73e8;
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 20px;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
.filter-section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 20px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
label {
|
|
||||||
font-weight: bold;
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
padding: 6px;
|
|
||||||
}
|
|
||||||
#downloadBtn, #searchBtn {
|
|
||||||
padding: 10px 20px;
|
|
||||||
background-color: #4CAF50;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
#downloadBtn:hover, #searchBtn:hover {
|
|
||||||
background-color: #45a049;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 0 auto;
|
|
||||||
margin-top: 30px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 95%;
|
|
||||||
}
|
|
||||||
th, td {
|
|
||||||
padding: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2 class="report-title">Purchase Order Report</h2>
|
|
||||||
|
|
||||||
<div class="filter-section">
|
|
||||||
<div>
|
|
||||||
<label for="supplier_name">Select Supplier Name:</label>
|
|
||||||
<select id="supplier_name" name="supplier_name" style="width: 300px;"></select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="purchase_order_no">Select Purchase Order Number:</label>
|
|
||||||
<select id="purchase_order_no" name="purchase_order_no" style="width: 300px;"></select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="searchBtn">Search</button>
|
|
||||||
<button id="downloadBtn" style="display: none;">Download Report</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table border="1" id="purchaseorderTable" style="display: none;">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Purchase ID</th>
|
|
||||||
<th>Purchase Date</th>
|
|
||||||
<th>Supplier Name</th>
|
|
||||||
<th>Purchase Order No</th>
|
|
||||||
<th>Item Name</th>
|
|
||||||
<th>Quantity</th>
|
|
||||||
<th>Unit</th>
|
|
||||||
<th>Rate</th>
|
|
||||||
<th>Amount</th>
|
|
||||||
<th>GST Amount</th>
|
|
||||||
<th>TDS</th>
|
|
||||||
<th>Final Amount</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody></tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- JS Scripts -->
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
// Initialize Select2 for supplier_name
|
|
||||||
$('#supplier_name').select2({
|
|
||||||
placeholder: 'Search Supplier Name',
|
|
||||||
ajax: {
|
|
||||||
url: '/get_supplier_names',
|
|
||||||
data: function (params) {
|
|
||||||
return { q: params.term };
|
|
||||||
},
|
|
||||||
processResults: function (data) {
|
|
||||||
return {
|
|
||||||
results: data.map(name => ({ id: name, text: name }))
|
|
||||||
};
|
|
||||||
},
|
|
||||||
delay: 250,
|
|
||||||
cache: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize Select2 for purchase_order_no
|
|
||||||
$('#purchase_order_no').select2({
|
|
||||||
placeholder: 'Search Purchase Order No',
|
|
||||||
ajax: {
|
|
||||||
url: '/get_purchase_order_numbers',
|
|
||||||
data: function (params) {
|
|
||||||
return {
|
|
||||||
q: params.term,
|
|
||||||
supplier_name: $('#supplier_name').val()
|
|
||||||
};
|
|
||||||
},
|
|
||||||
processResults: function (data) {
|
|
||||||
return {
|
|
||||||
results: data.map(no => ({ id: no, text: no }))
|
|
||||||
};
|
|
||||||
},
|
|
||||||
delay: 250,
|
|
||||||
cache: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Search button click
|
|
||||||
$('#searchBtn').click(function () {
|
|
||||||
let supplier = $('#supplier_name').val();
|
|
||||||
let poNumber = $('#purchase_order_no').val();
|
|
||||||
|
|
||||||
if (!supplier && !poNumber) {
|
|
||||||
alert("Please select Supplier or Purchase Order No or both.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: '/get_purchase_order_data',
|
|
||||||
data: {
|
|
||||||
supplier_name: supplier,
|
|
||||||
purchase_order_no: poNumber
|
|
||||||
},
|
|
||||||
success: function (data) {
|
|
||||||
let tbody = $('#purchaseorderTable tbody');
|
|
||||||
tbody.empty();
|
|
||||||
|
|
||||||
if (data.length > 0) {
|
|
||||||
$('#purchaseorderTable').show();
|
|
||||||
$('#downloadBtn').show();
|
|
||||||
|
|
||||||
data.forEach(function (row) {
|
|
||||||
tbody.append(`
|
|
||||||
<tr>
|
|
||||||
<td>${row.purchase_id}</td>
|
|
||||||
<td>${row.purchase_date}</td>
|
|
||||||
<td>${row.supplier_name}</td>
|
|
||||||
<td>${row.purchase_order_no}</td>
|
|
||||||
<td>${row.item_name}</td>
|
|
||||||
<td>${row.quantity}</td>
|
|
||||||
<td>${row.unit}</td>
|
|
||||||
<td>${row.rate}</td>
|
|
||||||
<td>${row.amount}</td>
|
|
||||||
<td>${row.GST_Amount}</td>
|
|
||||||
<td>${row.TDS}</td>
|
|
||||||
<td>${row.final_amount}</td>
|
|
||||||
</tr>
|
|
||||||
`);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert("No matching purchase orders found.");
|
|
||||||
$('#purchaseorderTable').hide();
|
|
||||||
$('#downloadBtn').hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Download report
|
|
||||||
$('#downloadBtn').click(function () {
|
|
||||||
let supplier = $('#supplier_name').val();
|
|
||||||
let poNumber = $('#purchase_order_no').val();
|
|
||||||
|
|
||||||
if (!supplier && !poNumber) {
|
|
||||||
alert("Please select filters before downloading.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let url = '/download_purchase_order_report?';
|
|
||||||
if (supplier) url += 'supplier_name=' + encodeURIComponent(supplier);
|
|
||||||
if (poNumber) url += '&purchase_order_no=' + encodeURIComponent(poNumber);
|
|
||||||
|
|
||||||
window.location.href = url;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% block content %}
|
|
||||||
<head>
|
|
||||||
<title>Work Order Report</title>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/subcontractor_report.css') }}">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
|
||||||
<style>
|
|
||||||
h2.report-title {
|
|
||||||
font-size: 28px;
|
|
||||||
color: #1a73e8;
|
|
||||||
text-align: center;
|
|
||||||
margin-top: 20px;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
.filter-section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 20px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
label {
|
|
||||||
font-weight: bold;
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
padding: 6px;
|
|
||||||
}
|
|
||||||
#downloadBtn, #searchBtn {
|
|
||||||
padding: 10px 20px;
|
|
||||||
background-color: #4CAF50;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
#downloadBtn:hover, #searchBtn:hover {
|
|
||||||
background-color: #45a049;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
margin: 0 auto;
|
|
||||||
margin-top: 30px;
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 95%;
|
|
||||||
}
|
|
||||||
th, td {
|
|
||||||
padding: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2 class="report-title">Work Order Report</h2>
|
|
||||||
|
|
||||||
<div class="filter-section">
|
|
||||||
<div>
|
|
||||||
<label for="vendor_name">Select Vendor Name:</label>
|
|
||||||
<select id="vendor_name" name="vendor_name" style="width: 300px;"></select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="work_order_number">Select Work Order Number:</label>
|
|
||||||
<select id="work_order_number" name="work_order_number" style="width: 300px;"></select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="searchBtn">Search</button>
|
|
||||||
<button id="downloadBtn" style="display: none;">Download Report</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table border="1" id="workOrderTable" style="display: none;">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>ID</th>
|
|
||||||
<th>Vendor Name</th>
|
|
||||||
<th>Work Order Type</th>
|
|
||||||
<th>Amount</th>
|
|
||||||
<th>BOQ</th>
|
|
||||||
<th>Done %</th>
|
|
||||||
<th>GST</th>
|
|
||||||
<th>TDS</th>
|
|
||||||
<th>Security Deposit</th>
|
|
||||||
<th>SD GST</th>
|
|
||||||
<th>Final Total</th>
|
|
||||||
<th>TDS of GST</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody></tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- JS Scripts -->
|
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
$('#vendor_name, #work_order_number').select2({
|
|
||||||
placeholder: 'Search',
|
|
||||||
minimumInputLength: 1,
|
|
||||||
ajax: {
|
|
||||||
delay: 250,
|
|
||||||
dataType: 'json',
|
|
||||||
cache: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#vendor_name').select2({
|
|
||||||
placeholder: 'Search Vendor',
|
|
||||||
ajax: {
|
|
||||||
url: '/get_vendor_names',
|
|
||||||
data: function (params) {
|
|
||||||
return { q: params.term };
|
|
||||||
},
|
|
||||||
processResults: function (data) {
|
|
||||||
return {
|
|
||||||
results: data.map(v => ({ id: v, text: v }))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#work_order_number').select2({
|
|
||||||
placeholder: 'Search Work Order',
|
|
||||||
ajax: {
|
|
||||||
url: '/get_work_order_numbers',
|
|
||||||
data: function (params) {
|
|
||||||
return {
|
|
||||||
q: params.term,
|
|
||||||
vendor_name: $('#vendor_name').val()
|
|
||||||
};
|
|
||||||
},
|
|
||||||
processResults: function (data) {
|
|
||||||
return {
|
|
||||||
results: data.map(o => ({ id: o, text: o }))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fetch and display table
|
|
||||||
$('#searchBtn').click(function () {
|
|
||||||
let vendor = $('#vendor_name').val();
|
|
||||||
let order = $('#work_order_number').val();
|
|
||||||
|
|
||||||
if (!vendor && !order) {
|
|
||||||
alert("Please select Vendor or Work Order Number or both.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: '/get_work_order_data',
|
|
||||||
data: {
|
|
||||||
vendor_name: vendor,
|
|
||||||
work_order_number: order
|
|
||||||
},
|
|
||||||
success: function (data) {
|
|
||||||
let tbody = $('#workOrderTable tbody');
|
|
||||||
tbody.empty();
|
|
||||||
|
|
||||||
if (data.length > 0) {
|
|
||||||
$('#workOrderTable').show();
|
|
||||||
$('#downloadBtn').show();
|
|
||||||
|
|
||||||
data.forEach(function (row) {
|
|
||||||
tbody.append(`
|
|
||||||
<tr>
|
|
||||||
<td>${row.work_order_id}</td>
|
|
||||||
<td>${row.vendor_name}</td>
|
|
||||||
<td>${row.work_order_type}</td>
|
|
||||||
<td>${row.work_order_amount}</td>
|
|
||||||
<td>${row.boq_amount}</td>
|
|
||||||
<td>${row.work_done_percentage}</td>
|
|
||||||
<td>${row.gst_amount}</td>
|
|
||||||
<td>${row.tds_amount}</td>
|
|
||||||
<td>${row.security_deposit}</td>
|
|
||||||
<td>${row.sd_against_gst}</td>
|
|
||||||
<td>${row.final_total}</td>
|
|
||||||
<td>${row.tds_of_gst}</td>
|
|
||||||
</tr>
|
|
||||||
`);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert("No data found for selected filters.");
|
|
||||||
$('#workOrderTable').hide();
|
|
||||||
$('#downloadBtn').hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Download report
|
|
||||||
$('#downloadBtn').click(function () {
|
|
||||||
let vendor = $('#vendor_name').val();
|
|
||||||
let order = $('#work_order_number').val();
|
|
||||||
|
|
||||||
if (!vendor && !order) {
|
|
||||||
alert("Please select filters before downloading.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let url = '/download_work_order_report?';
|
|
||||||
if (vendor) url += 'vendor_name=' + encodeURIComponent(vendor);
|
|
||||||
if (order) url += '&work_order_number=' + encodeURIComponent(order);
|
|
||||||
|
|
||||||
window.location.href = url;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,482 +0,0 @@
|
|||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/add_purchase_order', methods=['GET', 'POST'])
|
|
||||||
def add_purchase_order():
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
# Fetch form fields
|
|
||||||
purchase_date = request.form.get('purchase_date')
|
|
||||||
supplier_name = request.form.get('supplier_name')
|
|
||||||
purchase_order_no = request.form.get('purchase_order_no')
|
|
||||||
item_name = request.form.get('item_name')
|
|
||||||
quantity = request.form.get('quantity')
|
|
||||||
unit = request.form.get('unit')
|
|
||||||
rate = request.form.get('rate')
|
|
||||||
amount = request.form.get('amount')
|
|
||||||
GST_Amount = request.form.get('GST_Amount')
|
|
||||||
TDS = request.form.get('TDS')
|
|
||||||
final_amount = request.form.get('final_amount')
|
|
||||||
LogHelper.log_action("Add purchase order", f"User {current_user.id} Added puirchase Order'{ purchase_order_no}'")
|
|
||||||
# Insert into database
|
|
||||||
insert_query = """
|
|
||||||
INSERT INTO purchase_order (
|
|
||||||
purchase_date, supplier_name, purchase_order_no, item_name, quantity, unit, rate, amount,
|
|
||||||
GST_Amount, TDS, final_amount
|
|
||||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
|
||||||
"""
|
|
||||||
cursor.execute(insert_query, (
|
|
||||||
purchase_date, supplier_name, purchase_order_no, item_name, quantity, unit, rate, amount,
|
|
||||||
GST_Amount, TDS, final_amount
|
|
||||||
))
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
# ✅ Always fetch updated data
|
|
||||||
cursor.execute("SELECT * FROM purchase_order")
|
|
||||||
purchases = cursor.fetchall()
|
|
||||||
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
return render_template('add_purchase_order.html', purchases=purchases)
|
|
||||||
|
|
||||||
|
|
||||||
# Show all purchases
|
|
||||||
@app.route('/purchase_orders')
|
|
||||||
def show_purchase_orders():
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
cursor.execute("SELECT * FROM purchase_order")
|
|
||||||
purchases = cursor.fetchall()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return render_template('add_purchase_order.html', purchases=purchases)
|
|
||||||
|
|
||||||
|
|
||||||
# Delete purchase order
|
|
||||||
@app.route('/delete_purchase/<int:id>', methods=['POST'])
|
|
||||||
def delete_purchase(id):
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor()
|
|
||||||
cursor.execute("DELETE FROM purchase_order WHERE purchase_id = %s", (id,))
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
LogHelper.log_action("Delete purchase order", f"User {current_user.id} Deleted puirchase Order'{ id}'")
|
|
||||||
return render_template(('add_purchase_order.html'))
|
|
||||||
|
|
||||||
|
|
||||||
# Edit purchase order (form + update logic)
|
|
||||||
@app.route('/update_purchase/<int:id>', methods=['GET', 'POST'])
|
|
||||||
def update_purchase(id):
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
# ✅ Form submitted - update all fields
|
|
||||||
data = request.form
|
|
||||||
cursor.execute("""
|
|
||||||
UPDATE purchase_order
|
|
||||||
SET purchase_date = %s,
|
|
||||||
supplier_name = %s,
|
|
||||||
purchase_order_no = %s,
|
|
||||||
item_name = %s,
|
|
||||||
quantity = %s,
|
|
||||||
unit = %s,
|
|
||||||
rate = %s,
|
|
||||||
amount = %s,
|
|
||||||
GST_Amount = %s,
|
|
||||||
TDS = %s,
|
|
||||||
final_amount = %s
|
|
||||||
WHERE purchase_id = %s
|
|
||||||
""", (
|
|
||||||
data['purchase_date'], data['supplier_name'], data['purchase_order_no'], data['item_name'],
|
|
||||||
data['quantity'],
|
|
||||||
data['unit'], data['rate'], data['amount'], data['GST_Amount'], data['TDS'], data['final_amount'],
|
|
||||||
id
|
|
||||||
))
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
LogHelper.log_action("Delete purchase order", f"User {current_user.id} Deleted puirchase Order'{ id}'")
|
|
||||||
return redirect(url_for('show_purchase_orders'))
|
|
||||||
|
|
||||||
# Show edit form
|
|
||||||
cursor.execute("SELECT * FROM purchase_order WHERE purchase_id = %s", (id,))
|
|
||||||
purchase = cursor.fetchone()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return render_template('edit_purchase.html', purchase=purchase)
|
|
||||||
|
|
||||||
|
|
||||||
# SHOW all GRNs + ADD form
|
|
||||||
@app.route('/grn', methods=['GET'])
|
|
||||||
def grn_page():
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
|
|
||||||
# Fetch purchase orders for dropdown
|
|
||||||
cursor.execute("SELECT purchase_id, supplier_name FROM purchase_order")
|
|
||||||
purchase_orders = cursor.fetchall()
|
|
||||||
|
|
||||||
# Fetch all GRNs to display
|
|
||||||
cursor.execute("SELECT * FROM goods_receive_note")
|
|
||||||
grns = cursor.fetchall()
|
|
||||||
print(grns)
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
# Render the template with both datasets
|
|
||||||
return render_template('grn_form.html', purchase_orders=purchase_orders, grns=grns)
|
|
||||||
|
|
||||||
|
|
||||||
# ADD new GRN
|
|
||||||
@app.route('/add_grn', methods=['POST', 'GET'])
|
|
||||||
def add_grn():
|
|
||||||
data = request.form
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor()
|
|
||||||
query = """
|
|
||||||
INSERT INTO goods_receive_note
|
|
||||||
(grn_date, purchase_id, supplier_name, item_description, received_quantity, unit, rate, amount, remarks)
|
|
||||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) \
|
|
||||||
"""
|
|
||||||
cursor.execute(query, (
|
|
||||||
data.get('grn_date'),
|
|
||||||
data.get('purchase_id'),
|
|
||||||
data.get('supplier_name'),
|
|
||||||
data.get('item_description'),
|
|
||||||
data.get('received_quantity'),
|
|
||||||
data.get('unit'),
|
|
||||||
data.get('rate'),
|
|
||||||
data.get('amount'),
|
|
||||||
data.get('remarks')
|
|
||||||
))
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
cursor.execute("SELECT * FROM goods_receive_note")
|
|
||||||
grns = cursor.fetchall()
|
|
||||||
print(grns)
|
|
||||||
query = "select * from purchase_order"
|
|
||||||
cursor.execute(query)
|
|
||||||
purchase_orders = cursor.fetchall()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return render_template('grn_form.html', purchase_orders=purchase_orders, grns=grns)
|
|
||||||
|
|
||||||
|
|
||||||
# UPDATE GRN
|
|
||||||
@app.route('/update_grn/<int:grn_id>', methods=['GET', 'POST'])
|
|
||||||
def update_grn(grn_id):
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
data = request.form
|
|
||||||
query = """
|
|
||||||
UPDATE goods_receive_note
|
|
||||||
SET grn_date=%s, purchase_id=%s, supplier_name=%s, item_description=%s,
|
|
||||||
received_quantity=%s, unit=%s, rate=%s, amount=%s, remarks=%s
|
|
||||||
WHERE grn_id=%s
|
|
||||||
"""
|
|
||||||
cursor.execute(query, (
|
|
||||||
data['grn_date'], data['purchase_id'], data['supplier_name'],
|
|
||||||
data['item_description'], data['received_quantity'], data['unit'],
|
|
||||||
data['rate'], data['amount'], data['remarks'], grn_id
|
|
||||||
))
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return redirect(url_for('grns'))
|
|
||||||
|
|
||||||
cursor.execute("SELECT * FROM goods_receive_note WHERE grn_id = %s", (grn_id,))
|
|
||||||
grn = cursor.fetchone()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return render_template("edit_grn.html", grn=grn)
|
|
||||||
|
|
||||||
|
|
||||||
# DELETE GRN
|
|
||||||
@app.route('/delete_grn/<int:grn_id>', methods=['POST'])
|
|
||||||
def delete_grn(grn_id):
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor()
|
|
||||||
cursor.execute("DELETE FROM goods_receive_note WHERE grn_id = %s", (grn_id,))
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return render_template("grn_form.html")
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/work_order_report', methods=['GET'])
|
|
||||||
def work_order_report():
|
|
||||||
return render_template('work_order_report.html')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ✅ Vendor Name Search (for Select2)
|
|
||||||
@app.route('/get_vendor_names')
|
|
||||||
def get_vendor_names():
|
|
||||||
query = request.args.get('q', '')
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor()
|
|
||||||
cursor.execute("SELECT DISTINCT vendor_name FROM work_order WHERE vendor_name LIKE %s", (f"%{query}%",))
|
|
||||||
vendors = [row[0] for row in cursor.fetchall()]
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return jsonify(vendors)
|
|
||||||
|
|
||||||
|
|
||||||
# ✅ Work Order Number Search (with or without vendor)
|
|
||||||
@app.route('/get_work_order_numbers')
|
|
||||||
def get_work_order_numbers():
|
|
||||||
vendor = request.args.get('vendor_name', '')
|
|
||||||
query = request.args.get('q', '')
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor()
|
|
||||||
|
|
||||||
if vendor:
|
|
||||||
cursor.execute(
|
|
||||||
"SELECT DISTINCT work_order_number FROM work_order WHERE vendor_name = %s AND work_order_number LIKE %s",
|
|
||||||
(vendor, f"%{query}%"))
|
|
||||||
else:
|
|
||||||
cursor.execute("SELECT DISTINCT work_order_number FROM work_order WHERE work_order_number LIKE %s",
|
|
||||||
(f"%{query}%",))
|
|
||||||
|
|
||||||
orders = [row[0] for row in cursor.fetchall()]
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return jsonify(orders)
|
|
||||||
|
|
||||||
|
|
||||||
# ✅ Get Work Order Data (Filtered)
|
|
||||||
@app.route('/get_work_order_data')
|
|
||||||
def get_work_order_data():
|
|
||||||
vendor = request.args.get('vendor_name')
|
|
||||||
order_number = request.args.get('work_order_number')
|
|
||||||
|
|
||||||
query = "SELECT * FROM work_order WHERE 1=1"
|
|
||||||
params = []
|
|
||||||
|
|
||||||
if vendor:
|
|
||||||
query += " AND vendor_name = %s"
|
|
||||||
params.append(vendor)
|
|
||||||
if order_number:
|
|
||||||
query += " AND work_order_number = %s"
|
|
||||||
params.append(order_number)
|
|
||||||
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
cursor.execute(query, tuple(params))
|
|
||||||
data = cursor.fetchall()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return jsonify(data)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/download_work_order_report')
|
|
||||||
def download_work_order_report():
|
|
||||||
vendor_name = request.args.get('vendor_name')
|
|
||||||
work_order_number = request.args.get('work_order_number')
|
|
||||||
|
|
||||||
if work_order_number == "null":
|
|
||||||
work_order_number = None
|
|
||||||
|
|
||||||
query = "SELECT * FROM work_order WHERE 1=1"
|
|
||||||
params = []
|
|
||||||
|
|
||||||
if vendor_name:
|
|
||||||
query += " AND vendor_name = %s"
|
|
||||||
params.append(vendor_name)
|
|
||||||
if work_order_number:
|
|
||||||
query += " AND work_order_number = %s"
|
|
||||||
params.append(work_order_number)
|
|
||||||
|
|
||||||
conn = config.get_db_connection()
|
|
||||||
cursor = conn.cursor(dictionary=True)
|
|
||||||
cursor.execute(query, tuple(params))
|
|
||||||
data = cursor.fetchall()
|
|
||||||
cursor.close()
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
if not data:
|
|
||||||
return "No data found for the selected filters", 404
|
|
||||||
|
|
||||||
# Convert to DataFrame
|
|
||||||
df = pd.DataFrame(data)
|
|
||||||
|
|
||||||
output_path = 'static/downloads/work_order_report.xlsx'
|
|
||||||
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
|
||||||
df.to_excel(output_path, index=False, startrow=2) # Leave space for heading
|
|
||||||
|
|
||||||
# Load workbook for styling
|
|
||||||
wb = load_workbook(output_path)
|
|
||||||
ws = wb.active
|
|
||||||
|
|
||||||
# Add a merged title
|
|
||||||
title = "Work Order Report"
|
|
||||||
ws.merge_cells(start_row=1, start_column=1, end_row=1, end_column=len(df.columns))
|
|
||||||
title_cell = ws.cell(row=1, column=1)
|
|
||||||
title_cell.value = title
|
|
||||||
title_cell.font = Font(size=14, bold=True, color="1F4E78")
|
|
||||||
title_cell.alignment = Alignment(horizontal="center", vertical="center")
|
|
||||||
|
|
||||||
# Style header row (row 3 because data starts from row 3)
|
|
||||||
header_font = Font(bold=True)
|
|
||||||
for col_num, column_name in enumerate(df.columns, 1):
|
|
||||||
cell = ws.cell(row=3, column=col_num)
|
|
||||||
cell.font = header_font
|
|
||||||
cell.alignment = Alignment(horizontal="center", vertical="center")
|
|
||||||
# Optional: adjust column width
|
|
||||||
max_length = max(len(str(column_name)), 12)
|
|
||||||
ws.column_dimensions[get_column_letter(col_num)].width = max_length + 2
|
|
||||||
|
|
||||||
wb.save(output_path)
|
|
||||||
return send_file(output_path, as_attachment=True)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/purchase_order_report', methods=['GET'])
|
|
||||||
def purchase_order_report():
|
|
||||||
return render_template('purchase_order_report.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/get_supplier_names')
|
|
||||||
def get_supplier_names():
|
|
||||||
query = request.args.get('q', '') # Get the search term from Select2
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor()
|
|
||||||
|
|
||||||
# Fetch distinct supplier names that match the search query
|
|
||||||
cursor.execute(
|
|
||||||
"SELECT supplier_name FROM purchase_order WHERE supplier_name LIKE %s",
|
|
||||||
(f"%{query}%",)
|
|
||||||
)
|
|
||||||
suppliers = [row[0] for row in cursor.fetchall()]
|
|
||||||
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return jsonify(suppliers)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/get_purchase_order_numbers')
|
|
||||||
def get_purchase_order_numbers():
|
|
||||||
supplier = request.args.get('supplier_name', '')
|
|
||||||
query = request.args.get('q', '')
|
|
||||||
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor()
|
|
||||||
|
|
||||||
if supplier:
|
|
||||||
cursor.execute("""
|
|
||||||
SELECT purchase_order_no
|
|
||||||
FROM purchase_order
|
|
||||||
WHERE supplier_name = %s AND purchase_order_no LIKE %s
|
|
||||||
""", (supplier, f"%{query}%"))
|
|
||||||
else:
|
|
||||||
cursor.execute("""
|
|
||||||
SELECT purchase_order_no
|
|
||||||
FROM purchase_order
|
|
||||||
WHERE purchase_order_no LIKE %s
|
|
||||||
""", (f"%{query}%",))
|
|
||||||
|
|
||||||
orders = [row[0] for row in cursor.fetchall()]
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return jsonify(orders)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/get_purchase_order_data')
|
|
||||||
def get_purchase_order_data():
|
|
||||||
supplier = request.args.get('supplier_name')
|
|
||||||
order_no = request.args.get('purchase_order_no')
|
|
||||||
|
|
||||||
query = "SELECT * FROM purchase_order WHERE 1=1"
|
|
||||||
params = []
|
|
||||||
|
|
||||||
if supplier:
|
|
||||||
query += " AND supplier_name = %s"
|
|
||||||
params.append(supplier)
|
|
||||||
if order_no:
|
|
||||||
query += " AND purchase_order_no = %s"
|
|
||||||
params.append(order_no)
|
|
||||||
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
cursor.execute(query, tuple(params))
|
|
||||||
data = cursor.fetchall()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return jsonify(data)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/download_purchase_order_report')
|
|
||||||
def download_purchase_order_report():
|
|
||||||
supplier_name = request.args.get('supplier_name')
|
|
||||||
purchase_order_no = request.args.get('purchase_order_no')
|
|
||||||
|
|
||||||
if purchase_order_no == "null":
|
|
||||||
purchase_order_no = None
|
|
||||||
LogHelper.log_action("Download purchase order", f"User {current_user.id} Download puirchase Order'{ purchase_order_no}'")
|
|
||||||
query = "SELECT * FROM purchase_order WHERE 1=1"
|
|
||||||
params = []
|
|
||||||
|
|
||||||
if supplier_name:
|
|
||||||
query += " AND supplier_name = %s"
|
|
||||||
params.append(supplier_name)
|
|
||||||
if purchase_order_no:
|
|
||||||
query += " AND purchase_order_no = %s"
|
|
||||||
params.append(purchase_order_no)
|
|
||||||
|
|
||||||
conn = config.get_db_connection()
|
|
||||||
cursor = conn.cursor(dictionary=True)
|
|
||||||
cursor.execute(query, tuple(params))
|
|
||||||
data = cursor.fetchall()
|
|
||||||
cursor.close()
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
if not data:
|
|
||||||
return "No data found for the selected filters", 404
|
|
||||||
|
|
||||||
# Convert to DataFrame
|
|
||||||
df = pd.DataFrame(data)
|
|
||||||
|
|
||||||
output_path = 'static/downloads/purchase_order_report.xlsx'
|
|
||||||
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
|
||||||
|
|
||||||
df.to_excel(output_path, index=False, startrow=2) # Reserve space for heading
|
|
||||||
|
|
||||||
# Load workbook for styling
|
|
||||||
wb = load_workbook(output_path)
|
|
||||||
ws = wb.active
|
|
||||||
|
|
||||||
# Add a merged title
|
|
||||||
title = "Purchase Order Report"
|
|
||||||
ws.merge_cells(start_row=1, start_column=1, end_row=1, end_column=len(df.columns))
|
|
||||||
title_cell = ws.cell(row=1, column=1)
|
|
||||||
title_cell.value = title
|
|
||||||
title_cell.font = Font(size=14, bold=True, color="1F4E78")
|
|
||||||
title_cell.alignment = Alignment(horizontal="center", vertical="center")
|
|
||||||
|
|
||||||
# Style header row (row 3 because data starts from row 3)
|
|
||||||
header_font = Font(bold=True)
|
|
||||||
for col_num, column_name in enumerate(df.columns, 1):
|
|
||||||
cell = ws.cell(row=3, column=col_num)
|
|
||||||
cell.font = header_font
|
|
||||||
cell.alignment = Alignment(horizontal="center", vertical="center")
|
|
||||||
max_length = max(len(str(column_name)), 12)
|
|
||||||
ws.column_dimensions[get_column_letter(col_num)].width = max_length + 2
|
|
||||||
|
|
||||||
wb.save(output_path)
|
|
||||||
return send_file(output_path, as_attachment=True)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run(host='0.0.0.0', port=5000, debug=True)
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
# -- end hold types controlller --------------------
|
|
||||||
|
|
||||||
# Route to display the HTML form
|
|
||||||
@app.route('/add_work_order', methods=['GET'])
|
|
||||||
def add_work_order():
|
|
||||||
# Add database connection
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
|
|
||||||
cursor.execute("SELECT Contractor_id, Contractor_Name FROM subcontractors") # Adjust table/column names as needed
|
|
||||||
subcontractor = cursor.fetchall()
|
|
||||||
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
return render_template('add_work_order.html', subcontractor=subcontractor) # This is your HTML form page
|
|
||||||
|
|
||||||
|
|
||||||
# Route to handle form submission (from action="/submit_work_order")
|
|
||||||
@app.route('/submit_work_order', methods=['POST', 'GET'])
|
|
||||||
def submit_work_order():
|
|
||||||
vendor_name = request.form['vendor_name']
|
|
||||||
work_order_type = request.form['work_order_type']
|
|
||||||
work_order_amount = request.form['work_order_amount']
|
|
||||||
boq_amount = request.form['boq_amount']
|
|
||||||
work_done_percentage = request.form['work_done_percentage']
|
|
||||||
work_order_number = request.form['work_order_number']
|
|
||||||
gst_amount = request.form['gst_amount']
|
|
||||||
tds_amount = request.form['tds_amount']
|
|
||||||
security_deposite = request.form['security_deposite']
|
|
||||||
sd_against_gst = request.form['sd_against_gst']
|
|
||||||
final_total = request.form['final_total']
|
|
||||||
tds_of_gst = request.form['tds_of_gst']
|
|
||||||
LogHelper.log_action("Submit Work Order", f"User {current_user.id} Submit Work Order'{ work_order_type}'")
|
|
||||||
# print("Good Morning How are U")
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
# print("Good morning and how are you")
|
|
||||||
insert_query = """
|
|
||||||
INSERT INTO work_order
|
|
||||||
(vendor_name, work_order_type, work_order_amount, boq_amount, work_done_percentage,work_order_number,gst_amount,tds_amount
|
|
||||||
,security_deposit,sd_against_gst,final_total,tds_of_gst)
|
|
||||||
VALUES (%s, %s, %s, %s, %s,%s,%s,%s,%s,%s,%s,%s)
|
|
||||||
"""
|
|
||||||
cursor.execute(insert_query,
|
|
||||||
(vendor_name, work_order_type, work_order_amount, boq_amount, work_done_percentage, work_order_number
|
|
||||||
, gst_amount, tds_amount, security_deposite, sd_against_gst, final_total, tds_of_gst))
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
# ✅ Fetch all data after insert
|
|
||||||
select_query = "SELECT * FROM work_order"
|
|
||||||
cursor.execute(select_query)
|
|
||||||
wo = cursor.fetchall()
|
|
||||||
# print("The Work order data is ",wo)
|
|
||||||
print("The data from work order ", wo) # should now print the data properly
|
|
||||||
cursor.execute("SELECT Contractor_id, Contractor_Name FROM subcontractors") # Adjust table/column names as needed
|
|
||||||
subcontractor = cursor.fetchall()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
return render_template('add_work_order.html', work_order_type=work_order_type, wo=wo, subcontractor=subcontractor)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/delete_work_order/<int:id>', methods=['POST'])
|
|
||||||
def delete_work_order(id):
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor()
|
|
||||||
cursor.execute("DELETE FROM work_order WHERE work_order_id = %s", (id,))
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
LogHelper.log_action("delete Work Order", f"User {current_user.id} delete Work Order'{ id}'")
|
|
||||||
return jsonify({'success': True})
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/update_work_order/<int:id>', methods=['GET', 'POST'])
|
|
||||||
def update_work_order(id):
|
|
||||||
connection = config.get_db_connection()
|
|
||||||
cursor = connection.cursor(dictionary=True)
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
|
||||||
work_order_type = request.form['work_order_type']
|
|
||||||
work_order_amount = request.form['work_order_amount']
|
|
||||||
boq_amount = request.form['boq_amount']
|
|
||||||
work_done_percentage = request.form['work_done_percentage']
|
|
||||||
work_order_number = request.form['work_order_number']
|
|
||||||
gst_amount = request.form['gst_amount']
|
|
||||||
tds_amount = request.form['tds_amount']
|
|
||||||
security_deposite = request.form['security_deposite']
|
|
||||||
sd_against_gst = request.form['sd_against_gst']
|
|
||||||
final_amount = request.form['final_amount']
|
|
||||||
tds_of_gst = request.form['tds_of_gst']
|
|
||||||
update_query = """
|
|
||||||
UPDATE work_order
|
|
||||||
SET work_order_type = %s,
|
|
||||||
work_order_amount = %s,
|
|
||||||
boq_amount = %s,
|
|
||||||
work_done_percentage = %s,
|
|
||||||
work_order_number= %s,
|
|
||||||
gst_amount = %s,
|
|
||||||
tds_amount= %s,
|
|
||||||
security_deposite= %s,
|
|
||||||
sd_against_gst=%s,
|
|
||||||
final_amount= %s,
|
|
||||||
tds_of_gst=%s
|
|
||||||
WHERE work_order_id = %s
|
|
||||||
"""
|
|
||||||
cursor.execute(update_query, (
|
|
||||||
work_order_type, work_order_amount, boq_amount, work_done_percentage, work_order_number, gst_amount,
|
|
||||||
tds_amount, security_deposite, sd_against_gst, final_amount, tds_of_gst, id))
|
|
||||||
connection.commit()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
# If GET request: fetch the existing record
|
|
||||||
cursor.execute("SELECT * FROM work_order WHERE work_order_id = %s", (id,))
|
|
||||||
work_order = cursor.fetchone()
|
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
return render_template('update_work_order.html', work_order=work_order)
|
|
||||||
|
|
||||||
|
|
||||||
# Optional: Route to show a success message
|
|
||||||
@app.route('/success')
|
|
||||||
def success():
|
|
||||||
return "Work Order Submitted Successfully!"
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user