Files
sap-erp/public/docs/SAP_B1_Portal_Documentation.html
T
John 69b4e68baf
SAP-ERP Portal CI/CD / build (push) Failing after 5m20s
first commit
2026-09-23 17:31:02 +05:30

845 lines
44 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MITRA ERP Portal &mdash; User &amp; Technical Documentation</title>
<style>
@page {
size: A4;
margin: 25mm 20mm 25mm 20mm;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: Georgia, 'Times New Roman', Times, serif;
font-size: 11.5pt;
line-height: 1.65;
color: #1a1a1a;
background: #e8e8e8;
}
/* ── Page container ── */
.page {
width: 210mm;
min-height: 297mm;
margin: 12mm auto;
padding: 30mm 25mm 30mm 25mm;
background: #fff;
box-shadow: 0 2px 12px rgba(0,0,0,.12);
page-break-after: always;
position: relative;
}
.page:last-child { page-break-after: auto; }
/* ── Typography ── */
h1 {
font-family: 'Segoe UI', Calibri, Arial, sans-serif;
font-size: 28pt;
font-weight: 700;
color: #1A5276;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
h2 {
font-family: 'Segoe UI', Calibri, Arial, sans-serif;
font-size: 18pt;
font-weight: 700;
color: #1A5276;
margin-top: 22px;
margin-bottom: 10px;
padding-bottom: 5px;
border-bottom: 2px solid #1A5276;
}
h3 {
font-family: 'Segoe UI', Calibri, Arial, sans-serif;
font-size: 13pt;
font-weight: 700;
color: #2471A3;
margin-top: 16px;
margin-bottom: 6px;
}
h4 {
font-family: 'Segoe UI', Calibri, Arial, sans-serif;
font-size: 11.5pt;
font-weight: 600;
color: #1A5276;
margin-top: 10px;
margin-bottom: 4px;
}
p { margin-bottom: 8px; text-align: justify; }
ul, ol { margin-left: 22px; margin-bottom: 10px; }
li { margin-bottom: 4px; }
/* ── Cover page ── */
.cover {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
min-height: 237mm;
}
.cover-logo {
width: 90px; height: 90px;
border-radius: 18px;
background: #1A5276;
display: flex; align-items: center; justify-content: center;
font-family: 'Segoe UI', Calibri, sans-serif;
font-size: 32pt; font-weight: 800; color: #fff;
margin-bottom: 30px;
box-shadow: 0 4px 16px rgba(26,82,118,.3);
}
.cover h1 {
font-size: 30pt;
border: none;
margin-bottom: 8px;
}
.cover .subtitle {
font-family: 'Segoe UI', Calibri, sans-serif;
font-size: 15pt;
color: #5D6D7E;
font-weight: 400;
margin-bottom: 50px;
}
.cover .date {
font-family: 'Segoe UI', Calibri, sans-serif;
font-size: 12pt;
color: #7F8C8D;
margin-top: 20px;
}
.cover-line {
width: 80px;
height: 3px;
background: #1A5276;
margin: 18px auto 18px auto;
}
.cover .confidential {
font-family: 'Segoe UI', Calibri, sans-serif;
font-size: 10pt;
color: #AAB7B8;
text-transform: uppercase;
letter-spacing: 2px;
margin-top: 40px;
}
/* ── TOC ── */
.toc a {
color: #1a1a1a;
text-decoration: none;
display: flex;
justify-content: space-between;
padding: 5px 0;
border-bottom: 1px dotted #ccc;
font-size: 11pt;
}
.toc a:hover { color: #1A5276; }
.toc .toc-section {
font-weight: 700;
font-family: 'Segoe UI', Calibri, sans-serif;
color: #1A5276;
margin-top: 8px;
font-size: 12pt;
}
.toc .toc-sub {
padding-left: 18px;
font-size: 10.5pt;
}
/* ── Tables ── */
table {
width: 100%;
border-collapse: collapse;
margin: 12px 0 16px 0;
font-size: 10pt;
}
th {
background: #1A5276;
color: #fff;
font-family: 'Segoe UI', Calibri, sans-serif;
font-weight: 600;
font-size: 10pt;
padding: 8px 10px;
text-align: left;
}
td {
padding: 6px 10px;
border-bottom: 1px solid #e0e0e0;
vertical-align: top;
}
tr:nth-child(even) td { background: #F8F9F9; }
/* ── Code blocks ── */
code {
font-family: Consolas, 'Courier New', monospace;
background: #F2F3F4;
padding: 1px 5px;
border-radius: 3px;
font-size: 10pt;
}
.code-block {
background: #F2F3F4;
border-left: 4px solid #1A5276;
padding: 10px 14px;
font-family: Consolas, 'Courier New', monospace;
font-size: 9.5pt;
line-height: 1.5;
margin: 10px 0 14px 0;
overflow-x: auto;
white-space: pre;
}
/* ── Module cards ── */
.module-box {
border: 1px solid #D5DBDB;
border-radius: 6px;
padding: 14px 16px;
margin: 12px 0;
background: #FDFEFE;
}
.module-box h3 {
margin-top: 0;
font-size: 13pt;
color: #1A5276;
border-bottom: 1px solid #EBF0F0;
padding-bottom: 5px;
margin-bottom: 8px;
}
.module-box .features {
margin-top: 6px;
}
.module-box .features li {
font-size: 10.5pt;
margin-bottom: 3px;
}
.badge {
display: inline-block;
font-family: 'Segoe UI', Calibri, sans-serif;
font-size: 8.5pt;
font-weight: 600;
padding: 2px 8px;
border-radius: 3px;
text-transform: uppercase;
letter-spacing: 0.5px;
margin-left: 8px;
vertical-align: middle;
}
.badge-route { background: #EBF5FB; color: #1A5276; }
/* ── Footer ── */
.page-footer {
position: absolute;
bottom: 15mm;
left: 25mm;
right: 25mm;
display: flex;
justify-content: space-between;
font-family: 'Segoe UI', Calibri, sans-serif;
font-size: 8.5pt;
color: #AAB7B8;
border-top: 1px solid #E5E8E8;
padding-top: 6px;
}
/* ── Print styles ── */
@media print {
body { background: #fff; }
.page {
width: auto;
margin: 0;
padding: 0;
box-shadow: none;
min-height: auto;
}
}
</style>
</head>
<body>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 1: COVER
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<div class="cover">
<div class="cover-logo">B1</div>
<h1>MITRA ERP Portal</h1>
<div class="subtitle">User &amp; Technical Documentation</div>
<div class="cover-line"></div>
<div class="subtitle" style="font-size:13pt; margin-bottom:10px;">Comprehensive Guide for All Modules</div>
<div class="date">June 2026</div>
<div class="confidential">Internal Use &mdash; Confidential</div>
</div>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 1</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 2: TABLE OF CONTENTS
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h1 style="font-size:22pt; margin-bottom:20px;">Table of Contents</h1>
<div class="toc">
<a class="toc-section"><span>1. Overview &amp; Architecture</span><span>3</span></a>
<a class="toc-sub"><span>1.1 What is MITRA ERP Portal</span><span>3</span></a>
<a class="toc-sub"><span>1.2 Technology Stack</span><span>3</span></a>
<a class="toc-sub"><span>1.3 Authentication &amp; Access Control</span><span>3</span></a>
<a class="toc-sub"><span>1.4 How to Access</span><span>3</span></a>
<a class="toc-section"><span>2. Dashboard / Home</span><span>4</span></a>
<a class="toc-section"><span>3. Inventory Module</span><span>4</span></a>
<a class="toc-sub"><span>3.1 Bill of Materials (BOM)</span><span>4</span></a>
<a class="toc-sub"><span>3.2 Item Creation &amp; Management</span><span>4</span></a>
<a class="toc-section"><span>4. Production Module</span><span>5</span></a>
<a class="toc-section"><span>5. Purchase Module</span><span>5</span></a>
<a class="toc-section"><span>6. Approvals Module</span><span>6</span></a>
<a class="toc-section"><span>7. Forms &amp; Registration</span><span>6</span></a>
<a class="toc-section"><span>8. Documents</span><span>7</span></a>
<a class="toc-section"><span>9. Projects Module</span><span>7</span></a>
<a class="toc-section"><span>10. Finance Module</span><span>7</span></a>
<a class="toc-section"><span>11. GST Reports Module</span><span>8</span></a>
<a class="toc-section"><span>12. Masters</span><span>8</span></a>
<a class="toc-section"><span>13. Reports Module</span><span>9</span></a>
<a class="toc-section"><span>14. Admin &amp; User Management</span><span>9</span></a>
<a class="toc-section"><span>15. Technical Reference</span><span>10</span></a>
<a class="toc-sub"><span>15.1 Server Setup &amp; Configuration</span><span>10</span></a>
<a class="toc-sub"><span>15.2 API Routes Reference</span><span>10</span></a>
<a class="toc-sub"><span>15.3 Project File Structure</span><span>10</span></a>
<a class="toc-sub"><span>15.4 Deployment &amp; Restart</span><span>10</span></a>
</div>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 2</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 3: OVERVIEW & ARCHITECTURE
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h2>1. Overview &amp; Architecture</h2>
<h3>1.1 What is MITRA ERP Portal</h3>
<p>
The MITRA ERP Portal is a web-based application that provides a modern, browser-accessible interface for interacting with SAP Business One operations. It enables users across departments to perform critical business functions including inventory management, production control, purchase workflows, financial reporting, GST compliance, and customer/vendor registration &mdash; all without requiring direct access to the SAP B1 client application.
</p>
<p>
The portal streamlines operations by providing role-based access, multi-level approval workflows, and real-time data retrieval from the SAP B1 database via SQL Server. It serves as a unified hub for day-to-day business operations, approvals, and reporting.
</p>
<h3>1.2 Technology Stack</h3>
<table>
<tr><th style="width:35%">Component</th><th>Technology</th></tr>
<tr><td>Backend Runtime</td><td>Node.js with Express.js framework</td></tr>
<tr><td>Frontend</td><td>Vanilla HTML, CSS, and JavaScript (no framework)</td></tr>
<tr><td>Database</td><td>Microsoft SQL Server</td></tr>
<tr><td>SAP Integration</td><td>SAP B1 Service Layer REST API + Direct SQL queries</td></tr>
<tr><td>Authentication</td><td>JSON Web Tokens (JWT) with 12-hour expiry</td></tr>
<tr><td>Hosting</td><td>Windows Server, port 5000</td></tr>
<tr><td>UI Library</td><td>Lucide Icons, Space Grotesk font</td></tr>
<tr><td>Validation</td><td>express-validator for input validation</td></tr>
</table>
<h3>1.3 Authentication &amp; Access Control</h3>
<p>
The portal uses JWT token-based authentication. Upon login, users receive a signed token valid for 12 hours. All API endpoints require a valid Bearer token in the Authorization header. The system implements role-based access control with the following roles:
</p>
<ul>
<li><strong>admin</strong> &mdash; Full access to all modules and administrative functions, can bypass approval workflows.</li>
<li><strong>sap_adder</strong> &mdash; Final approver with permission to push records to SAP B1 and manage users.</li>
<li><strong>sr_manager</strong> &mdash; Senior manager with second-level approval authority.</li>
<li><strong>manager</strong> &mdash; First-level approval authority for BOM and customer requests.</li>
<li><strong>project_approver</strong> &mdash; Dedicated role for project approval workflows.</li>
<li><strong>user</strong> &mdash; Standard user with module-based access permissions.</li>
</ul>
<p>
Module-level permissions are assigned per user. The sidebar dynamically shows only the modules each user has access to. Administrators can configure per-user module access from the Admin panel.
</p>
<h3>1.4 How to Access</h3>
<p>Open a web browser and navigate to:</p>
<div class="code-block">http://&lt;server-ip&gt;:5000</div>
<p>Users will see the login page. After authentication, they are redirected to the Home dashboard with the sidebar showing their permitted modules.</p>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 3</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 4: DASHBOARD + INVENTORY
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h2>2. Dashboard / Home</h2>
<div class="module-box">
<h3>Home Dashboard <span class="badge badge-route">Route: /</span></h3>
<p>
The Home page is the landing page of the MITRA ERP Portal, accessible to all authenticated users. It presents a card-based overview of all available modules, providing quick-access navigation to each functional area. The dashboard dynamically renders module cards based on the user's assigned permissions, ensuring each user sees only the features relevant to their role.
</p>
<p>
The dashboard also provides BOM request statistics (total, pending, approved, SAP-pushed) via the <code>/api/stats</code> endpoint, giving managers and administrators an at-a-glance view of pending workflows.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Dynamic module cards based on user role and permissions</li>
<li>BOM request statistics overview</li>
<li>Quick navigation to all portal modules</li>
<li>Responsive design with mobile bottom navigation bar</li>
</ul>
</div>
<h2>3. Inventory Module</h2>
<div class="module-box">
<h3>3.1 Bill of Materials (BOM) <span class="badge badge-route">Route: /bom</span></h3>
<p>
The BOM module enables users to create and update Bills of Materials in SAP Business One through a multi-level approval workflow. Users can compose a BOM by specifying a parent item, quantity, BOM type (Production, Sales, Assembly, Template, or Disassembly), warehouse, distribution rule, project code, and a list of component items with individual quantities, issue methods, and unit costs.
</p>
<p>
Submitted BOM requests flow through a configurable multi-level approval process (2, 3, or 4 levels) before being pushed to SAP B1 via the Service Layer API. The status flow progresses through DRAFT, PENDING, L1_APPROVED, L2_APPROVED (if 3+ levels), L3_APPROVED (if 4 levels), and finally SAP_PUSHED. Admin users can bypass the approval chain and push BOMs directly to SAP.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Create new BOMs and update existing BOMs in SAP B1</li>
<li>Configurable 2/3/4-level approval workflow (Manager, Senior Manager, SAP Adder)</li>
<li>Component-level detail: item code, quantity, issue method, warehouse, unit cost</li>
<li>Admin direct-push capability for bypassing approvals</li>
<li>Full audit trail with approval log entries</li>
</ul>
</div>
<div class="module-box">
<h3>3.2 Item Creation &amp; Management <span class="badge badge-route">Route: /items</span></h3>
<p>
The Items module provides functionality to create new items in SAP B1 and view existing items. The "Create Item" view (<code>/items</code>) presents a form for entering item master data, while the "View Items" view (<code>/items?list=1</code>) lists all items with search and filter capabilities. Item creation requests go through an approval workflow managed by the Item Approval system.
</p>
<p>
The module integrates with SAP B1 lookups for item groups, warehouses, tax codes, GL accounts, and other master data to ensure consistency with the SAP system.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Create new item master records with full SAP field mapping</li>
<li>View and search existing items</li>
<li>Item approval workflow before SAP push</li>
<li>Auto-populated dropdowns from SAP master data (groups, warehouses, tax codes)</li>
</ul>
</div>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 4</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 5: PRODUCTION + PURCHASE
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h2>4. Production Module</h2>
<div class="module-box">
<h3>Production Order Management <span class="badge badge-route">Routes: /production, /issue-production, /receipt-production, /close-production</span></h3>
<p>
The Production module covers the full lifecycle of production orders in SAP Business One. It is divided into four sub-modules, each handling a specific stage of the production process. Users can create new production orders, issue raw materials to production, receive finished goods from production, and close completed production orders.
</p>
<h4>Sub-modules:</h4>
<ul class="features">
<li><strong>Create Order</strong> (<code>/production</code>) &mdash; Create new production orders by selecting the product item, specifying quantity, planned dates, warehouse, and associated BOM. The system pulls BOM component details from SAP.</li>
<li><strong>Issue for Production</strong> (<code>/issue-production</code>) &mdash; Issue raw materials and components against an existing production order. Records material consumption from the warehouse to the production floor.</li>
<li><strong>Receipt from Production</strong> (<code>/receipt-production</code>) &mdash; Receive finished goods back into inventory upon production completion. Updates stock quantities and records production output.</li>
<li><strong>Close Production</strong> (<code>/close-production</code>) &mdash; Close a production order after all materials have been issued and finished goods received. Finalizes the production cycle and locks the order from further transactions.</li>
</ul>
</div>
<h2>5. Purchase Module</h2>
<div class="module-box">
<h3>Purchase Workflow Management <span class="badge badge-route">Routes: /purchase-request, /purchase-quotation, /purchase-order, /grpo</span></h3>
<p>
The Purchase module provides end-to-end procurement management, covering the complete purchase cycle from initial request through to goods receipt. Each stage is handled by a dedicated sub-module with its own interface and workflow.
</p>
<h4>Sub-modules:</h4>
<ul class="features">
<li><strong>Purchase Request</strong> (<code>/purchase-request</code>) &mdash; Initiate internal purchase requests specifying required items, quantities, preferred vendors, and required delivery dates. Serves as the starting point of the procurement workflow.</li>
<li><strong>Purchase Quotation</strong> (<code>/purchase-quotation</code>) &mdash; Manage vendor quotations received against purchase requests. Compare pricing, terms, and delivery schedules from multiple vendors to select the best offer.</li>
<li><strong>Purchase Order</strong> (<code>/purchase-order</code>) &mdash; Create and manage purchase orders sent to vendors. Generated from approved quotations or created directly, these orders formalize the commitment to purchase goods or services.</li>
<li><strong>Goods Receipt PO (GRPO)</strong> (<code>/grpo</code>) &mdash; Record the receipt of goods against purchase orders. Verifies delivered quantities, updates inventory stock, and triggers accounts payable entries in SAP B1. Supports partial receipts and multi-line document processing.</li>
</ul>
</div>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 5</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 6: APPROVALS + FORMS
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h2>6. Approvals Module</h2>
<div class="module-box">
<h3>6.1 External Approval (Portal Approvals) <span class="badge badge-route">Route: /approvals</span></h3>
<p>
The External Approval module manages the portal's internal approval workflows for BOM requests, customer registrations, and item creation requests. Approvers see a unified queue of pending requests relevant to their role level. The multi-level approval system routes requests through the appropriate chain: Manager (L1), Senior Manager (L2), and SAP Adder (L3/Final), with configurable 2, 3, or 4-level workflows.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Unified approval queue filtered by user's role and approval level</li>
<li>Approve or reject with comments and audit trail</li>
<li>View full request details including components and history</li>
<li>Status tracking: PENDING, L1_APPROVED, L2_APPROVED, SAP_PUSHED, REJECTED</li>
</ul>
</div>
<div class="module-box">
<h3>6.2 SAP Approval <span class="badge badge-route">Route: /sap-approvals</span></h3>
<p>
The SAP Approval module provides an interface for managing SAP Business One's native approval procedures. It surfaces approval requests generated by SAP B1's built-in approval workflow engine, allowing authorized users to review and act on pending SAP documents (such as purchase orders, invoices, and other transactional documents) directly from the web portal without opening the SAP client.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>View pending SAP B1 native approval requests</li>
<li>Approve or reject SAP documents from the web portal</li>
<li>Integration with SAP B1's approval procedure engine</li>
</ul>
</div>
<h2>7. Forms &amp; Registration</h2>
<div class="module-box">
<h3>7.1 Customer Registration <span class="badge badge-route">Route: /register</span></h3>
<p>
The Customer Registration form allows users to submit new customer (Business Partner) records for creation in SAP B1. The form captures comprehensive business partner data including company details, contact information, billing and shipping addresses (with support for multiple addresses), currency preferences, GST/PAN details, MSME information, and file attachments. Submitted registrations go through a verification and approval workflow before being pushed to SAP as a new customer master record.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Multi-step registration form with validation</li>
<li>Two-stage approval: Verification (Manager) then SAP Push (SAP Adder)</li>
<li>Admin direct-approve capability</li>
<li>Multiple billing and shipping address support</li>
<li>GST, PAN, and MSME detail capture</li>
<li>Automatic SAP card code generation with configurable prefix</li>
</ul>
</div>
<div class="module-box">
<h3>7.2 Vendor Registration <span class="badge badge-route">Route: /vendor-register</span></h3>
<p>
The Vendor Registration form mirrors the customer registration process but is tailored for vendor (supplier) business partners. It captures vendor-specific information, AP account mappings, and vendor BP group classifications. Registered vendors follow a similar approval workflow before being created in the SAP B1 system as vendor-type business partners.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Vendor-specific form with AP account configuration</li>
<li>Vendor BP group selection from SAP master data</li>
<li>Approval workflow with verification and final push to SAP</li>
</ul>
</div>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 6</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 7: DOCUMENTS + PROJECTS + FINANCE
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h2>8. Documents</h2>
<div class="module-box">
<h3>Document Management <span class="badge badge-route">Route: /documents</span></h3>
<p>
The Documents module provides a centralized document management interface for uploading, organizing, and retrieving business documents associated with SAP transactions. Users can upload files and attachments, which are stored in the server's <code>/uploads</code> directory and linked to relevant business records. This module serves as a repository for supporting documentation such as purchase orders, invoices, delivery notes, and other transactional evidence.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Upload and manage business documents</li>
<li>File storage in dedicated uploads directory</li>
<li>Document linking to business transactions</li>
</ul>
</div>
<h2>9. Projects Module</h2>
<div class="module-box">
<h3>Project Management <span class="badge badge-route">Routes: /project-form, /project-approvals</span></h3>
<p>
The Projects module enables users to create, view, and manage project records with an integrated approval workflow. The "New Project" view (<code>/project-form?new=1</code>) provides a form for defining new project details, while the "View Projects" view (<code>/project-form?list=1</code>) displays all existing projects with filtering and search. The "Project Approvals" view (<code>/project-approvals</code>) presents a queue for project approvers to review and approve pending project submissions.
</p>
<p>
Project data is managed through a dedicated project store with its own database tables, supporting full CRUD operations and approval state management.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Create new projects with detailed project information</li>
<li>View and filter existing projects</li>
<li>Dedicated project approval workflow with <code>project_approver</code> role</li>
<li>Project-specific data storage and management</li>
</ul>
</div>
<h2>10. Finance Module</h2>
<div class="module-box">
<h3>Financial Reporting &amp; Analysis <span class="badge badge-route">Routes: /costing-pl, /costing-comparison, /cost-sheet, /balance-sheet, /cash-flow, /salary</span></h3>
<p>
The Finance module provides a comprehensive suite of financial reporting tools that pull data directly from the SAP B1 database. It enables management to view and analyze key financial statements and reports without exporting data from the SAP client.
</p>
<h4>Sub-modules:</h4>
<ul class="features">
<li><strong>Monthly Accounts (P&amp;L)</strong> (<code>/costing-pl</code>) &mdash; View monthly profit and loss statements with revenue, cost of goods sold, operating expenses, and net profit calculations. Data is sourced from SAP GL accounts with costing store snapshots for period comparisons.</li>
<li><strong>P&amp;L Comparison</strong> (<code>/costing-comparison</code>) &mdash; Compare profit and loss performance across multiple periods. Enables month-over-month and year-over-year variance analysis for financial planning.</li>
<li><strong>Cost Sheet</strong> (<code>/cost-sheet</code>) &mdash; Detailed cost breakdown analysis showing direct costs, overhead allocations, and cost center-wise expenditure summaries.</li>
<li><strong>Balance Sheet</strong> (<code>/balance-sheet</code>) &mdash; View the company's balance sheet with assets, liabilities, and equity sections. Pulls account balances from SAP GL accounts organized by the chart of accounts hierarchy.</li>
<li><strong>Cash Flow</strong> (<code>/cash-flow</code>) &mdash; Cash flow statement showing operating, investing, and financing activities. Tracks cash inflows and outflows for liquidity management.</li>
<li><strong>Salary</strong> (<code>/salary</code>) &mdash; Salary management and reporting module for processing and viewing employee salary data. Managed through a dedicated salary store with its own data tables.</li>
</ul>
</div>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 7</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 8: GST REPORTS + MASTERS
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h2>11. GST Reports Module</h2>
<div class="module-box">
<h3>11.1 GSTR-1 (Sales Register) <span class="badge badge-route">Route: /gstr1</span></h3>
<p>
The GSTR-1 module generates the outward supply register required for GST filing in India. It pulls sales invoice data from the SAP B1 database and formats it according to the GSTR-1 filing requirements. Users can filter by date range and export the data for upload to the GST portal. The report covers B2B invoices, B2C invoices, credit/debit notes, and other categories as required by the GSTR-1 format.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Automated GSTR-1 report generation from SAP sales data</li>
<li>Date range filtering for specific filing periods</li>
<li>Data formatted for GST portal upload compatibility</li>
<li>Export functionality for filing submissions</li>
</ul>
</div>
<div class="module-box">
<h3>11.2 GSTR-2 Purchase Register <span class="badge badge-route">Route: /gstr2</span></h3>
<p>
The GSTR-2 module generates the inward supply (purchase) register for GST compliance. It extracts purchase invoice data from SAP B1 and presents it in the GSTR-2 format. The module includes TCS (Tax Collected at Source) upload functionality, allowing users to upload TCS data files and reconcile them against purchase records for accurate GST reporting.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Purchase register generation from SAP purchase invoices</li>
<li>TCS data upload and reconciliation</li>
<li>Supplier-wise purchase summary</li>
<li>Export-ready format for GST portal submission</li>
</ul>
</div>
<div class="module-box">
<h3>11.3 ITC-04 Job Work Register <span class="badge badge-route">Route: /itc04</span></h3>
<p>
The ITC-04 module generates the job work register required under GST for tracking goods sent to and received from job workers. It pulls data from SAP B1 related to job work transactions and formats the report according to the ITC-04 filing requirements. This is essential for manufacturers who outsource production processes to third-party job workers.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Job work goods sent and received tracking</li>
<li>ITC-04 formatted report generation</li>
<li>Job worker-wise transaction summary</li>
<li>Compliance reporting for GST authorities</li>
</ul>
</div>
<h2>12. Masters</h2>
<div class="module-box">
<h3>Business Master <span class="badge badge-route">Route: /business-master</span></h3>
<p>
The Business Master module provides an interface for viewing and managing business partner master data from SAP B1. It allows users to search, view, and manage customer and vendor master records, including contact details, address information, financial terms, and classification data. The module serves as a quick-reference tool for business partner information without requiring direct SAP client access.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Search and browse business partner master records</li>
<li>View detailed partner information (contacts, addresses, terms)</li>
<li>Customer and vendor classification management</li>
<li>Integration with SAP B1 business partner master data</li>
</ul>
</div>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 8</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 9: REPORTS + ADMIN
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h2>13. Reports Module</h2>
<div class="module-box">
<h3>13.1 Reports Dashboard <span class="badge badge-route">Route: /reports</span></h3>
<p>
The Reports module provides a centralized reporting dashboard for generating and viewing various business reports from the SAP B1 database. It offers a collection of predefined report templates covering sales, purchases, inventory, and other operational metrics. Users can specify date ranges and filters to generate reports tailored to their analytical needs.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Pre-built report templates for common business queries</li>
<li>Date range and parameter-based filtering</li>
<li>Data sourced directly from SAP B1 SQL database</li>
<li>Export capabilities for further analysis</li>
</ul>
</div>
<div class="module-box">
<h3>13.2 General Ledger Report <span class="badge badge-route">Route: /general-ledger</span></h3>
<p>
The General Ledger Report provides detailed GL account transaction listings from the SAP B1 database. Users can view individual account activity with debits, credits, and running balances for any specified period. The report supports filtering by account code, date range, and other criteria to drill down into specific financial transactions recorded in the general ledger.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Account-wise transaction detail with debit/credit columns</li>
<li>Date range filtering for period-specific reporting</li>
<li>Running balance calculation</li>
<li>Direct SQL queries against SAP B1 GL tables (JDT1/OJDT)</li>
</ul>
</div>
<h2>14. Admin &amp; User Management</h2>
<div class="module-box">
<h3>Administration Panel <span class="badge badge-route">Route: /admin</span></h3>
<p>
The Admin module is the central administration panel for managing portal users, roles, and module access permissions. Accessible only to users with <code>admin</code> or <code>sap_adder</code> roles, it provides a complete user management interface for creating, editing, and deactivating user accounts. Administrators can assign roles, configure per-user module permissions, set approval departments, and link portal users to SAP user IDs.
</p>
<h4>Key Features:</h4>
<ul class="features">
<li>Create new user accounts with username, password, role, and module permissions</li>
<li>Edit existing users: update role, modules, full name, email, and active status</li>
<li>Delete user accounts (with self-deletion protection)</li>
<li>Role assignment: admin, sap_adder, sr_manager, manager, project_approver, user</li>
<li>Granular module-level access control (bom, items, production, purchase, approvals, sap-approvals, vendors, customers, documents, projects, costing, salary, gstr1, gstr2, itc04, business-master, reports, general-ledger)</li>
<li>Approval department assignment for workflow routing</li>
<li>User activity tracking with last login timestamps</li>
</ul>
</div>
<div class="module-box">
<h3>User Profile <span class="badge badge-route">Route: /profile</span></h3>
<p>
Each user has a personal profile page where they can update their display name, email address, and password. The profile page shows current role and module assignments (read-only) and provides a secure password change mechanism that requires the current password for verification before allowing updates.
</p>
</div>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 9</span>
</div>
</div>
<!-- ═══════════════════════════════════════════════════════════════════
PAGE 10: TECHNICAL REFERENCE
═══════════════════════════════════════════════════════════════════ -->
<div class="page">
<h2>15. Technical Reference</h2>
<h3>15.1 Server Setup &amp; Configuration</h3>
<p>The application is a Node.js Express server defined in <code>server.js</code>. It listens on port 5000 (configurable via the <code>PORT</code> environment variable) and binds to <code>0.0.0.0</code> for network-wide access. Configuration is managed through environment variables loaded via <code>dotenv</code>.</p>
<table>
<tr><th>Variable</th><th>Description</th></tr>
<tr><td><code>PORT</code></td><td>Server port (default: 5000)</td></tr>
<tr><td><code>JWT_SECRET</code></td><td>Secret key for JWT token signing</td></tr>
<tr><td><code>SQL_HOST</code></td><td>SQL Server hostname/IP</td></tr>
<tr><td><code>SQL_PORT</code></td><td>SQL Server port</td></tr>
<tr><td><code>SQL_USER</code></td><td>SQL Server username</td></tr>
<tr><td><code>SQL_PASSWORD</code></td><td>SQL Server password</td></tr>
<tr><td><code>SQL_DATABASE</code></td><td>SAP B1 database name</td></tr>
<tr><td><code>BOM_APPROVAL_LEVELS</code></td><td>Number of BOM approval levels (2, 3, or 4)</td></tr>
<tr><td><code>CUST_APPROVAL_LEVELS</code></td><td>Customer approval levels (default: 2)</td></tr>
</table>
<h3>15.2 API Routes Reference</h3>
<table>
<tr><th>Route Prefix</th><th>Description</th><th>Auth</th></tr>
<tr><td><code>/api/auth</code></td><td>Login, profile, token verification</td><td>Public / Token</td></tr>
<tr><td><code>/api/users</code></td><td>User CRUD (admin)</td><td>sap_adder+</td></tr>
<tr><td><code>/api/bom-requests</code></td><td>BOM create/update/approve/reject</td><td>Token</td></tr>
<tr><td><code>/api/customers</code></td><td>Customer registration &amp; approval</td><td>Public / Token</td></tr>
<tr><td><code>/api/vendors</code></td><td>Vendor registration &amp; management</td><td>Token</td></tr>
<tr><td><code>/api/sap</code></td><td>SAP lookups (items, warehouses, GL, tax, etc.) &amp; GRPO</td><td>Token</td></tr>
<tr><td><code>/api/projects</code></td><td>Project CRUD &amp; approvals</td><td>Token</td></tr>
<tr><td><code>/api/item-approvals</code></td><td>Item creation approval workflow</td><td>Token</td></tr>
<tr><td><code>/api/costing</code></td><td>P&amp;L, monthly accounts, cost analysis</td><td>Token</td></tr>
<tr><td><code>/api/balance-sheet</code></td><td>Balance sheet data</td><td>Token</td></tr>
<tr><td><code>/api/cash-flow</code></td><td>Cash flow statement data</td><td>Token</td></tr>
<tr><td><code>/api/costsheet</code></td><td>Cost sheet report data</td><td>Token</td></tr>
<tr><td><code>/api/salary</code></td><td>Salary data management</td><td>Token</td></tr>
<tr><td><code>/api/gstr1</code></td><td>GSTR-1 outward supply report</td><td>Token</td></tr>
<tr><td><code>/api/gstr2</code></td><td>GSTR-2 purchase register &amp; TCS</td><td>Token</td></tr>
<tr><td><code>/api/itc04</code></td><td>ITC-04 job work report</td><td>Token</td></tr>
<tr><td><code>/api/reports</code></td><td>General business reports</td><td>Token</td></tr>
<tr><td><code>/api/general-ledger</code></td><td>GL account transaction report</td><td>Token</td></tr>
<tr><td><code>/api/business-master</code></td><td>Business partner master data</td><td>Token</td></tr>
<tr><td><code>/api/chat</code></td><td>AI chatbot assistant</td><td>Token</td></tr>
<tr><td><code>/api/config</code></td><td>Portal configuration (approval levels)</td><td>Public</td></tr>
<tr><td><code>/api/health</code></td><td>Health check endpoint</td><td>Public</td></tr>
<tr><td><code>/api/stats</code></td><td>BOM request statistics</td><td>Token</td></tr>
</table>
<h3>15.3 Project File Structure</h3>
<div class="code-block">backend/
server.js Entry point &mdash; Express app, middleware, inline routes
.env Environment variables (SQL, JWT, ports)
routes/ Modular route handlers
sap.js SAP lookups &amp; GRPO
gstr1.js, gstr2.js, itc04.js GST report routes
projects.js Project CRUD &amp; approvals
costing.js P&amp;L and costing routes
balanceSheet.js Balance sheet route
cashFlow.js Cash flow route
salary.js Salary route
costsheet.js Cost sheet route
reports.js General reports
generalLedger.js GL report
vendors.js Vendor management
businessMaster.js Business master data
itemApproval.js Item approval workflow
chatbot.js AI chatbot
services/ Data access &amp; business logic
hanaStore.js Customer data store (SQL)
hanaUsers.js User authentication &amp; management
sapServiceLayer.js SAP B1 Service Layer API client
bomRequestStore.js BOM request persistence
hanaItemStore.js Item data store
hanaVendorStore.js Vendor data store
projectStore.js Project data store
costingStore.js Costing &amp; P&amp;L data store
salaryStore.js Salary data store
cashFlowStore.js Cash flow data store
companyConfig.js Multi-company configuration
sqlPool.js SQL connection pool
middleware/
auth.js JWT verification middleware
public/ Static frontend files
index.html Home/dashboard page
sidebar.js Shared sidebar navigation
*.html Module-specific pages
docs/ Documentation files</div>
<h3>15.4 Deployment &amp; Restart</h3>
<p>To restart the portal server:</p>
<div class="code-block">1. Stop the running process on port 5000
(e.g., taskkill /F /PID &lt;process-id&gt; or stop the service)
2. Navigate to the project directory:
cd d:\Project\backend
3. Start the server:
node server.js</div>
<p>The server will display connection status in the console. Wait for the "Database ready" message to confirm all services are initialized and available.</p>
<div class="page-footer">
<span>MITRA ERP Portal &mdash; Documentation</span>
<span>Page 10</span>
</div>
</div>
</body>
</html>