first commit

This commit is contained in:
Isuru Bimsara
2026-08-14 22:46:02 +05:30
commit 81d0e65686
132 changed files with 24398 additions and 0 deletions
@@ -0,0 +1,48 @@
/**
* Copyright (c) 2026 Niolla
* All rights reserved.
*
* This source code is proprietary and confidential.
* Unauthorized copying, modification, distribution, or use
* of this file, via any medium, is strictly prohibited.
*/
// app/templates/documents/precost/preCost.template.js
const { log } = require("../../../utils/consoleLog.utill");
module.exports = async (data) => {
log("📋 Preparing PreCost data for PDF...");
log("📥 Incoming data:", JSON.stringify(data, null, 2));
const templateData = {
logoUrl:
"https://res.cloudinary.com/dtthuvvir/image/upload/v1780748661/company_logo_transperent_bg_uullzw.png",
vesselName: data.vessel_name || "MV Vessel",
supplierName: data.supplyPort || "N/A",
clientRfqNum: data.clientRfqNum || "N/A",
omsRfqNum: data.omsRfqNum || "N/A",
date: data.date || new Date().toLocaleDateString(),
items: data.items || [],
subtotal: data.sub_total || 0,
discount: data.discount || 0,
additionalCharges: data.additionalCharges || 0,
fullTotal: data.total_cost || data.total_cost_usd || (data.sub_total - data.discount + data.additionalCharges) || 0,
};
log("Data:", data);
log("fullTotal calculation:", {
total_cost: data.total_cost,
total_cost_usd: data.total_cost_usd,
calculated: data.sub_total - data.discount + data.additionalCharges,
final: templateData.fullTotal,
});
log("✅ PreCost data prepared:", JSON.stringify(templateData, null, 2));
return templateData;
};
+300
View File
@@ -0,0 +1,300 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: white;
font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
padding: 20px;
}
.container {
max-width: 1000px;
margin: 0 auto;
background: white;
}
.header-section {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
border-bottom: 2px solid #1a7a4d;
padding-bottom: 15px;
}
.header-section img {
height: 80px;
}
.po-title {
font-size: 28px;
font-weight: bold;
color: #1a7a4d;
text-align: center;
flex: 1;
}
.info-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 30px;
background: #e8f5e9;
padding: 15px;
border-radius: 4px;
}
.info-left,
.info-right {
display: flex;
flex-direction: column;
gap: 8px;
}
.info-row {
display: flex;
justify-content: space-between;
}
.info-label {
font-weight: bold;
color: #2e7d32;
min-width: 150px;
}
.info-value {
color: #333;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
.items-table thead {
background-color: #2e7d32;
color: white;
}
.items-table th {
padding: 12px;
text-align: left;
font-weight: bold;
font-size: 12px;
}
.items-table td {
padding: 12px;
border-bottom: 1px solid #ddd;
}
.items-table tbody tr:nth-child(even) {
background-color: #f5f5f5;
}
.summary-area {
display: flex;
justify-content: flex-end;
margin-top: 30px;
margin-bottom: 30px;
}
.summary-table {
width: 400px;
}
.summary-table td {
padding: 10px;
border: 1px solid #ddd;
}
.summary-table td:first-child {
font-weight: bold;
background-color: #f5f5f5;
width: 60%;
}
.summary-table td:last-child {
text-align: right;
}
.total-row {
background-color: #2e7d32;
color: white;
font-weight: bold;
font-size: 14px;
}
.total-row td {
border-color: #1a7a4d;
}
.footer-note {
text-align: center;
margin-top: 40px;
border-top: 2px solid #ddd;
padding-top: 20px;
}
.footer-note img {
max-width: 100%;
height: auto;
}
.text-black{
color: black !important;
}
</style>
</head>
<body>
<div class="container">
<!-- HEADER SECTION -->
<div class="header-section">
<div>
<% if (logoBase64) { %>
<img src="<%= logoBase64 %>" alt="Company Logo" />
<% } %>
</div>
<div class="po-title">PRICE QUOTATION</div>
</div>
<!-- INFO GRID -->
<div class="info-grid">
<div class="info-left">
<div class="info-row">
<span class="info-label">VESSEL NAME :</span>
<span class="info-value">
<%= vesselName %>
</span>
</div>
<div class="info-row">
<span class="info-label">SUPPLY PORT :</span>
<span class="info-value">
<%= supplierName || 'Supplier Name' %>
</span>
</div>
</div>
<div class="info-right">
<div class="info-row">
<span class="info-label">CLIENT RFQ :</span>
<span class="info-value">
<%= clientRfqNum || 'RFQ-001' %>
</span>
</div>
<div class="info-row">
<span class="info-label">OMS RFQ :</span>
<span class="info-value">
<%= omsRfqNum || 'RFQ-001' %>
</span>
</div>
<div class="info-row">
<span class="info-label">DATE :</span>
<span class="info-value">
<%= date || 'Current Date' %>
</span>
</div>
</div>
</div>
<!-- ITEMS TABLE -->
<div style="overflow-x: auto;">
<table class="items-table">
<thead>
<tr>
<th>ITEM NO</th>
<th>DESCRIPTION</th>
<th>REMARKS</th>
<th>QTY</th>
<th>UNIT</th>
<th>UNIT PRICE</th>
<th>TOTAL PRICE</th>
</tr>
</thead>
<tbody>
<% if (items && items.length> 0) { %>
<% items.forEach((item, index)=> { %>
<tr>
<td>
<%= index + 1 %>
</td>
<td>
<%= item.item_name || '' %>
</td>
<td>
<%= item.customer_remark || '' %>
</td>
<td>
<%= item.quantity || 0 %>
</td>
<td>
<%= item.unit || '' %>
</td>
<td>
<%= item.unit_price || 0 %>
</td>
<td>
<%= (item.quantity || 0) * (item.unit_price || 0) %>
</td>
</tr>
<% }); %>
<% } %>
</tbody>
</table>
</div>
<!-- SUMMARY SECTION -->
<div class="summary-area">
<table class="summary-table">
<tr>
<td>SUB TOTAL</td>
<td>
<%= subtotal || 0 %>
</td>
</tr>
<% if (discount && Number(discount) !==0) { %>
<tr>
<td>DISCOUNT (%)</td>
<td>
<%= discount %>
</td>
</tr>
<% } %>
<% if (additionalCharges && Number(additionalCharges) !==0) { %>
<tr>
<td>ADDITIONAL CHARGES<br />(CUSTOM/HANDLING/TRANSPORT)</td>
<td>
<%= additionalCharges %>
</td>
</tr>
<% } %>
<tr class="total-row">
<td class="text-black" >GRAND TOTAL</td>
<td>
<%= fullTotal || 0 %>
</td>
</tr>
</table>
</div>
<!-- FOOTER -->
<div class="footer-note">
<img src="https://res.cloudinary.com/dtthuvvir/image/upload/v1780748661/footer_ax2jyz.png" alt="Footer">
</div>
</div>
</body>
</html>
+527
View File
@@ -0,0 +1,527 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: white;
display: flex;
justify-content: center;
align-items: center;
padding: 2rem 1rem;
font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
}
/* actual table style — clean, border-collapse */
.po-table {
width: 100%;
border-collapse: collapse;
font-size: 0.85rem;
font-family: 'Segoe UI', system-ui, 'Calibri', sans-serif;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
/* header sections & company info area (using table-like but not inside main table) */
.header-section {
margin-bottom: 1.8rem;
text-align: center;
}
.po-title {
font-size: 2rem;
font-weight: 700;
letter-spacing: 1px;
color: #257339;
border-top: 2px solid #257339;
border-bottom: 2px solid #257339;
padding: 1rem;
margin-bottom: 1.5rem;
margin-top: 1.5rem;
font-family: 'Inter', 'Segoe UI', sans-serif;
}
/* two column info grid (company, supplier, dates etc) */
.info-grid {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 1.2rem;
margin-bottom: 2rem;
background: #e1f3db;
padding: 1rem 1.2rem;
border: 1px solid #e2edf2;
}
.info-left {
flex: 2;
min-width: 240px;
}
.info-right {
flex: 1.2;
min-width: 200px;
}
.info-row {
display: flex;
align-items: baseline;
flex-wrap: wrap;
margin-bottom: 12px;
font-size: 0.9rem;
}
.info-label {
font-weight: 700;
width: 140px;
color: #257339;
letter-spacing: 0.3px;
}
.info-value {
font-weight: 500;
color: #1f2d3d;
border-bottom: 1px dashed #bdd3e6;
min-width: 200px;
padding: 0 0.2rem;
background: transparent;
}
.inline-placeholder {
color: #2c7da0;
font-weight: 500;
}
hr {
margin: 1rem 0;
}
/* main items table */
.items-table {
width: 100%;
border-collapse: collapse;
margin: 1.2rem 0 1rem;
font-size: 0.8rem;
}
.items-table th,
.items-table td {
border: 1px solid #cddfe7;
padding: 10px 6px;
vertical-align: top;
text-align: left;
}
.items-table th {
background-color: #257339;
color: white;
font-weight: 600;
font-size: 0.8rem;
letter-spacing: 0.5px;
text-align: center;
}
.items-table td {
background-color: #fff;
color: #1e2a3a;
}
.items-table input,
.items-table .pseudo-input {
width: 100%;
border: none;
background: transparent;
font-family: inherit;
font-size: 0.8rem;
padding: 4px 2px;
outline: none;
border-bottom: 1px dotted #acc8dd;
}
.items-table input:focus {
border-bottom: 1px solid #1f6e8c;
background: #fefce8;
}
/* numeric cells alignment */
.numeric-cell {
text-align: right;
}
.qty-cell input,
.price-cell input {
text-align: right;
}
.total-cell {
font-weight: 600;
background-color: #f8fafc;
text-align: right;
}
/* summary section (subtotal, discount, transport) */
.summary-area {
margin-top: 1.5rem;
display: flex;
flex-direction: column;
align-items: flex-end;
border-top: 2px solid #cbdde6;
padding-top: 1.2rem;
}
.summary-table {
width: 320px;
border-collapse: collapse;
font-size: 0.85rem;
}
.summary-table td {
padding: 6px 8px;
border: none;
}
.summary-table td:first-child {
font-weight: 700;
text-align: left;
}
.summary-table td:last-child {
text-align: right;
font-weight: 600;
}
.total-row {
border-top: 2px solid #2c5a74;
font-weight: 800;
font-size: 1rem;
}
.discount-input,
.transport-input {
border: 1px solid #b9d0df;
border-radius: 8px;
padding: 4px 10px;
width: 110px;
text-align: right;
font-weight: 500;
background: #fff;
}
.inline-action {
display: inline-flex;
align-items: center;
gap: 5px;
}
button.recalc {
background: #eef2f5;
border: 1px solid #b9cfdf;
border-radius: 30px;
padding: 4px 12px;
font-size: 0.7rem;
cursor: pointer;
transition: 0.1s;
margin-left: 10px;
font-weight: 500;
}
button.recalc:hover {
background: #cbdde6;
}
.footer-note {
margin-top: 2rem;
font-size: 0.7rem;
text-align: center;
color: #547b97;
border-top: 1px solid #d4e2ec;
padding-top: 1rem;
}
@media (max-width: 750px) {
.po-container {
padding: 1rem;
}
.info-grid {
flex-direction: column;
}
.summary-table {
width: 100%;
}
.items-table th,
.items-table td {
padding: 6px 3px;
font-size: 0.7rem;
}
}
.editable-highlight {
background-color: #fef9e3;
} * {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: white;
display: flex;
justify-content: center;
align-items: center;
padding: 2rem 1rem;
font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
}
/* actual table style — clean, border-collapse */
.po-table {
width: 100%;
border-collapse: collapse;
font-size: 0.85rem;
font-family: 'Segoe UI', system-ui, 'Calibri', sans-serif;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
/* header sections & company info area (using table-like but not inside main table) */
.header-section {
margin-bottom: 1.8rem;
text-align: center;
}
.po-title {
font-size: 2rem;
font-weight: 700;
letter-spacing: 1px;
color: #257339;
border-top: 2px solid #257339;
border-bottom: 2px solid #257339;
padding: 1rem;
margin-bottom: 1.5rem;
margin-top: 1.5rem;
font-family: 'Inter', 'Segoe UI', sans-serif;
}
/* two column info grid (company, supplier, dates etc) */
.info-grid {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 1.2rem;
margin-bottom: 2rem;
background: #e1f3db;
padding: 1rem 1.2rem;
border: 1px solid #e2edf2;
}
.info-left {
flex: 2;
min-width: 240px;
}
.info-right {
flex: 1.2;
min-width: 200px;
}
.info-row {
display: flex;
align-items: baseline;
flex-wrap: wrap;
margin-bottom: 12px;
font-size: 0.9rem;
}
.info-label {
font-weight: 700;
width: 140px;
color: #257339;
letter-spacing: 0.3px;
}
.info-value {
font-weight: 500;
color: #1f2d3d;
border-bottom: 1px dashed #bdd3e6;
min-width: 200px;
padding: 0 0.2rem;
background: transparent;
}
.inline-placeholder {
color: #2c7da0;
font-weight: 500;
}
hr {
margin: 1rem 0;
}
/* main items table */
.items-table {
width: 100%;
border-collapse: collapse;
margin: 1.2rem 0 1rem;
font-size: 0.8rem;
}
.items-table th,
.items-table td {
border: 1px solid #cddfe7;
padding: 10px 6px;
vertical-align: top;
text-align: left;
}
.items-table th {
background-color: #257339;
color: white;
font-weight: 600;
font-size: 0.8rem;
letter-spacing: 0.5px;
text-align: center;
}
.items-table td {
background-color: #fff;
color: #1e2a3a;
}
.items-table input,
.items-table .pseudo-input {
width: 100%;
border: none;
background: transparent;
font-family: inherit;
font-size: 0.8rem;
padding: 4px 2px;
outline: none;
border-bottom: 1px dotted #acc8dd;
}
.items-table input:focus {
border-bottom: 1px solid #1f6e8c;
background: #fefce8;
}
/* numeric cells alignment */
.numeric-cell {
text-align: right;
}
.qty-cell input,
.price-cell input {
text-align: right;
}
.total-cell {
font-weight: 600;
background-color: #f8fafc;
text-align: right;
}
/* summary section (subtotal, discount, transport) */
.summary-area {
margin-top: 1.5rem;
display: flex;
flex-direction: column;
align-items: flex-end;
border-top: 2px solid #cbdde6;
padding-top: 1.2rem;
}
.summary-table {
width: 320px;
border-collapse: collapse;
font-size: 0.85rem;
}
.summary-table td {
padding: 6px 8px;
border: none;
}
.summary-table td:first-child {
font-weight: 700;
text-align: left;
}
.summary-table td:last-child {
text-align: right;
font-weight: 600;
}
.total-row {
border-top: 2px solid #2c5a74;
font-weight: 800;
font-size: 1rem;
}
.discount-input,
.transport-input {
border: 1px solid #b9d0df;
border-radius: 8px;
padding: 4px 10px;
width: 110px;
text-align: right;
font-weight: 500;
background: #fff;
}
.inline-action {
display: inline-flex;
align-items: center;
gap: 5px;
}
button.recalc {
background: #eef2f5;
border: 1px solid #b9cfdf;
border-radius: 30px;
padding: 4px 12px;
font-size: 0.7rem;
cursor: pointer;
transition: 0.1s;
margin-left: 10px;
font-weight: 500;
}
button.recalc:hover {
background: #cbdde6;
}
.footer-note {
margin-top: 2rem;
font-size: 0.7rem;
text-align: center;
color: #547b97;
border-top: 1px solid #d4e2ec;
padding-top: 1rem;
}
@media (max-width: 750px) {
.po-container {
padding: 1rem;
}
.info-grid {
flex-direction: column;
}
.summary-table {
width: 100%;
}
.items-table th,
.items-table td {
padding: 6px 3px;
font-size: 0.7rem;
}
}
.editable-highlight {
background-color: #fef9e3;
}
@@ -0,0 +1,97 @@
<html>
<head>
<style>
{{styles}}
</style>
</head>
<body>
<div>
<!-- PURCHASE ORDER title -->
<div class="header-section">
<div>
<img src="{{logoBase64}}" alt="Company Logo" style="height:80px; margin-bottom:-8px;" />
</div>
<div class="po-title">PRICE QUOTATION</div>
</div>
<!-- Company & supplier info (dynamic / editable) -->
<div class="info-grid">
<div class="info-left">
<div class="info-row">
<span class="info-label">VESSEL NAME :</span>
<span class="info-value" id="companyName">Oceanic Maritime Solutions (Pvt) Ltd</span>
</div>
<div class="info-row">
<span class="info-label">SUPPLY PORT :</span>
<span class="info-value" id="supplierName">Supplier Name</span>
</div>
</div>
<div class="info-right">
<div class="info-row">
<span class="info-label">CLIENT RFQ :</span>
<span class="info-value" id="rfqNum">RFQ-001</span>
</div>
<div class="info-row">
<span class="info-label">OMS RFQ :</span>
<span class="info-value" id="rfqNum">RFQ-001</span>
</div>
<div class="info-row">
<span class="info-label">DATE :</span>
<span class="info-value" id="orderDate">Current Date</span>
</div>
</div>
</div>
<!-- items table: ITEM NO, DESCRIPTION, REMARKS, UNIT, QTY, UNIT PRICE, TOTAL PRICE -->
<div style="overflow-x: auto;">
<table class="items-table" id="poItemsTable">
<thead>
<tr>
<th>ITEM NO</th>
<th>DESCRIPTION</th>
<th>REMARKS</th>
<th>QTY</th>
<th>UNIT</th>
<th>UNIT PRICE</th>
<th>TOTAL PRICE</th>
</tr>
</thead>
<tbody id="itemsTableBody">
{{items}}
</tbody>
</table>
</div>
<!-- summary: subtotal, discount, transportation, full total -->
<div class="summary-area">
<table class="summary-table" id="summaryTable">
<tr>
<td>SUB TOTAL</td>
<td id="subTotalVal">{{subtotal}}</td>
</tr>
<tr>
<td>DISCOUNT <span style="font-weight:normal;">(%)</span>
</td>
<td id="discountAmount">{{discount}}</td>
</tr>
<tr>
<td>ADDITIONAL CHARGES (CUSTOM/HANDLING/TRANSPORT)
</td>
<td id="transportDisplay">{{transport}}</td>
</tr>
<tr class="total-row">
<td>GRAND TOTAL</td>
<td id="fullTotalVal">{{fullTotal}}</td>
</tr>
</table>
</div>
<div class="footer-note">
<img src="https://res.cloudinary.com/dtthuvvir/image/upload/v1780748661/footer_ax2jyz.png" alt="Footer">
</div>
</div>
</body>
</html>