Spaces:
Sleeping
Sleeping
Commit
·
ff5b78c
1
Parent(s):
0ea575d
fix: indentation
Browse files
script.js
CHANGED
|
@@ -100,12 +100,21 @@ if (typeof document !== "undefined") {
|
|
| 100 |
items.push({
|
| 101 |
description: desc,
|
| 102 |
hsn: row.querySelector(".item-hsn").value,
|
| 103 |
-
qty:
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
discount:
|
| 106 |
-
parseFloat(
|
|
|
|
|
|
|
| 107 |
amount:
|
| 108 |
-
parseFloat(
|
|
|
|
|
|
|
| 109 |
});
|
| 110 |
}
|
| 111 |
});
|
|
@@ -301,7 +310,9 @@ if (typeof document !== "undefined") {
|
|
| 301 |
|
| 302 |
// If we're at the last input in the row and it's the last row, add a new row
|
| 303 |
if (currentIndex === inputs.length - 1) {
|
| 304 |
-
const allRows = Array.from(
|
|
|
|
|
|
|
| 305 |
const currentRowIndex = allRows.indexOf(currentRow);
|
| 306 |
|
| 307 |
if (currentRowIndex === allRows.length - 1) {
|
|
@@ -386,25 +397,35 @@ if (typeof document !== "undefined") {
|
|
| 386 |
});
|
| 387 |
|
| 388 |
// Add remove button listener
|
| 389 |
-
row.querySelector(".remove-item").addEventListener(
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
|
| 409 |
// Auto-calculate initial amount
|
| 410 |
updateItemAmount({ target: row.querySelector(".item-qty") });
|
|
@@ -415,7 +436,8 @@ if (typeof document !== "undefined") {
|
|
| 415 |
if (!row) return;
|
| 416 |
|
| 417 |
const qty = parseFloat(row.querySelector(".item-qty").value) || 0;
|
| 418 |
-
const price =
|
|
|
|
| 419 |
const discountRate =
|
| 420 |
parseFloat(row.querySelector(".item-discount").value) || 0;
|
| 421 |
|
|
@@ -426,7 +448,8 @@ if (typeof document !== "undefined") {
|
|
| 426 |
|
| 427 |
// Add visual feedback for calculated amount
|
| 428 |
const amountCell = row.querySelector(".item-amount");
|
| 429 |
-
amountCell.style.backgroundColor =
|
|
|
|
| 430 |
}
|
| 431 |
|
| 432 |
// Enhanced Add Item button
|
|
|
|
| 100 |
items.push({
|
| 101 |
description: desc,
|
| 102 |
hsn: row.querySelector(".item-hsn").value,
|
| 103 |
+
qty:
|
| 104 |
+
parseFloat(row.querySelector(".item-qty").value) ||
|
| 105 |
+
0,
|
| 106 |
+
price:
|
| 107 |
+
parseFloat(
|
| 108 |
+
row.querySelector(".item-price").value,
|
| 109 |
+
) || 0,
|
| 110 |
discount:
|
| 111 |
+
parseFloat(
|
| 112 |
+
row.querySelector(".item-discount").value,
|
| 113 |
+
) || 0,
|
| 114 |
amount:
|
| 115 |
+
parseFloat(
|
| 116 |
+
row.querySelector(".item-amount").textContent,
|
| 117 |
+
) || 0,
|
| 118 |
});
|
| 119 |
}
|
| 120 |
});
|
|
|
|
| 310 |
|
| 311 |
// If we're at the last input in the row and it's the last row, add a new row
|
| 312 |
if (currentIndex === inputs.length - 1) {
|
| 313 |
+
const allRows = Array.from(
|
| 314 |
+
itemsTableBody.querySelectorAll("tr"),
|
| 315 |
+
);
|
| 316 |
const currentRowIndex = allRows.indexOf(currentRow);
|
| 317 |
|
| 318 |
if (currentRowIndex === allRows.length - 1) {
|
|
|
|
| 397 |
});
|
| 398 |
|
| 399 |
// Add remove button listener
|
| 400 |
+
row.querySelector(".remove-item").addEventListener(
|
| 401 |
+
"click",
|
| 402 |
+
(_event) => {
|
| 403 |
+
if (itemsTableBody.children.length > 1) {
|
| 404 |
+
row.remove();
|
| 405 |
+
updateSerialNumbers();
|
| 406 |
+
updatePreview();
|
| 407 |
+
} else {
|
| 408 |
+
// If it's the last row, just clear it instead of removing
|
| 409 |
+
inputs.forEach((input) => {
|
| 410 |
+
if (input.type === "number") {
|
| 411 |
+
input.value = input.classList.contains(
|
| 412 |
+
"item-qty",
|
| 413 |
+
)
|
| 414 |
+
? "1"
|
| 415 |
+
: "0";
|
| 416 |
+
} else {
|
| 417 |
+
input.value = "";
|
| 418 |
+
}
|
| 419 |
+
input.classList.remove(
|
| 420 |
+
"input-error",
|
| 421 |
+
"input-success",
|
| 422 |
+
);
|
| 423 |
+
});
|
| 424 |
+
row.querySelector(".item-amount").textContent = "0.00";
|
| 425 |
+
updatePreview();
|
| 426 |
+
}
|
| 427 |
+
},
|
| 428 |
+
);
|
| 429 |
|
| 430 |
// Auto-calculate initial amount
|
| 431 |
updateItemAmount({ target: row.querySelector(".item-qty") });
|
|
|
|
| 436 |
if (!row) return;
|
| 437 |
|
| 438 |
const qty = parseFloat(row.querySelector(".item-qty").value) || 0;
|
| 439 |
+
const price =
|
| 440 |
+
parseFloat(row.querySelector(".item-price").value) || 0;
|
| 441 |
const discountRate =
|
| 442 |
parseFloat(row.querySelector(".item-discount").value) || 0;
|
| 443 |
|
|
|
|
| 448 |
|
| 449 |
// Add visual feedback for calculated amount
|
| 450 |
const amountCell = row.querySelector(".item-amount");
|
| 451 |
+
amountCell.style.backgroundColor =
|
| 452 |
+
amount > 0 ? "#f0fdf4" : "#fef2f2";
|
| 453 |
}
|
| 454 |
|
| 455 |
// Enhanced Add Item button
|
style.css
CHANGED
|
@@ -318,7 +318,6 @@
|
|
| 318 |
}
|
| 319 |
|
| 320 |
@media print {
|
| 321 |
-
|
| 322 |
html,
|
| 323 |
body {
|
| 324 |
height: 100%;
|
|
|
|
| 318 |
}
|
| 319 |
|
| 320 |
@media print {
|
|
|
|
| 321 |
html,
|
| 322 |
body {
|
| 323 |
height: 100%;
|