update vat issue
This commit is contained in:
parent
46b5eae015
commit
3694996f67
BIN
assets/pasted-20260505-042538-9c56fd70.png
Normal file
BIN
assets/pasted-20260505-042538-9c56fd70.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
@ -441,9 +441,18 @@ require __DIR__ . '/includes/header.php';
|
||||
<?php $effectiveDelivery = $order['delivery_date'] ?: date('Y-m-d', strtotime((string) $order['sale_date'])); ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php $eidSerialValue = max(1, (int) ($order['eid_serial_no'] ?? 0)); ?>
|
||||
<div class="fw-semibold"><?= h(eid_serial_label($eidSerialValue)) ?></div>
|
||||
<div class="small text-muted">#<?= h($order['receipt_no']) ?> · <?= h(sale_mode_label((string) ($order['sale_mode'] ?? 'normal'))) ?></div>
|
||||
<?php
|
||||
$receiptReference = trim((string) ($order['receipt_no'] ?? ''));
|
||||
$eidSerialValue = (int) ($order['eid_serial_no'] ?? 0);
|
||||
?>
|
||||
<div class="fw-semibold">#<?= h($receiptReference !== '' ? $receiptReference : (string) ($order['id'] ?? '')) ?></div>
|
||||
<div class="small text-muted">
|
||||
<?php if ($eidSerialValue > 0): ?>
|
||||
<?= h(tr('التسلسل الموسمي', 'Season serial')) ?>: <?= h(eid_serial_label($eidSerialValue)) ?>
|
||||
<span aria-hidden="true">·</span>
|
||||
<?php endif; ?>
|
||||
<?= h(sale_mode_label((string) ($order['sale_mode'] ?? 'normal'))) ?>
|
||||
</div>
|
||||
</td>
|
||||
<?php
|
||||
$rawCustomerName = (string) ($order['customer_name'] ?: tr('عميل نقدي', 'Walk-in customer'));
|
||||
|
||||
@ -1895,7 +1895,9 @@ function eid_serial_setting_key(): string
|
||||
|
||||
function current_eid_serial_next(PDO $pdo): int
|
||||
{
|
||||
ensure_sales_table();
|
||||
if (!$pdo->inTransaction()) {
|
||||
ensure_sales_table();
|
||||
}
|
||||
|
||||
$seedStmt = $pdo->query("SELECT COALESCE(MAX(eid_serial_no), 0) + 1 FROM sales_orders WHERE order_type = 'eid'");
|
||||
$seed = max(1, (int) $seedStmt->fetchColumn());
|
||||
@ -1918,7 +1920,9 @@ function reset_eid_serial_next(PDO $pdo, int $nextNumber = 1): void
|
||||
|
||||
function next_eid_serial_no(PDO $pdo): int
|
||||
{
|
||||
ensure_sales_table();
|
||||
if (!$pdo->inTransaction()) {
|
||||
ensure_sales_table();
|
||||
}
|
||||
|
||||
$settingKey = eid_serial_setting_key();
|
||||
$seedValue = current_eid_serial_next($pdo);
|
||||
@ -1952,7 +1956,10 @@ function create_sale(array $data): int
|
||||
ensure_sales_table();
|
||||
|
||||
$pdo = db();
|
||||
$pdo->beginTransaction();
|
||||
$ownsTransaction = !$pdo->inTransaction();
|
||||
if ($ownsTransaction) {
|
||||
$pdo->beginTransaction();
|
||||
}
|
||||
try {
|
||||
$receiptNo = isset($data['receipt_no']) && trim((string) $data['receipt_no']) !== ''
|
||||
? trim((string) $data['receipt_no'])
|
||||
@ -2010,10 +2017,12 @@ function create_sale(array $data): int
|
||||
$saleId = (int) $pdo->lastInsertId();
|
||||
sync_order_stock_reservation([], 'completed', $data['items'] ?? [], (string) ($data['status'] ?? 'completed'));
|
||||
|
||||
$pdo->commit();
|
||||
if ($ownsTransaction && $pdo->inTransaction()) {
|
||||
$pdo->commit();
|
||||
}
|
||||
return $saleId;
|
||||
} catch (Throwable $e) {
|
||||
if ($pdo->inTransaction()) {
|
||||
if ($ownsTransaction && $pdo->inTransaction()) {
|
||||
$pdo->rollBack();
|
||||
}
|
||||
throw $e;
|
||||
|
||||
@ -129,28 +129,29 @@
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="rounded-4 border bg-body-tertiary p-3 settings-eid-card">
|
||||
<div class="small text-uppercase text-muted mb-1"><?= h(tr('طلبات العيد', 'Eid orders')) ?></div>
|
||||
<h6 class="fw-bold mb-1"><?= h(tr('إعادة ضبط التسلسل الموسمي', 'Reset seasonal serial')) ?></h6>
|
||||
<p class="text-muted small mb-2"><?= h(tr('يعيد الرقم القادم لطلبات العيد إلى 1 للطلبات الجديدة فقط، بدون تغيير أرقام الطلبات السابقة.', 'Resets the next Eid order serial to 1 for new orders only, without changing older saved orders.')) ?></p>
|
||||
<div class="d-flex flex-column flex-xl-row justify-content-between align-items-xl-start gap-3 settings-eid-header-row">
|
||||
<div class="flex-grow-1">
|
||||
<div class="small text-uppercase text-muted mb-1"><?= h(tr('طلبات العيد', 'Eid orders')) ?></div>
|
||||
<h6 class="fw-bold mb-1"><?= h(tr('إعادة ضبط التسلسل الموسمي', 'Reset seasonal serial')) ?></h6>
|
||||
<p class="text-muted small mb-0"><?= h(tr('يعيد الرقم القادم لطلبات العيد إلى 1 للطلبات الجديدة فقط، بدون تغيير أرقام الطلبات السابقة.', 'Resets the next Eid order serial to 1 for new orders only, without changing older saved orders.')) ?></p>
|
||||
</div>
|
||||
|
||||
<div class="bg-white border rounded-3 p-3 settings-eid-reset-box">
|
||||
<div class="d-flex flex-column flex-sm-row justify-content-between align-items-sm-center gap-2">
|
||||
<div>
|
||||
<div class="small text-muted mb-1"><?= h(tr('الرقم القادم', 'Next serial')) ?></div>
|
||||
<div class="bg-white border rounded-3 px-3 py-2 settings-eid-reset-box">
|
||||
<div class="small text-muted mb-1"><?= h(tr('الرقم القادم', 'Next serial')) ?></div>
|
||||
<div class="d-flex align-items-center gap-2 flex-nowrap settings-eid-inline-controls" dir="auto">
|
||||
<div class="fs-5 fw-bold mb-0" data-eid-serial-next-label="1"><?= h(eid_serial_label($eidSerialNext)) ?></div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-danger btn-sm px-3 text-nowrap"
|
||||
data-reset-eid-serial="1"
|
||||
data-reset-url="<?= h(url_for('api/settings.php')) ?>"
|
||||
data-reset-label="<?= h(eid_serial_label(1)) ?>"
|
||||
data-reset-confirm="<?= h(tr('سيتم تعيين الرقم القادم لطلبات العيد إلى 1. لن يتم تعديل الطلبات القديمة. هل تريد المتابعة؟', 'The next Eid order serial will be reset to 1. Old orders will not be changed. Do you want to continue?')) ?>"
|
||||
data-reset-success="<?= h(tr('تمت إعادة الضبط بنجاح.', 'Reset completed successfully.')) ?>"
|
||||
data-reset-error="<?= h(tr('تعذر تنفيذ إعادة الضبط حالياً. حاول مرة أخرى.', 'Could not reset the Eid serial right now. Please try again.')) ?>">
|
||||
<i class="bi bi-arrow-counterclockwise me-1"></i><?= h(tr('إعادة الضبط إلى 1', 'Reset to 1')) ?>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-danger btn-sm px-3 align-self-start align-self-sm-center text-nowrap"
|
||||
data-reset-eid-serial="1"
|
||||
data-reset-url="<?= h(url_for('api/settings.php')) ?>"
|
||||
data-reset-label="<?= h(eid_serial_label(1)) ?>"
|
||||
data-reset-confirm="<?= h(tr('سيتم تعيين الرقم القادم لطلبات العيد إلى 1. لن يتم تعديل الطلبات القديمة. هل تريد المتابعة؟', 'The next Eid order serial will be reset to 1. Old orders will not be changed. Do you want to continue?')) ?>"
|
||||
data-reset-success="<?= h(tr('تمت إعادة الضبط بنجاح.', 'Reset completed successfully.')) ?>"
|
||||
data-reset-error="<?= h(tr('تعذر تنفيذ إعادة الضبط حالياً. حاول مرة أخرى.', 'Could not reset the Eid serial right now. Please try again.')) ?>"
|
||||
dir="auto">
|
||||
<i class="bi bi-arrow-counterclockwise me-1"></i><?= h(tr('إعادة الضبط إلى 1', 'Reset to 1')) ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -355,9 +356,18 @@
|
||||
margin-top: -0.125rem;
|
||||
}
|
||||
|
||||
#settingsModal .settings-eid-header-row {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
#settingsModal .settings-eid-reset-box {
|
||||
padding-top: 0.875rem;
|
||||
padding-bottom: 0.875rem;
|
||||
flex: 0 0 auto;
|
||||
min-width: 290px;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
#settingsModal .settings-eid-inline-controls {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#settingsModal .settings-inline-save {
|
||||
@ -380,6 +390,15 @@
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
#settingsModal .settings-eid-header-row {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
#settingsModal .settings-eid-reset-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
#wablasSettingsModal {
|
||||
|
||||
@ -15,6 +15,7 @@ $savePrintLabel = $savePrintLabel ?? tr('حفظ مع الطباعة', 'Save with
|
||||
$error = '';
|
||||
$paymentAmountInput = (string) ($_POST['payment_amount'] ?? '');
|
||||
$catalog = catalog();
|
||||
$globalVatPercent = max(0, (float) get_setting('vat_percentage', 5));
|
||||
$allowedBranches = get_user_branches($user);
|
||||
$deliveryOptions = eid_delivery_status_options();
|
||||
$selectedDeliveryStatus = trim((string) ($_POST['delivery_status'] ?? ($isEidOrder ? 'pending' : '')));
|
||||
@ -110,8 +111,7 @@ $itemNote = trim((string) ($item['item_note'] ?? ''));
|
||||
: (float) $product['price'];
|
||||
$lineTotal = $price * $qty;
|
||||
|
||||
$vatPercent = (float) ($product['vat'] ?? 0);
|
||||
// Assuming price is inclusive of VAT:
|
||||
$vatPercent = $globalVatPercent;
|
||||
$itemVat = $lineTotal * ($vatPercent / 100);
|
||||
$totalVat += $itemVat;
|
||||
|
||||
@ -547,7 +547,7 @@ require __DIR__ . '/header.php';
|
||||
<span id="displaySubtotal" class="fw-medium">0.000</span>
|
||||
</div>
|
||||
<div class="totals-row">
|
||||
<span><?= h(tr('الضريبة (مضافة)', 'VAT (Added)')) ?></span>
|
||||
<span><?= h(tr('الضريبة (' . number_format($globalVatPercent, 2) . '%)', 'VAT (' . number_format($globalVatPercent, 2) . '%)')) ?></span>
|
||||
<span id="displayVat" class="text-muted">0.000</span>
|
||||
</div>
|
||||
<div class="totals-row grand-total">
|
||||
@ -879,7 +879,7 @@ function renderInvoice() {
|
||||
const item = invoiceItems[sku];
|
||||
const lineTotal = item.qty * item.price;
|
||||
|
||||
const vatPercent = parseFloat(catalogData[sku].vat) || 0;
|
||||
const vatPercent = <?= json_encode((float) $globalVatPercent) ?>;
|
||||
const itemVat = lineTotal * (vatPercent / 100);
|
||||
totalVat += itemVat;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user