Aleksmorshen commited on
Commit
a50d805
·
verified ·
1 Parent(s): ad7b8c2

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +7 -1
script.js CHANGED
@@ -356,6 +356,9 @@ document.addEventListener('DOMContentLoaded', function () {
356
  document.getElementById('receiptDiscount').textContent = receipt.discount.toFixed(2);
357
  document.getElementById('receiptFinalTotal').textContent = (totalAmount - receipt.discount).toFixed(2);
358
 
 
 
 
359
  // Показываем модальное окно
360
  modal.style.display = 'flex';
361
  }
@@ -365,7 +368,10 @@ document.addEventListener('DOMContentLoaded', function () {
365
  receipt.items.forEach(item => {
366
  totalSold += item.quantity;
367
  totalRevenue += item.quantity * item.salePrice;
368
- totalProfit += item.quantity * (item.salePrice - item.purchasePrice);
 
 
 
369
  });
370
 
371
  // Вычитаем скидку из прибыли
 
356
  document.getElementById('receiptDiscount').textContent = receipt.discount.toFixed(2);
357
  document.getElementById('receiptFinalTotal').textContent = (totalAmount - receipt.discount).toFixed(2);
358
 
359
+ // Убираем кнопку "Подтвердить" при просмотре чека
360
+ document.getElementById('confirmSaleBtn').style.display = 'none';
361
+
362
  // Показываем модальное окно
363
  modal.style.display = 'flex';
364
  }
 
368
  receipt.items.forEach(item => {
369
  totalSold += item.quantity;
370
  totalRevenue += item.quantity * item.salePrice;
371
+
372
+ // Исправляем расчет прибыли
373
+ const purchasePrice = item.purchasePrice || 0; // Если purchasePrice отсутствует, считаем его равным 0
374
+ totalProfit += item.quantity * (item.salePrice - purchasePrice);
375
  });
376
 
377
  // Вычитаем скидку из прибыли