accounting modules
This commit is contained in:
@@ -244,6 +244,7 @@
|
||||
// ── Status helpers ────────────────────────────────────────────────────────
|
||||
function order_status_badge(status) {
|
||||
const map = {
|
||||
'-2': '<span class="badge bg-danger">Pending — Awaiting Warehouse</span>',
|
||||
'-1': '<span class="badge bg-secondary">Cancelled</span>',
|
||||
'0': '<span class="badge bg-warning text-dark">Draft</span>',
|
||||
'1': '<span class="badge bg-info text-white">Confirmed</span>',
|
||||
@@ -380,19 +381,26 @@
|
||||
has_active_invoice = has_active_invoice || false;
|
||||
returnable_count = returnable_count ?? 1;
|
||||
fulfillment_status = parseInt(fulfillment_status) || 0;
|
||||
var is_pending = status === -2;
|
||||
var is_draft = status === 0;
|
||||
var can_confirm = status === 0;
|
||||
var can_cancel = status === 0 || status === 1;
|
||||
var is_editable = is_pending || is_draft; // both Pending and Draft are editable
|
||||
var can_confirm = status === 0; // only Draft can be confirmed (not Pending)
|
||||
var can_cancel = status === -2 || status === 0 || status === 1;
|
||||
var is_cancelled = status === -1;
|
||||
var is_completed = status === 3;
|
||||
var can_fulfill = status >= 1 && !is_cancelled && !is_completed;
|
||||
|
||||
// Edit controls
|
||||
$('#btn_add_item, #contact, #order_date, #notes, #discount, #tax, #shipping_fee')
|
||||
.prop('disabled', !is_draft);
|
||||
$('#shipping_tracking_number').prop('disabled', !(is_draft || can_fulfill));
|
||||
$('.item_sku, .item_qty, .item_price, .item_warehouse').prop('disabled', !is_draft);
|
||||
$('a[onclick^="remove_item"]').toggleClass('d-none', !is_draft);
|
||||
.prop('disabled', !is_editable);
|
||||
$('#shipping_tracking_number').prop('disabled', !(is_editable || can_fulfill));
|
||||
$('.item_sku, .item_qty, .item_price, .item_warehouse').prop('disabled', !is_editable);
|
||||
$('a[onclick^="remove_item"]').toggleClass('d-none', !is_editable);
|
||||
|
||||
// Pending hint
|
||||
if (is_pending) {
|
||||
$('#page_subtitle').text('Assign a warehouse for each item, then save to move this order to Draft.');
|
||||
}
|
||||
|
||||
// Action buttons
|
||||
set_btn_state('#btn_save', is_draft, 'Only draft orders can be edited');
|
||||
|
||||
Reference in New Issue
Block a user