feat(sync): add delivery cost, discount tracking and import settings

Parse delivery.total and discounts[] from GoMag JSON into new
delivery_cost/discount_total fields. Add app_settings table for
configuring transport/discount CODMAT codes. When configured,
transport and discount are appended as extra articles in the
Oracle import JSON. Reorder Total column in dashboard/logs tables
and show transport/discount breakdown in order detail modals.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-03-16 10:15:17 +00:00
parent 137c4a8b0b
commit 25aa9e544c
10 changed files with 302 additions and 22 deletions

View File

@@ -84,10 +84,10 @@
<th class="sortable" onclick="dashSortBy('order_date')">Data <span class="sort-icon" data-col="order_date"></span></th>
<th class="sortable" onclick="dashSortBy('customer_name')">Client <span class="sort-icon" data-col="customer_name"></span></th>
<th class="sortable" onclick="dashSortBy('items_count')">Art. <span class="sort-icon" data-col="items_count"></span></th>
<th class="text-end">Total</th>
<th class="sortable" onclick="dashSortBy('status')">Status Import <span class="sort-icon" data-col="status"></span></th>
<th>ID ROA</th>
<th>Factura</th>
<th>Total</th>
</tr>
</thead>
<tbody id="dashOrdersBody">
@@ -121,8 +121,10 @@
<small class="text-muted">ID Adr. Livrare:</small> <span id="detailIdAdresaLivr">-</span>
</div>
</div>
<div class="d-flex justify-content-end gap-3 mb-2" id="detailTotals">
<div class="d-flex justify-content-end gap-3 mb-2 flex-wrap" id="detailTotals">
<span><small class="text-muted">Valoare articole:</small> <strong id="detailItemsTotal">-</strong></span>
<span id="detailDeliveryWrap" style="display:none"><small class="text-muted">Transport:</small> <strong id="detailDeliveryCost">-</strong></span>
<span id="detailDiscountWrap" style="display:none"><small class="text-muted">Discount:</small> <strong id="detailDiscount">-</strong></span>
<span><small class="text-muted">Total comanda:</small> <strong id="detailOrderTotal">-</strong></span>
</div>
<div class="table-responsive d-none d-md-block">
@@ -153,6 +155,43 @@
</div>
</div>
<!-- Settings Card -->
<div class="card mb-4">
<div class="card-header d-flex align-items-center justify-content-between">
<span>Setari Import</span>
<button class="btn btn-sm btn-primary" onclick="saveAppSettings()">Salveaza</button>
</div>
<div class="card-body">
<div class="row g-3">
<div class="col-md-4">
<label class="form-label form-label-sm mb-1">CODMAT Transport</label>
<div class="position-relative">
<input type="text" class="form-control form-control-sm" id="settTransportCodmat" placeholder="ex: TRANSPORT" autocomplete="off">
<div class="autocomplete-dropdown d-none" id="settTransportAc"></div>
</div>
<small class="text-muted">Lasa gol pentru a nu adauga transport la import</small>
</div>
<div class="col-md-2">
<label class="form-label form-label-sm mb-1">TVA Transport (%)</label>
<select class="form-select form-select-sm" id="settTransportVat">
<option value="5">5%</option>
<option value="9">9%</option>
<option value="19">19%</option>
<option value="21" selected>21%</option>
</select>
</div>
<div class="col-md-4">
<label class="form-label form-label-sm mb-1">CODMAT Discount</label>
<div class="position-relative">
<input type="text" class="form-control form-control-sm" id="settDiscountCodmat" placeholder="ex: DISCOUNT" autocomplete="off">
<div class="autocomplete-dropdown d-none" id="settDiscountAc"></div>
</div>
<small class="text-muted">Lasa gol pentru a nu adauga discount la import</small>
</div>
</div>
</div>
</div>
<!-- Quick Map Modal (used from order detail) -->
<div class="modal fade" id="quickMapModal" tabindex="-1" data-bs-backdrop="static">
<div class="modal-dialog">
@@ -183,5 +222,5 @@
{% endblock %}
{% block scripts %}
<script src="/static/js/dashboard.js?v=6"></script>
<script src="/static/js/dashboard.js?v=7"></script>
{% endblock %}

View File

@@ -72,8 +72,8 @@
<th class="sortable" onclick="sortOrdersBy('order_number')">Nr. comanda <span class="sort-icon" data-col="order_number"></span></th>
<th class="sortable" onclick="sortOrdersBy('customer_name')">Client <span class="sort-icon" data-col="customer_name"></span></th>
<th class="sortable" onclick="sortOrdersBy('items_count')">Articole <span class="sort-icon" data-col="items_count"></span></th>
<th class="text-end">Total</th>
<th class="sortable" onclick="sortOrdersBy('status')">Status <span class="sort-icon" data-col="status"></span></th>
<th>Total</th>
</tr>
</thead>
<tbody id="runOrdersBody">
@@ -116,8 +116,10 @@
<small class="text-muted">ID Adr. Livrare:</small> <span id="detailIdAdresaLivr">-</span>
</div>
</div>
<div class="d-flex justify-content-end gap-3 mb-2" id="detailTotals">
<div class="d-flex justify-content-end gap-3 mb-2 flex-wrap" id="detailTotals">
<span><small class="text-muted">Valoare articole:</small> <strong id="detailItemsTotal">-</strong></span>
<span id="detailDeliveryWrap" style="display:none"><small class="text-muted">Transport:</small> <strong id="detailDeliveryCost">-</strong></span>
<span id="detailDiscountWrap" style="display:none"><small class="text-muted">Discount:</small> <strong id="detailDiscount">-</strong></span>
<span><small class="text-muted">Total comanda:</small> <strong id="detailOrderTotal">-</strong></span>
</div>
<div class="table-responsive d-none d-md-block">
@@ -181,5 +183,5 @@
{% endblock %}
{% block scripts %}
<script src="/static/js/logs.js?v=6"></script>
<script src="/static/js/logs.js?v=7"></script>
{% endblock %}