anuragshas commited on
Commit
38c96d1
·
1 Parent(s): 6858e31

chore: basic linting

Browse files
Files changed (7) hide show
  1. .eslintrc.json +13 -4
  2. .htmlhintrc +1 -1
  3. .stylelintrc.json +1 -1
  4. index.html +7 -3
  5. script.js +13 -13
  6. style.css +1 -1
  7. tests/test.js +1 -1
.eslintrc.json CHANGED
@@ -10,8 +10,17 @@
10
  "sourceType": "module"
11
  },
12
  "rules": {
13
- "indent": ["error", 2],
14
- "quotes": ["error", "single"],
15
- "semi": ["error", "always"]
 
 
 
 
 
 
 
 
 
16
  }
17
- }
 
10
  "sourceType": "module"
11
  },
12
  "rules": {
13
+ "indent": [
14
+ "error",
15
+ 2
16
+ ],
17
+ "quotes": [
18
+ "error",
19
+ "single"
20
+ ],
21
+ "semi": [
22
+ "error",
23
+ "always"
24
+ ]
25
  }
26
+ }
.htmlhintrc CHANGED
@@ -7,4 +7,4 @@
7
  "spec-char-escape": true,
8
  "id-unique": true,
9
  "src-not-empty": true
10
- }
 
7
  "spec-char-escape": true,
8
  "id-unique": true,
9
  "src-not-empty": true
10
+ }
.stylelintrc.json CHANGED
@@ -4,4 +4,4 @@
4
  "rule-empty-line-before": null,
5
  "no-descending-specificity": null
6
  }
7
- }
 
4
  "rule-empty-line-before": null,
5
  "no-descending-specificity": null
6
  }
7
+ }
index.html CHANGED
@@ -1,11 +1,13 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
  <title>Quotation Generator</title>
7
  <link rel="stylesheet" href="style.css">
8
  </head>
 
9
  <body>
10
  <h1>Quotation Generator</h1>
11
  <div id="form-container">
@@ -33,7 +35,7 @@
33
  <legend>Items</legend>
34
  <table id="items-table">
35
  <thead>
36
- <tr>
37
  <th>S.No</th>
38
  <th>Description</th>
39
  <th>HSN Code</th>
@@ -52,7 +54,8 @@
52
  <fieldset>
53
  <legend>Additional Charges</legend>
54
  <label>IGST (%)<input type="number" id="igst-rate" name="igst-rate" value="0" min="0"></label>
55
- <label>Freight Charges<input type="number" id="freight-charges" name="freight-charges" value="0" min="0"></label>
 
56
  </fieldset>
57
  <fieldset>
58
  <legend>Bank Details</legend>
@@ -67,4 +70,5 @@
67
  <div id="quotation-output" style="display:none;"></div>
68
  <script src="script.js"></script>
69
  </body>
70
- </html>
 
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
+
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1">
7
  <title>Quotation Generator</title>
8
  <link rel="stylesheet" href="style.css">
9
  </head>
10
+
11
  <body>
12
  <h1>Quotation Generator</h1>
13
  <div id="form-container">
 
35
  <legend>Items</legend>
36
  <table id="items-table">
37
  <thead>
38
+ <tr>
39
  <th>S.No</th>
40
  <th>Description</th>
41
  <th>HSN Code</th>
 
54
  <fieldset>
55
  <legend>Additional Charges</legend>
56
  <label>IGST (%)<input type="number" id="igst-rate" name="igst-rate" value="0" min="0"></label>
57
+ <label>Freight Charges<input type="number" id="freight-charges" name="freight-charges" value="0"
58
+ min="0"></label>
59
  </fieldset>
60
  <fieldset>
61
  <legend>Bank Details</legend>
 
70
  <div id="quotation-output" style="display:none;"></div>
71
  <script src="script.js"></script>
72
  </body>
73
+
74
+ </html>
script.js CHANGED
@@ -21,7 +21,7 @@ function numberToWords(num) {
21
  }
22
 
