lokeshloki143 commited on
Commit
864ab9e
·
verified ·
1 Parent(s): 48794a2

Update templates/combined_summary.html

Browse files
Files changed (1) hide show
  1. templates/combined_summary.html +179 -18
templates/combined_summary.html CHANGED
@@ -6,8 +6,9 @@
6
  <meta http-equiv="x-ua-compatible" content="ie=edge">
7
  <title>Order Summary and Invoice</title>
8
  <script src="https://cdn.tailwindcss.com"></script>
 
9
  <style>
10
- /* Existing styles remain unchanged */
11
  @keyframes fadeIn {
12
  from { opacity: 0; transform: translateY(10px); }
13
  to { opacity: 1; transform: translateY(0); }
@@ -462,7 +463,7 @@
462
  border-radius: 8px;
463
  display: inline-block;
464
  }
465
- /* New Invoice Section Styles */
466
  .invoice-section {
467
  background: #FFFFFF;
468
  border-radius: 12px;
@@ -472,6 +473,14 @@
472
  max-width: 800px;
473
  margin-left: auto;
474
  margin-right: auto;
 
 
 
 
 
 
 
 
475
  }
476
  .invoice-header {
477
  text-align: center;
@@ -531,6 +540,20 @@
531
  .invoice-footer p {
532
  margin: 4px 0;
533
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  /* Responsive adjustments */
535
  @media (max-width: 768px) {
536
  .custom-class {
@@ -571,6 +594,10 @@
571
  .invoice-section {
572
  padding: 16px;
573
  }
 
 
 
 
574
  }
575
  @media (max-width: 360px) {
576
  .custom-class {
@@ -816,7 +843,7 @@
816
  />
817
  <h3 class="order-item-name" id="order-name-{{ loop.index }}">{{ item.name | escape }}</h3>
818
  </div>
819
- <p id="order-price-{{ loop.index }}" class="text-gray-600 mb-2 price-badge">${{ "%.2f"|format(item.price | default(0)) }}</p>
820
 
821
  {% if item.category != 'Soft Drink' %}
822
  <button
@@ -909,8 +936,14 @@
909
  <div class="no-data">No previous orders found.</div>
910
  {% endif %}
911
 
 
 
 
 
 
 
912
  <!-- Invoice Section -->
913
- <div class="invoice-section">
914
  <div class="invoice-header">
915
  <h1>Tax Invoice</h1>
916
  <p>ORIGINAL FOR RECIPIENT</p>
@@ -926,7 +959,9 @@
926
  <div>
927
  <p><span>Invoice No:</span> {{ order.id | default('247JD92F00043965') }}</p>
928
  <p><span>Invoice Date:</span> {{ order.created_date | default('2024-12-12') }}</p>
929
- <p><span>Customer Name:</span> {{ order.customer_name | default('SATHVIK GANTA') }}</p>
 
 
930
  <p><span>Delivery Address:</span> {{ order.delivery_address | default('Plot no -80, Road no-4, Sharadha Nagar, Vanasthalipuram, 500070') }}</p>
931
  <p><span>Place of Supply:</span> {{ order.place_of_supply | default('Telangana(36)') }}</p>
932
  </div>
@@ -949,26 +984,26 @@
949
  {% for item in order_items %}
950
  <tr>
951
  <td>{{ item.name | escape }}</td>
952
- <td>{{ "%.2f"|format(item.price | default(0)) }}</td>
953
- <td>{{ "%.2f"|format(item.discount | default(0)) }}</td>
954
- <td>{{ "%.2f"|format((item.price | default(0)) - (item.discount | default(0))) }}</td>
955
  <td>{{ order.cgst_rate | default('2.5%') }}</td>
956
- <td>{{ "%.3f"|format(((item.price | default(0)) - (item.discount | default(0))) * (order.cgst_rate_float | default(0.025))) }}</td>
957
  <td>{{ order.sgst_rate | default('2.5%') }}</td>
958
- <td>{{ "%.3f"|format(((item.price | default(0)) - (item.discount | default(0))) * (order.sgst_rate_float | default(0.025))) }}</td>
959
- <td>{{ "%.2f"|format(((item.price | default(0)) - (item.discount | default(0))) * (1 + (order.cgst_rate_float | default(0.025)) + (order.sgst_rate_float | default(0.025)))) }}</td>
960
  </tr>
961
  {% endfor %}
962
  <tr class="total-row">
963
  <td>Total</td>
964
- <td>{{ "%.2f"|format(total_gross_value) }}</td>
965
- <td>{{ "%.2f"|format(total_discount) }}</td>
966
- <td>{{ "%.2f"|format(total_net_value) }}</td>
967
  <td></td>
968
- <td>{{ "%.3f"|format(total_cgst) }}</td>
969
  <td></td>
970
- <td>{{ "%.3f"|format(total_sgst) }}</td>
971
- <td>{{ "%.2f"|format(total_amount) }}</td>
972
  </tr>
973
  </tbody>
974
  </table>
@@ -985,7 +1020,7 @@
985
  </div>
986
 
987
  <script>
988
- // Existing JavaScript remains unchanged
989
  function debounce(func, wait) {
990
  let timeout;
991
  return function executedFunction(...args) {
@@ -1186,6 +1221,132 @@
1186
  updateTimer();
1187
  }
1188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1189
  document.addEventListener('DOMContentLoaded', () => {
1190
  try {
1191
  const progressBar = document.getElementById('progressBar');
 
6
  <meta http-equiv="x-ua-compatible" content="ie=edge">
7
  <title>Order Summary and Invoice</title>
8
  <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
10
  <style>
11
+ /* Existing styles */
12
  @keyframes fadeIn {
13
  from { opacity: 0; transform: translateY(10px); }
14
  to { opacity: 1; transform: translateY(0); }
 
463
  border-radius: 8px;
464
  display: inline-block;
465
  }
466
+ /* Invoice Section Styles */
467
  .invoice-section {
468
  background: #FFFFFF;
469
  border-radius: 12px;
 
473
  max-width: 800px;
474
  margin-left: auto;
475
  margin-right: auto;
476
+ transition: max-height 0.5s ease-in-out, opacity 0.3s ease-in-out;
477
+ }
478
+ .invoice-section.hidden {
479
+ max-height: 0;
480
+ opacity: 0;
481
+ overflow: hidden;
482
+ padding: 0;
483
+ margin: 0;
484
  }
485
  .invoice-header {
486
  text-align: center;
 
540
  .invoice-footer p {
541
  margin: 4px 0;
542
  }
543
+ .invoice-toggle-btn, .invoice-download-btn {
544
+ display: inline-block;
545
+ padding: 10px 20px;
546
+ background-color: #FFB347;
547
+ color: #FFFFFF;
548
+ border-radius: 8px;
549
+ font-weight: 600;
550
+ cursor: pointer;
551
+ margin: 10px;
552
+ transition: background-color 0.3s ease;
553
+ }
554
+ .invoice-toggle-btn:hover, .invoice-download-btn:hover {
555
+ background-color: #FF9E2C;
556
+ }
557
  /* Responsive adjustments */
558
  @media (max-width: 768px) {
559
  .custom-class {
 
594
  .invoice-section {
595
  padding: 16px;
596
  }
597
+ .invoice-toggle-btn, .invoice-download-btn {
598
+ padding: 8px 16px;
599
+ font-size: 0.875rem;
600
+ }
601
  }
602
  @media (max-width: 360px) {
603
  .custom-class {
 
843
  />
844
  <h3 class="order-item-name" id="order-name-{{ loop.index }}">{{ item.name | escape }}</h3>
845
  </div>
846
+ <p id="order-price-{{ loop.index }}" class="text-gray-600 mb-2 price-badge">₹{{ "%.2f"|format(item.price | default(0)) }}</p>
847
 
848
  {% if item.category != 'Soft Drink' %}
849
  <button
 
936
  <div class="no-data">No previous orders found.</div>
937
  {% endif %}
938
 
939
+ <!-- Invoice Toggle and Download Buttons -->
940
+ <div class="text-center mb-6">
941
+ <button id="toggleInvoiceBtn" class="invoice-toggle-btn" onclick="toggleInvoice()">View Invoice</button>
942
+ <button id="downloadInvoiceBtn" class="invoice-download-btn" onclick="downloadInvoice()">Download Invoice as PDF</button>
943
+ </div>
944
+
945
  <!-- Invoice Section -->
946
+ <div id="invoiceSection" class="invoice-section hidden">
947
  <div class="invoice-header">
948
  <h1>Tax Invoice</h1>
949
  <p>ORIGINAL FOR RECIPIENT</p>
 
959
  <div>
960
  <p><span>Invoice No:</span> {{ order.id | default('247JD92F00043965') }}</p>
961
  <p><span>Invoice Date:</span> {{ order.created_date | default('2024-12-12') }}</p>
962
+ <p><span>Customer Name:</span> {{ customer.name | default('SATHVIK GANTA') }}</p>
963
+ <p><span>Customer Email:</span> {{ customer.email | default('[email protected]') }}</p>
964
+ <p><span>Customer Phone:</span> {{ customer.phone | default('9876543210') }}</p>
965
  <p><span>Delivery Address:</span> {{ order.delivery_address | default('Plot no -80, Road no-4, Sharadha Nagar, Vanasthalipuram, 500070') }}</p>
966
  <p><span>Place of Supply:</span> {{ order.place_of_supply | default('Telangana(36)') }}</p>
967
  </div>
 
984
  {% for item in order_items %}
985
  <tr>
986
  <td>{{ item.name | escape }}</td>
987
+ <td>₹{{ "%.2f"|format(item.price | default(0)) }}</td>
988
+ <td>₹{{ "%.2f"|format(item.discount | default(0)) }}</td>
989
+ <td>₹{{ "%.2f"|format((item.price | default(0)) - (item.discount | default(0))) }}</td>
990
  <td>{{ order.cgst_rate | default('2.5%') }}</td>
991
+ <td>₹{{ "%.3f"|format(((item.price | default(0)) - (item.discount | default(0))) * (order.cgst_rate_float | default(0.025))) }}</td>
992
  <td>{{ order.sgst_rate | default('2.5%') }}</td>
993
+ <td>₹{{ "%.3f"|format(((item.price | default(0)) - (item.discount | default(0))) * (order.sgst_rate_float | default(0.025))) }}</td>
994
+ <td>₹{{ "%.2f"|format(((item.price | default(0)) - (item.discount | default(0))) * (1 + (order.cgst_rate_float | default(0.025)) + (order.sgst_rate_float | default(0.025)))) }}</td>
995
  </tr>
996
  {% endfor %}
997
  <tr class="total-row">
998
  <td>Total</td>
999
+ <td>₹{{ "%.2f"|format(total_gross_value) }}</td>
1000
+ <td>₹{{ "%.2f"|format(total_discount) }}</td>
1001
+ <td>₹{{ "%.2f"|format(total_net_value) }}</td>
1002
  <td></td>
1003
+ <td>₹{{ "%.3f"|format(total_cgst) }}</td>
1004
  <td></td>
1005
+ <td>₹{{ "%.3f"|format(total_sgst) }}</td>
1006
+ <td>₹{{ "%.2f"|format(total_amount) }}</td>
1007
  </tr>
1008
  </tbody>
1009
  </table>
 
1020
  </div>
1021
 
1022
  <script>
1023
+ // Existing JavaScript
1024
  function debounce(func, wait) {
1025
  let timeout;
1026
  return function executedFunction(...args) {
 
1221
  updateTimer();
1222
  }
1223
 
1224
+ // New Invoice JavaScript
1225
+ function toggleInvoice() {
1226
+ const invoiceSection = document.getElementById('invoiceSection');
1227
+ const toggleBtn = document.getElementById('toggleInvoiceBtn');
1228
+ const isHidden = invoiceSection.classList.contains('hidden');
1229
+ invoiceSection.classList.toggle('hidden');
1230
+ toggleBtn.textContent = isHidden ? 'Hide Invoice' : 'View Invoice';
1231
+ }
1232
+
1233
+ function downloadInvoice() {
1234
+ const { jsPDF } = window.jspdf;
1235
+ const doc = new jsPDF();
1236
+ const invoice = document.getElementById('invoiceSection');
1237
+ let y = 20;
1238
+
1239
+ // Header
1240
+ doc.setFontSize(16);
1241
+ doc.text('Tax Invoice', 105, y, { align: 'center' });
1242
+ y += 10;
1243
+ doc.setFontSize(10);
1244
+ doc.text('ORIGINAL FOR RECIPIENT', 105, y, { align: 'center' });
1245
+ y += 20;
1246
+
1247
+ // Restaurant and Customer Details
1248
+ doc.setFontSize(10);
1249
+ doc.text('Legal Entity Name: {{ restaurant.legal_name | default('DOUBLE TREE BY KVP HOSPITALITY LLP') }}', 10, y);
1250
+ y += 10;
1251
+ doc.text('Restaurant Name: {{ restaurant.name | default('Pista House') }}', 10, y);
1252
+ y += 10;
1253
+ doc.text('Restaurant Address: {{ restaurant.address | default('52 To 57, 69 & 70, 5-5-162 & 5-5-163, 5-5-164 & 5-5-165, Plot 1, Vanasthali Hills, Saheb Nagar, LB Nagar Circle 4, Vanasthalipuram, Hyderabad') }}', 10, y, { maxWidth: 90 });
1254
+ y += 20;
1255
+ doc.text('GSTIN: {{ restaurant.gstin | default('36AATFD1209K1Z9') }}', 10, y);
1256
+ y += 10;
1257
+ doc.text('FSSAI: {{ restaurant.fssai | default('13622012000022') }}', 10, y);
1258
+ y -= 70;
1259
+
1260
+ doc.text('Invoice No: {{ order.id | default('247JD92F00043965') }}', 110, y);
1261
+ y += 10;
1262
+ doc.text('Invoice Date: {{ order.created_date | default('2024-12-12') }}', 110, y);
1263
+ y += 10;
1264
+ doc.text('Customer Name: {{ customer.name | default('SATHVIK GANTA') }}', 110, y);
1265
+ y += 10;
1266
+ doc.text('Customer Email: {{ customer.email | default('[email protected]') }}', 110, y);
1267
+ y += 10;
1268
+ doc.text('Customer Phone: {{ customer.phone | default('9876543210') }}', 110, y);
1269
+ y += 10;
1270
+ doc.text('Delivery Address: {{ order.delivery_address | default('Plot no -80, Road no-4, Sharadha Nagar, Vanasthalipuram, 500070') }}', 110, y, { maxWidth: 90 });
1271
+ y += 20;
1272
+ doc.text('Place of Supply: {{ order.place_of_supply | default('Telangana(36)') }}', 110, y);
1273
+ y += 20;
1274
+
1275
+ // Table Header
1276
+ doc.setFontSize(10);
1277
+ const headers = ['Particulars', 'Gross Value', 'Discount', 'Net Value', 'CGST (Rate)', 'CGST (INR)', 'SGST (Rate)', 'SGST (INR)', 'Total'];
1278
+ const colWidths = [50, 20, 20, 20, 20, 20, 20, 20, 20];
1279
+ let x = 10;
1280
+ headers.forEach((header, i) => {
1281
+ doc.text(header, x, y, { maxWidth: colWidths[i] });
1282
+ x += colWidths[i];
1283
+ });
1284
+ y += 10;
1285
+
1286
+ // Table Rows
1287
+ {% for item in order_items %}
1288
+ x = 10;
1289
+ doc.text('{{ item.name | escape }}', x, y, { maxWidth: colWidths[0] });
1290
+ x += colWidths[0];
1291
+ doc.text('₹{{ "%.2f"|format(item.price | default(0)) }}', x, y);
1292
+ x += colWidths[1];
1293
+ doc.text('₹{{ "%.2f"|format(item.discount | default(0)) }}', x, y);
1294
+ x += colWidths[2];
1295
+ doc.text('₹{{ "%.2f"|format((item.price | default(0)) - (item.discount | default(0))) }}', x, y);
1296
+ x += colWidths[3];
1297
+ doc.text('{{ order.cgst_rate | default('2.5%') }}', x, y);
1298
+ x += colWidths[4];
1299
+ doc.text('₹{{ "%.3f"|format(((item.price | default(0)) - (item.discount | default(0))) * (order.cgst_rate_float | default(0.025))) }}', x, y);
1300
+ x += colWidths[5];
1301
+ doc.text('{{ order.sgst_rate | default('2.5%') }}', x, y);
1302
+ x += colWidths[6];
1303
+ doc.text('₹{{ "%.3f"|format(((item.price | default(0)) - (item.discount | default(0))) * (order.sgst_rate_float | default(0.025))) }}', x, y);
1304
+ x += colWidths[7];
1305
+ doc.text('₹{{ "%.2f"|format(((item.price | default(0)) - (item.discount | default(0))) * (1 + (order.cgst_rate_float | default(0.025)) + (order.sgst_rate_float | default(0.025)))) }}', x, y);
1306
+ y += 10;
1307
+ {% endfor %}
1308
+
1309
+ // Total Row
1310
+ x = 10;
1311
+ doc.setFont('helvetica', 'bold');
1312
+ doc.text('Total', x, y, { maxWidth: colWidths[0] });
1313
+ x += colWidths[0];
1314
+ doc.text('₹{{ "%.2f"|format(total_gross_value) }}', x, y);
1315
+ x += colWidths[1];
1316
+ doc.text('₹{{ "%.2f"|format(total_discount) }}', x, y);
1317
+ x += colWidths[2];
1318
+ doc.text('₹{{ "%.2f"|format(total_net_value) }}', x, y);
1319
+ x += colWidths[3];
1320
+ x += colWidths[4];
1321
+ doc.text('₹{{ "%.3f"|format(total_cgst) }}', x, y);
1322
+ x += colWidths[5];
1323
+ x += colWidths[6];
1324
+ doc.text('₹{{ "%.3f"|format(total_sgst) }}', x, y);
1325
+ x += colWidths[7];
1326
+ doc.text('₹{{ "%.2f"|format(total_amount) }}', x, y);
1327
+ doc.setFont('helvetica', 'normal');
1328
+ y += 20;
1329
+
1330
+ // Footer
1331
+ doc.setFontSize(10);
1332
+ doc.text('Amount (in words): {{ total_amount_in_words | default('Three Hundred Eighty Seven Rupees And Forty Five Paisa Only') }}', 10, y, { maxWidth: 190 });
1333
+ y += 10;
1334
+ doc.text('Payment Mode: {{ order.payment_mode | default('Digital') }}', 10, y);
1335
+ y += 10;
1336
+ doc.text('Order ID: {{ order.id | default('6428970359') }}', 10, y);
1337
+ y += 10;
1338
+ doc.text('Order Date: {{ order.created_date | default('2024-12-12') }}', 10, y);
1339
+ y += 10;
1340
+ doc.text('Supply attracts reverse charge: {{ order.reverse_charge | default('No') }}', 10, y);
1341
+ y += 10;
1342
+ doc.text('For {{ restaurant.legal_name | default('ZOMATO LIMITED') }}', 10, y);
1343
+ y += 10;
1344
+ doc.text('Authorized Signatory', 10, y);
1345
+
1346
+ // Save PDF
1347
+ doc.save('invoice_{{ order.id | default('247JD92F00043965') }}.pdf');
1348
+ }
1349
+
1350
  document.addEventListener('DOMContentLoaded', () => {
1351
  try {
1352
  const progressBar = document.getElementById('progressBar');