23
  if (typeof document !== 'undefined') {
24
- document.addEventListener('DOMContentLoaded', function() {
25
  const addItemBtn = document.getElementById('add-item');
26
  const itemsTableBody = document.querySelector('#items-table tbody');
27
  const form = document.getElementById('quotation-form');
@@ -36,14 +36,14 @@ if (typeof document !== 'undefined') {
36
  function addItemRow() {
37
  const row = document.createElement('tr');
38
  row.innerHTML = `
39
- <td class="item-slno"></td>
40
- <td><input type="text" class="item-desc" placeholder="Item Description" required></td>
41
- <td><input type="text" class="item-hsn" placeholder="HSN Code"></td>
42
- <td><input type="number" class="item-qty" value="1" min="0" required></td>
43
- <td><input type="number" class="item-price" value="0" min="0" required></td>
44
- <td><input type="number" class="item-discount" value="0" min="0" max="100" step="0.01" placeholder="Discount %"></td>
45
- <td class="item-amount">0.00</td>
46
- <td><button type="button" class="remove-item">Remove</button></td>
47
  `;
48
  itemsTableBody.appendChild(row);
49
  updateSerialNumbers();
@@ -67,7 +67,7 @@ if (typeof document !== 'undefined') {
67
 
68
  addItemBtn.addEventListener('click', addItemRow);
69
 
70
- form.addEventListener('submit', function(e) {
71
  e.preventDefault();
72
  const data = new FormData(form);
73
  const company = {
@@ -112,8 +112,8 @@ if (typeof document !== 'undefined') {
112
  const rupeeWords = numberToWords(rupeePart);
113
  const paiseWords = paisePart > 0 ? numberToWords(paisePart) : '';
114
  let html = '<div class="quotation-print">';
115
- html += `<div class="section"><strong>From:</strong><br>${company.name}<br>${company.address.replace(/\n/g,'<br>')}<br>Phone: ${company.phone}<br>Email: ${company.email}</div>`;
116
- html += `<div class="section"><strong>To:</strong><br>${customer.name}<br>${customer.address.replace(/\n/g,'<br>')}<br>Phone: ${customer.phone}<br>Email: ${customer.email}</div>`;
117
  html += `<div class="section quote-meta">Quotation No: ${quotationNumber}<br>Date: ${quotationDate}</div>`;
118
  html += '<table class="quotation-table"><thead><tr><th>S.No</th><th>Description</th><th>HSN</th><th>Qty</th><th>Unit Price</th><th>Discount (%)</th><th>Amount</th></tr></thead><tbody>';
119
  items.forEach((item, idx) => {
@@ -142,4 +142,4 @@ if (typeof document !== 'undefined') {
142
  // Export for testing (Node.js)
143
  if (typeof module !== 'undefined' && module.exports) {
144
  module.exports = { numberToWords };
145
- }
 
21
  }
22
 
23
  if (typeof document !== 'undefined') {
24
+ document.addEventListener('DOMContentLoaded', function () {
25
  const addItemBtn = document.getElementById('add-item');
26
  const itemsTableBody = document.querySelector('#items-table tbody');
27
  const form = document.getElementById('quotation-form');
 
36
  function addItemRow() {
37
  const row = document.createElement('tr');
38
  row.innerHTML = `
39
+ <td class="item-slno" data-label="S.No"></td>
40
+ <td data-label="Description"><input type="text" class="item-desc" placeholder="Item Description" required></td>
41
+ <td data-label="HSN Code"><input type="text" class="item-hsn" placeholder="HSN Code"></td>
42
+ <td data-label="Qty"><input type="number" class="item-qty" value="1" min="0" required></td>
43
+ <td data-label="Unit Price"><input type="number" class="item-price" value="0" min="0" required></td>
44
+ <td data-label="Discount (%)"><input type="number" class="item-discount" value="0" min="0" max="100" step="0.01" placeholder="Discount %"></td>
45
+ <td class="item-amount" data-label="Amount">0.00</td>
46
+ <td data-label="Action"><button type="button" class="remove-item">Remove</button></td>
47
  `;
48
  itemsTableBody.appendChild(row);
49
  updateSerialNumbers();
 
67
 
68
  addItemBtn.addEventListener('click', addItemRow);
69
 
70
+ form.addEventListener('submit', function (e) {
71
  e.preventDefault();
72
  const data = new FormData(form);
73
  const company = {
 
112
  const rupeeWords = numberToWords(rupeePart);
113
  const paiseWords = paisePart > 0 ? numberToWords(paisePart) : '';
114
  let html = '<div class="quotation-print">';
115
+ html += `<div class="section"><strong>From:</strong><br>${company.name}<br>${company.address.replace(/\n/g, '<br>')}<br>Phone: ${company.phone}<br>Email: ${company.email}</div>`;
116
+ html += `<div class="section"><strong>To:</strong><br>${customer.name}<br>${customer.address.replace(/\n/g, '<br>')}<br>Phone: ${customer.phone}<br>Email: ${customer.email}</div>`;
117
  html += `<div class="section quote-meta">Quotation No: ${quotationNumber}<br>Date: ${quotationDate}</div>`;
118
  html += '<table class="quotation-table"><thead><tr><th>S.No</th><th>Description</th><th>HSN</th><th>Qty</th><th>Unit Price</th><th>Discount (%)</th><th>Amount</th></tr></thead><tbody>';
119
  items.forEach((item, idx) => {
 
142
  // Export for testing (Node.js)
143
  if (typeof module !== 'undefined' && module.exports) {
144
  module.exports = { numberToWords };
145
+ }
style.css CHANGED
@@ -76,7 +76,7 @@ button {
76
  text-align: right;
77
  }
78
 
79
- @media screen and (width <= 768px) {
80
  #items-table thead {
81
  display: none;
82
  }
 
76
  text-align: right;
77
  }
78
 
79
+ @media screen and (width <=768px) {
80
  #items-table thead {
81
  display: none;
82
  }
tests/test.js CHANGED
@@ -30,4 +30,4 @@ cases.forEach(({ num, expected }) => {
30
  );
31
  });
32
 
33
- console.log('✅ All numberToWords tests passed');
 
30
  );
31
  });
32
 
33
+ console.log('✅ All numberToWords tests passed');