u
This commit is contained in:
@@ -17,6 +17,7 @@ export { posterminal } from './posterminal.js';
|
|||||||
export { printer } from './printer.js';
|
export { printer } from './printer.js';
|
||||||
export { propertyname } from './propertyname.js';
|
export { propertyname } from './propertyname.js';
|
||||||
export { quote } from './quote.js';
|
export { quote } from './quote.js';
|
||||||
|
export { retoure } from './retoure.js';
|
||||||
export { setting } from './setting.js';
|
export { setting } from './setting.js';
|
||||||
export { serper } from './serper.js';
|
export { serper } from './serper.js';
|
||||||
export { supplier } from './supplier.js';
|
export { supplier } from './supplier.js';
|
||||||
|
|||||||
@@ -11,8 +11,17 @@ export const payment = {
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region POST /api/order/:id/payment — create
|
// #region POST /api/order/:id/payment — create
|
||||||
create(orderId, body) {
|
create(orderIdOrBody, maybeBody) {
|
||||||
return http(`/api/order/${orderId}/payment`, { method: 'POST', body });
|
if (typeof orderIdOrBody === 'object' && orderIdOrBody !== null) {
|
||||||
|
return http('/api/payment', { method: 'POST', body: orderIdOrBody });
|
||||||
|
}
|
||||||
|
return http(`/api/order/${orderIdOrBody}/payment`, { method: 'POST', body: maybeBody });
|
||||||
|
},
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region POST /api/payment — register
|
||||||
|
register(body) {
|
||||||
|
return http('/api/payment', { method: 'POST', body });
|
||||||
},
|
},
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
|||||||
187
src/api/retoure.js
Normal file
187
src/api/retoure.js
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
import { http } from './http.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes a retouresummary record from either snake_case (raw view) or camelCase.
|
||||||
|
* Fields: manifest_id, retoure_number, retoure_date, entity_id, customer_name,
|
||||||
|
* positions, gross_total, paid_total, ordered_quantity, shipped_quantity, is_paid, is_shipped, created_at
|
||||||
|
*/
|
||||||
|
export function normalizeRetoureSummary(row) {
|
||||||
|
if (!row) return null;
|
||||||
|
const id = row.manifest_id ?? row.id;
|
||||||
|
const num = row.retoure_number ?? row.number ?? (id ? `RET-${id}` : '');
|
||||||
|
const dt = row.retoure_date ?? row.date ?? row.created_at ?? row.createdAt;
|
||||||
|
const entityId = row.entity_id ?? row.entityId ?? null;
|
||||||
|
const customerName = row.customer_name ?? row.customerName ?? '';
|
||||||
|
const positions = Number(row.positions) || 0;
|
||||||
|
const grossTotal = row.gross_total != null ? Number(row.gross_total) : (row.grossTotal != null ? Number(row.grossTotal) : 0);
|
||||||
|
const paidTotal = row.paid_total != null ? Number(row.paid_total) : (row.paidTotal != null ? Number(row.paidTotal) : 0);
|
||||||
|
const orderedQuantity = row.ordered_quantity != null ? Number(row.ordered_quantity) : (row.orderedQuantity != null ? Number(row.orderedQuantity) : 0);
|
||||||
|
const shippedQuantity = row.shipped_quantity != null ? Number(row.shipped_quantity) : (row.shippedQuantity != null ? Number(row.shippedQuantity) : 0);
|
||||||
|
const isPaid = Boolean(row.is_paid ?? row.isPaid);
|
||||||
|
const isShipped = Boolean(row.is_shipped ?? row.isShipped);
|
||||||
|
const createdAt = row.created_at ?? row.createdAt ?? null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
manifest_id: id,
|
||||||
|
number: num,
|
||||||
|
retoure_number: num,
|
||||||
|
date: dt,
|
||||||
|
retoure_date: dt,
|
||||||
|
entityId,
|
||||||
|
entity_id: entityId,
|
||||||
|
customerName,
|
||||||
|
customer_name: customerName,
|
||||||
|
positions,
|
||||||
|
grossTotal,
|
||||||
|
gross_total: grossTotal,
|
||||||
|
paidTotal,
|
||||||
|
paid_total: paidTotal,
|
||||||
|
orderedQuantity,
|
||||||
|
ordered_quantity: orderedQuantity,
|
||||||
|
shippedQuantity,
|
||||||
|
shipped_quantity: shippedQuantity,
|
||||||
|
isPaid,
|
||||||
|
is_paid: isPaid,
|
||||||
|
isShipped,
|
||||||
|
is_shipped: isShipped,
|
||||||
|
createdAt,
|
||||||
|
created_at: createdAt,
|
||||||
|
lines: row.lines ?? [],
|
||||||
|
files: row.files ?? [],
|
||||||
|
shipments: row.shipments ?? [],
|
||||||
|
payments: row.payments ?? [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customer Returns / Retouren (manifest type = retoure).
|
||||||
|
*/
|
||||||
|
export const retoure = {
|
||||||
|
/**
|
||||||
|
* GET /api/retoure
|
||||||
|
* Query params: q, from, to, isPaid, isShipped, page, pageSize, offset, limit, entityId
|
||||||
|
* → { retoures: RetoureSummary[], total: number, unfilteredTotal: number }
|
||||||
|
*/
|
||||||
|
// #region GET /api/retoure — list
|
||||||
|
async list({
|
||||||
|
q,
|
||||||
|
search,
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
isPaid,
|
||||||
|
isShipped,
|
||||||
|
onlyUnpaid,
|
||||||
|
onlyUndelivered,
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
offset,
|
||||||
|
limit,
|
||||||
|
entityId,
|
||||||
|
seekMonths,
|
||||||
|
} = {}) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
const query = q || search;
|
||||||
|
if (query && String(query).trim()) {
|
||||||
|
params.set('q', String(query).trim());
|
||||||
|
params.set('search', String(query).trim());
|
||||||
|
}
|
||||||
|
if (from) params.set('from', String(from));
|
||||||
|
if (to) params.set('to', String(to));
|
||||||
|
if (isPaid !== undefined && isPaid !== null) {
|
||||||
|
params.set('isPaid', String(isPaid));
|
||||||
|
} else if (onlyUnpaid === true || onlyUnpaid === 'true') {
|
||||||
|
params.set('isPaid', 'false');
|
||||||
|
}
|
||||||
|
if (isShipped !== undefined && isShipped !== null) {
|
||||||
|
params.set('isShipped', String(isShipped));
|
||||||
|
} else if (onlyUndelivered === true || onlyUndelivered === 'true') {
|
||||||
|
params.set('isShipped', 'false');
|
||||||
|
}
|
||||||
|
if (page != null) params.set('page', String(page));
|
||||||
|
if (pageSize != null) params.set('pageSize', String(pageSize));
|
||||||
|
if (offset != null) params.set('offset', String(offset));
|
||||||
|
if (limit != null) params.set('limit', String(limit));
|
||||||
|
if (entityId != null) params.set('entityId', String(entityId));
|
||||||
|
if (seekMonths != null && Number(seekMonths) < 0) {
|
||||||
|
params.set('seekMonths', String(Math.floor(Number(seekMonths))));
|
||||||
|
}
|
||||||
|
|
||||||
|
const qs = params.toString();
|
||||||
|
const res = await http(`/api/retoure${qs ? `?${qs}` : ''}`);
|
||||||
|
const rawList = res?.retoures ?? res?.summaries ?? res?.items ?? (Array.isArray(res) ? res : []);
|
||||||
|
const items = rawList.map(normalizeRetoureSummary);
|
||||||
|
const total = Number(res?.total ?? res?.count ?? items.length);
|
||||||
|
const unfilteredTotal = res?.unfilteredTotal != null ? Number(res.unfilteredTotal) : total;
|
||||||
|
|
||||||
|
return {
|
||||||
|
retoures: items,
|
||||||
|
summaries: items,
|
||||||
|
items,
|
||||||
|
total,
|
||||||
|
unfilteredTotal,
|
||||||
|
raw: res,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
/** GET /api/retoure/:id → { retoure: Retoure } */
|
||||||
|
// #region GET /api/retoure/:id — get
|
||||||
|
async get(id) {
|
||||||
|
const res = await http(`/api/retoure/${id}`);
|
||||||
|
if (res && !res.retoure && (res.id != null || res.manifest_id != null)) {
|
||||||
|
return { retoure: res };
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/retoure
|
||||||
|
* Body: { number?, date, entityId?, externalNumber?, lines }
|
||||||
|
* → 201 { retoure: Retoure }
|
||||||
|
*/
|
||||||
|
// #region POST /api/retoure — create
|
||||||
|
async create(body) {
|
||||||
|
const res = await http('/api/retoure', { method: 'POST', body });
|
||||||
|
if (res && !res.retoure && (res.id != null || res.manifest_id != null)) {
|
||||||
|
return { retoure: res };
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PUT /api/retoure/:id
|
||||||
|
* Body: { number?, date?, entityId?, externalNumber?, lines? }
|
||||||
|
* → 200 { retoure: Retoure }
|
||||||
|
*/
|
||||||
|
// #region PUT /api/retoure/:id — update
|
||||||
|
async update(id, body) {
|
||||||
|
const res = await http(`/api/retoure/${id}`, { method: 'PUT', body });
|
||||||
|
if (res && !res.retoure && (res.id != null || res.manifest_id != null)) {
|
||||||
|
return { retoure: res };
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
/** DELETE /api/retoure/:id → 204 */
|
||||||
|
// #region DELETE /api/retoure/:id — delete
|
||||||
|
delete(id) {
|
||||||
|
return http(`/api/retoure/${id}`, { method: 'DELETE' });
|
||||||
|
},
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/retoure/:id/shipment
|
||||||
|
* Creates return shipment.
|
||||||
|
* Body: { date?, externalNumber?, lines?: Array<{ sku?: string, orderLineId?: number, amount?: number }>, shipping?: { carrierId, type, state, warehouseId } }
|
||||||
|
* → 201 { shipment: Shipment }
|
||||||
|
*/
|
||||||
|
// #region POST /api/retoure/:id/shipment — createShipment
|
||||||
|
createShipment(id, body = {}) {
|
||||||
|
return http(`/api/retoure/${id}/shipment`, { method: 'POST', body });
|
||||||
|
},
|
||||||
|
// #endregion
|
||||||
|
};
|
||||||
@@ -22,6 +22,9 @@ import AuftragBestellungPage from './routes/auftrag/bestellung';
|
|||||||
import AuftragBestellungNeuPage from './routes/auftrag/bestellung/neu';
|
import AuftragBestellungNeuPage from './routes/auftrag/bestellung/neu';
|
||||||
import AuftragBestellungEditPage from './routes/auftrag/bestellung/_orderId';
|
import AuftragBestellungEditPage from './routes/auftrag/bestellung/_orderId';
|
||||||
import AuftragAusliefernPage from './routes/auftrag/ausliefern';
|
import AuftragAusliefernPage from './routes/auftrag/ausliefern';
|
||||||
|
import AuftragRetourePage from './routes/auftrag/retoure';
|
||||||
|
import AuftragRetoureNeuPage from './routes/auftrag/retoure/neu';
|
||||||
|
import AuftragRetoureEditPage from './routes/auftrag/retoure/_retoureId';
|
||||||
import AuftragZahlungenPage from './routes/auftrag/zahlungen';
|
import AuftragZahlungenPage from './routes/auftrag/zahlungen';
|
||||||
import AuftragVersandartenPage from './routes/auftrag/versandarten';
|
import AuftragVersandartenPage from './routes/auftrag/versandarten';
|
||||||
|
|
||||||
@@ -109,6 +112,9 @@ const routes = [
|
|||||||
{ path: 'bestellung/neu', element: <AuftragBestellungNeuPage /> },
|
{ path: 'bestellung/neu', element: <AuftragBestellungNeuPage /> },
|
||||||
{ path: 'bestellung/:orderId', element: <AuftragBestellungEditPage /> },
|
{ path: 'bestellung/:orderId', element: <AuftragBestellungEditPage /> },
|
||||||
{ path: 'ausliefern', element: <AuftragAusliefernPage /> },
|
{ path: 'ausliefern', element: <AuftragAusliefernPage /> },
|
||||||
|
{ path: 'retoure', element: <AuftragRetourePage /> },
|
||||||
|
{ path: 'retoure/neu', element: <AuftragRetoureNeuPage /> },
|
||||||
|
{ path: 'retoure/:retoureId', element: <AuftragRetoureEditPage /> },
|
||||||
{ path: 'zahlungen', element: <AuftragZahlungenPage /> },
|
{ path: 'zahlungen', element: <AuftragZahlungenPage /> },
|
||||||
{ path: 'versandarten', element: <AuftragVersandartenPage /> },
|
{ path: 'versandarten', element: <AuftragVersandartenPage /> },
|
||||||
{ path: 'lieferarten', element: <Navigate to="/auftrag/versandarten" replace /> },
|
{ path: 'lieferarten', element: <Navigate to="/auftrag/versandarten" replace /> },
|
||||||
|
|||||||
@@ -98,6 +98,20 @@ export {
|
|||||||
subscribeChunkStats,
|
subscribeChunkStats,
|
||||||
} from './orderAutomat';
|
} from './orderAutomat';
|
||||||
export { default as entityAutomat } from './entityAutomat';
|
export { default as entityAutomat } from './entityAutomat';
|
||||||
|
export {
|
||||||
|
default as retoureAutomat,
|
||||||
|
selectRetoures,
|
||||||
|
selectRetoureTotal,
|
||||||
|
selectRetoureUnfilteredTotal,
|
||||||
|
isRetourePaid,
|
||||||
|
isRetoureShipped,
|
||||||
|
isRetoureDelivered,
|
||||||
|
getRetoureDate,
|
||||||
|
getItems as getRetoureItems,
|
||||||
|
requireChunk as requireRetoureChunk,
|
||||||
|
getChunkStats as getRetoureChunkStats,
|
||||||
|
subscribeChunkStats as subscribeRetoureChunkStats,
|
||||||
|
} from './retoureAutomat';
|
||||||
export { default as customergroupAutomat } from './customergroupAutomat';
|
export { default as customergroupAutomat } from './customergroupAutomat';
|
||||||
export { default as numberAutomat } from './numberAutomat';
|
export { default as numberAutomat } from './numberAutomat';
|
||||||
export { default as accountAutomat } from './accountAutomat';
|
export { default as accountAutomat } from './accountAutomat';
|
||||||
|
|||||||
@@ -224,14 +224,21 @@ export const orderDraftAutomat = createManifestDraftAutomat({
|
|||||||
name: 'order-draft',
|
name: 'order-draft',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** Shared singleton automat for retoure draft. */
|
||||||
|
export const retoureDraftAutomat = createManifestDraftAutomat({
|
||||||
|
kind: 'retoure',
|
||||||
|
name: 'retoure-draft',
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the draft automat for a given manifest kind.
|
* Returns the draft automat for a given manifest kind.
|
||||||
* @param {'quote'|'order'} kind
|
* @param {'quote'|'order'|'retoure'} kind
|
||||||
* @returns {Automat|null}
|
* @returns {Automat|null}
|
||||||
*/
|
*/
|
||||||
export function getManifestDraftAutomat(kind) {
|
export function getManifestDraftAutomat(kind) {
|
||||||
if (kind === 'quote') return quoteDraftAutomat;
|
if (kind === 'quote') return quoteDraftAutomat;
|
||||||
if (kind === 'order') return orderDraftAutomat;
|
if (kind === 'order') return orderDraftAutomat;
|
||||||
|
if (kind === 'retoure') return retoureDraftAutomat;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,10 +461,10 @@ export function createManifestEditAutomat({ kind, name }) {
|
|||||||
shipments: doc.shipments || [],
|
shipments: doc.shipments || [],
|
||||||
payments: doc.payments || [],
|
payments: doc.payments || [],
|
||||||
shippings: doc.shippings || [],
|
shippings: doc.shippings || [],
|
||||||
orderTotal: doc.orderTotal ?? null,
|
orderTotal: doc.orderTotal ?? doc.grossTotal ?? doc.gross_total ?? null,
|
||||||
paidTotal: doc.paidTotal ?? null,
|
paidTotal: doc.paidTotal ?? doc.paid_total ?? null,
|
||||||
paid: Boolean(doc.paid),
|
paid: Boolean(doc.paid ?? doc.isPaid ?? doc.is_paid),
|
||||||
shipped: Boolean(doc.shipped),
|
shipped: Boolean(doc.shipped ?? doc.isShipped ?? doc.is_shipped),
|
||||||
delivered: Boolean(doc.delivered),
|
delivered: Boolean(doc.delivered),
|
||||||
baseline,
|
baseline,
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
@@ -605,13 +612,20 @@ export const orderEditAutomat = createManifestEditAutomat({
|
|||||||
name: 'order-edit',
|
name: 'order-edit',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** Shared singleton automat for the single last edited retoure. */
|
||||||
|
export const retoureEditAutomat = createManifestEditAutomat({
|
||||||
|
kind: 'retoure',
|
||||||
|
name: 'retoure-edit',
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the edit automat for a given manifest kind.
|
* Returns the edit automat for a given manifest kind.
|
||||||
* @param {'quote'|'order'} kind
|
* @param {'quote'|'order'|'retoure'} kind
|
||||||
* @returns {Automat|null}
|
* @returns {Automat|null}
|
||||||
*/
|
*/
|
||||||
export function getManifestEditAutomat(kind) {
|
export function getManifestEditAutomat(kind) {
|
||||||
if (kind === 'quote') return quoteEditAutomat;
|
if (kind === 'quote') return quoteEditAutomat;
|
||||||
if (kind === 'order') return orderEditAutomat;
|
if (kind === 'order') return orderEditAutomat;
|
||||||
|
if (kind === 'retoure') return retoureEditAutomat;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
1005
src/automats/retoureAutomat.js
Normal file
1005
src/automats/retoureAutomat.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -35,6 +35,7 @@ import supplierAutomat from './supplierAutomat';
|
|||||||
import deliveryAutomat from './deliveryAutomat';
|
import deliveryAutomat from './deliveryAutomat';
|
||||||
import orderAutomat from './orderAutomat';
|
import orderAutomat from './orderAutomat';
|
||||||
import quoteAutomat from './quoteAutomat';
|
import quoteAutomat from './quoteAutomat';
|
||||||
|
import retoureAutomat from './retoureAutomat';
|
||||||
import shipmentAutomat from './shipmentAutomat';
|
import shipmentAutomat from './shipmentAutomat';
|
||||||
import carrierAutomat from './carrierAutomat';
|
import carrierAutomat from './carrierAutomat';
|
||||||
|
|
||||||
@@ -282,6 +283,15 @@ function connect() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addTrackedListener(es, 'retoure', () => {
|
||||||
|
void retoureAutomat.actions.reload().catch((err) => {
|
||||||
|
console.error('[sse] retoure refresh failed', err);
|
||||||
|
});
|
||||||
|
void shipmentAutomat.actions.reload().catch((err) => {
|
||||||
|
console.error('[sse] shipment refresh failed', err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import entityAutomat from '../../automats/entityAutomat';
|
|||||||
import customergroupAutomat from '../../automats/customergroupAutomat';
|
import customergroupAutomat from '../../automats/customergroupAutomat';
|
||||||
import supplierAutomat from '../../automats/supplierAutomat';
|
import supplierAutomat from '../../automats/supplierAutomat';
|
||||||
import orderAutomat from '../../automats/orderAutomat';
|
import orderAutomat from '../../automats/orderAutomat';
|
||||||
|
import retoureAutomat from '../../automats/retoureAutomat';
|
||||||
import companyAutomat, { selectCompanyTaxrate } from '../../automats/companyAutomat';
|
import companyAutomat, { selectCompanyTaxrate } from '../../automats/companyAutomat';
|
||||||
import warehouseAutomat from '../../automats/warehouseAutomat';
|
import warehouseAutomat from '../../automats/warehouseAutomat';
|
||||||
import sseAutomat from '../../automats/sseAutomat';
|
import sseAutomat from '../../automats/sseAutomat';
|
||||||
@@ -46,6 +47,22 @@ import {
|
|||||||
getManifestEditAutomat,
|
getManifestEditAutomat,
|
||||||
} from '../../automats/manifestDraftAutomat';
|
} from '../../automats/manifestDraftAutomat';
|
||||||
|
|
||||||
|
export function computeDocGrossTotal(lines) {
|
||||||
|
if (!Array.isArray(lines)) return 0;
|
||||||
|
return lines.reduce((acc, line) => {
|
||||||
|
const amount = Number(line.amount ?? line.count) || 0;
|
||||||
|
if (line.gross != null && line.gross !== '') {
|
||||||
|
const g = Number(line.gross) || 0;
|
||||||
|
return acc + amount * g;
|
||||||
|
}
|
||||||
|
const net = Number(line.net ?? line.netprice ?? line.netPrice) || 0;
|
||||||
|
const tax = Number(line.tax ?? line.taxrate ?? line.taxRate) || 0;
|
||||||
|
const rebate = Number(line.rebate) || 0;
|
||||||
|
const lineNet = amount * net * (1 - rebate / 100);
|
||||||
|
return acc + lineNet * (1 + tax / 100);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
class ManifestForm extends PureComponent {
|
class ManifestForm extends PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -481,7 +498,7 @@ class ManifestForm extends PureComponent {
|
|||||||
|
|
||||||
let shipments = doc.shipments;
|
let shipments = doc.shipments;
|
||||||
let payments = doc.payments;
|
let payments = doc.payments;
|
||||||
if (kind === 'order') {
|
if (kind === 'order' || kind === 'retoure') {
|
||||||
if (!shipments) {
|
if (!shipments) {
|
||||||
try {
|
try {
|
||||||
const shRes = await shipmentApi.listByOrder(docId);
|
const shRes = await shipmentApi.listByOrder(docId);
|
||||||
@@ -512,6 +529,10 @@ class ManifestForm extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const linesGross = computeDocGrossTotal(lines);
|
||||||
|
const computedOrderTotal = doc.orderTotal ?? doc.grossTotal ?? doc.gross_total ?? (linesGross !== 0 ? linesGross : null);
|
||||||
|
const computedPaidTotal = doc.paidTotal ?? doc.paid_total ?? (Array.isArray(payments) && payments.length > 0 ? payments.reduce((acc, p) => acc + (Number(p.amount) || 0), 0) : null);
|
||||||
|
|
||||||
const loadedDoc = {
|
const loadedDoc = {
|
||||||
date: dateInputValue(doc.date),
|
date: dateInputValue(doc.date),
|
||||||
createdAt: doc.createdAt ?? doc.created_at ?? null,
|
createdAt: doc.createdAt ?? doc.created_at ?? null,
|
||||||
@@ -524,11 +545,11 @@ class ManifestForm extends PureComponent {
|
|||||||
shipments: shipments || [],
|
shipments: shipments || [],
|
||||||
payments: payments || [],
|
payments: payments || [],
|
||||||
shippings: doc.shippings || [],
|
shippings: doc.shippings || [],
|
||||||
orderTotal: doc.orderTotal ?? null,
|
orderTotal: computedOrderTotal,
|
||||||
paidTotal: doc.paidTotal ?? null,
|
paidTotal: computedPaidTotal,
|
||||||
paid: Boolean(doc.paid),
|
paid: Boolean(doc.paid ?? doc.isPaid ?? doc.is_paid),
|
||||||
shipped: Boolean(doc.shipped),
|
shipped: Boolean(doc.shipped ?? doc.isShipped ?? doc.is_shipped),
|
||||||
isShipped: Boolean(doc.isShipped ?? doc.shipped),
|
isShipped: Boolean(doc.isShipped ?? doc.shipped ?? doc.is_shipped),
|
||||||
delivered: Boolean(doc.delivered),
|
delivered: Boolean(doc.delivered),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1211,7 +1232,11 @@ class ManifestForm extends PureComponent {
|
|||||||
|
|
||||||
async handleShipmentCreated() {
|
async handleShipmentCreated() {
|
||||||
await this.loadEdit();
|
await this.loadEdit();
|
||||||
void orderAutomat.actions.reload();
|
if (this.props.kind === 'retoure') {
|
||||||
|
void retoureAutomat.actions.reload();
|
||||||
|
} else {
|
||||||
|
void orderAutomat.actions.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleAttachmentDelete(attachment) {
|
async handleAttachmentDelete(attachment) {
|
||||||
@@ -1315,12 +1340,21 @@ class ManifestForm extends PureComponent {
|
|||||||
attachments: this.state.attachments,
|
attachments: this.state.attachments,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const linesGross = computeDocGrossTotal(savedDoc.lines);
|
||||||
|
const savedDocWithTotals = {
|
||||||
|
...savedDoc,
|
||||||
|
orderTotal: doc.orderTotal ?? doc.grossTotal ?? doc.gross_total ?? this.state.orderTotal ?? (linesGross !== 0 ? linesGross : null),
|
||||||
|
paidTotal: doc.paidTotal ?? doc.paid_total ?? this.state.paidTotal ?? null,
|
||||||
|
shipments: this.state.shipments,
|
||||||
|
payments: this.state.payments,
|
||||||
|
};
|
||||||
|
|
||||||
if (this.editAutomat && String(this.editAutomat.state.id) === String(docId)) {
|
if (this.editAutomat && String(this.editAutomat.state.id) === String(docId)) {
|
||||||
this.editAutomat.actions.commitSaved(savedDoc);
|
this.editAutomat.actions.commitSaved(savedDocWithTotals);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
...savedDoc,
|
...savedDocWithTotals,
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
dirtyFields: null,
|
dirtyFields: null,
|
||||||
dirtyLineKeys: [],
|
dirtyLineKeys: [],
|
||||||
@@ -1430,8 +1464,8 @@ class ManifestForm extends PureComponent {
|
|||||||
onPdfDelete={this.handleAttachmentDelete}
|
onPdfDelete={this.handleAttachmentDelete}
|
||||||
onPdfCreate={kind === 'quote' || kind === 'order' ? this.handleCreatePdf : undefined}
|
onPdfCreate={kind === 'quote' || kind === 'order' ? this.handleCreatePdf : undefined}
|
||||||
onCreateOrder={kind === 'quote' && this.props.mode === 'edit' ? this.handleCreateOrder : undefined}
|
onCreateOrder={kind === 'quote' && this.props.mode === 'edit' ? this.handleCreateOrder : undefined}
|
||||||
onOpenCreateShipment={kind === 'order' && this.props.mode === 'edit' ? this.handleOpenCreateShipment : undefined}
|
onOpenCreateShipment={(kind === 'order' || kind === 'retoure') && this.props.mode === 'edit' ? this.handleOpenCreateShipment : undefined}
|
||||||
deliverDisabled={kind === 'order' && this.isFullyDelivered()}
|
deliverDisabled={(kind === 'order' || kind === 'retoure') && this.isFullyDelivered()}
|
||||||
onSave={this.handleSave}
|
onSave={this.handleSave}
|
||||||
onPartyChange={this.handlePartyChange}
|
onPartyChange={this.handlePartyChange}
|
||||||
onDateChange={this.handleDateChange}
|
onDateChange={this.handleDateChange}
|
||||||
@@ -1439,13 +1473,24 @@ class ManifestForm extends PureComponent {
|
|||||||
onExternalNumberChange={this.handleExternalNumberChange}
|
onExternalNumberChange={this.handleExternalNumberChange}
|
||||||
/>
|
/>
|
||||||
{status === 'ready' ? this.renderArticles() : null}
|
{status === 'ready' ? this.renderArticles() : null}
|
||||||
{status === 'ready' && kind === 'order' && this.props.mode === 'edit' ? (
|
{status === 'ready' && (kind === 'order' || kind === 'retoure') && this.props.mode === 'edit' ? (
|
||||||
<OrderDocumentsTiles
|
<OrderDocumentsTiles
|
||||||
|
kind={kind}
|
||||||
orderId={this.props.docId}
|
orderId={this.props.docId}
|
||||||
orderNumber={number}
|
orderNumber={number}
|
||||||
externalNumber={externalNumber}
|
externalNumber={externalNumber}
|
||||||
orderTotal={this.state.orderTotal}
|
orderTotal={
|
||||||
paidTotal={this.state.paidTotal}
|
this.state.orderTotal != null && Number(this.state.orderTotal) !== 0
|
||||||
|
? this.state.orderTotal
|
||||||
|
: computeDocGrossTotal(this.state.lines)
|
||||||
|
}
|
||||||
|
paidTotal={
|
||||||
|
this.state.paidTotal != null
|
||||||
|
? this.state.paidTotal
|
||||||
|
: (Array.isArray(this.state.payments) && this.state.payments.length > 0
|
||||||
|
? this.state.payments.reduce((acc, p) => acc + (Number(p.amount) || 0), 0)
|
||||||
|
: 0)
|
||||||
|
}
|
||||||
paid={this.state.paid}
|
paid={this.state.paid}
|
||||||
shipped={this.state.shipped}
|
shipped={this.state.shipped}
|
||||||
delivered={this.state.delivered}
|
delivered={this.state.delivered}
|
||||||
@@ -1482,6 +1527,7 @@ class ManifestForm extends PureComponent {
|
|||||||
<OrderShipmentDialog
|
<OrderShipmentDialog
|
||||||
open={this.state.shipmentDialogOpen}
|
open={this.state.shipmentDialogOpen}
|
||||||
onClose={this.handleCloseShipmentDialog}
|
onClose={this.handleCloseShipmentDialog}
|
||||||
|
kind={kind}
|
||||||
orderId={this.props.docId}
|
orderId={this.props.docId}
|
||||||
orderNumber={number}
|
orderNumber={number}
|
||||||
externalNumber={externalNumber}
|
externalNumber={externalNumber}
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ class ManifestLines extends PureComponent {
|
|||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
})()}
|
})()}
|
||||||
{(totalNet > 0 || totalGross > 0) && (
|
{(totalNet !== 0 || totalGross !== 0) && (
|
||||||
<Box sx={{ ml: 'auto', display: 'flex', alignItems: 'center', gap: 2, pr: 0.5 }}>
|
<Box sx={{ ml: 'auto', display: 'flex', alignItems: 'center', gap: 2, pr: 0.5 }}>
|
||||||
<Typography variant="body2" sx={{ color: 'text.secondary', fontWeight: 600, fontSize: '0.8rem' }}>
|
<Typography variant="body2" sx={{ color: 'text.secondary', fontWeight: 600, fontSize: '0.8rem' }}>
|
||||||
Netto:{' '}
|
Netto:{' '}
|
||||||
|
|||||||
@@ -11,10 +11,19 @@ import LocalShippingOutlinedIcon from '@mui/icons-material/LocalShippingOutlined
|
|||||||
import PaymentsOutlinedIcon from '@mui/icons-material/PaymentsOutlined';
|
import PaymentsOutlinedIcon from '@mui/icons-material/PaymentsOutlined';
|
||||||
import AddIcon from '@mui/icons-material/Add';
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
||||||
|
import DialogContent from '@mui/material/DialogContent';
|
||||||
|
import DialogActions from '@mui/material/DialogActions';
|
||||||
|
import DialogTitle from '@mui/material/DialogTitle';
|
||||||
|
import TextField from '@mui/material/TextField';
|
||||||
|
import MenuItem from '@mui/material/MenuItem';
|
||||||
|
import { enqueueSnackbar } from 'notistack';
|
||||||
import { PanelTile } from 'dashgui/panels';
|
import { PanelTile } from 'dashgui/panels';
|
||||||
import { formatDate, formatDateTime } from './manifestConfig';
|
import AppDialog from '../AppDialog';
|
||||||
|
import { payment as paymentApi } from '../../api';
|
||||||
|
import { notifyError } from '../../utils/notify';
|
||||||
|
import { formatDate, formatDateTime, todayInputValue } from './manifestConfig';
|
||||||
import { formatPrice } from '../../utils/price';
|
import { formatPrice } from '../../utils/price';
|
||||||
import { typeLabel, typeIcon } from './OrderPaymentList';
|
import { typeLabel, typeIcon, PAYMENT_TYPES } from './OrderPaymentList';
|
||||||
import ShipmentDetailDialog from './ShipmentDetailDialog';
|
import ShipmentDetailDialog from './ShipmentDetailDialog';
|
||||||
import {
|
import {
|
||||||
GREEN_PANEL,
|
GREEN_PANEL,
|
||||||
@@ -23,19 +32,81 @@ import {
|
|||||||
} from '../../colors';
|
} from '../../colors';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders 1-wide associated document tiles for an order in edit mode:
|
* Renders 1-wide associated document tiles for an order or retoure in edit mode:
|
||||||
* 1. Lieferscheine / Auslieferungen (Shipments)
|
* 1. Lieferscheine / Auslieferungen (Shipments)
|
||||||
* 2. Zahlungen (Payments)
|
* 2. Zahlungen / Erstattungen (Payments)
|
||||||
*/
|
*/
|
||||||
export class OrderDocumentsTiles extends PureComponent {
|
export class OrderDocumentsTiles extends PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedShipment: null,
|
selectedShipment: null,
|
||||||
|
paymentDialogOpen: false,
|
||||||
|
paymentAmount: '',
|
||||||
|
paymentType: 'cash',
|
||||||
|
paymentDate: todayInputValue(),
|
||||||
|
paymentSaving: false,
|
||||||
};
|
};
|
||||||
this.handleOpenShipment = this.handleOpenShipment.bind(this);
|
this.handleOpenShipment = this.handleOpenShipment.bind(this);
|
||||||
this.handleCloseShipment = this.handleCloseShipment.bind(this);
|
this.handleCloseShipment = this.handleCloseShipment.bind(this);
|
||||||
this.handleOpenPayments = this.handleOpenPayments.bind(this);
|
this.handleOpenPayments = this.handleOpenPayments.bind(this);
|
||||||
|
this.handleOpenPaymentDialog = this.handleOpenPaymentDialog.bind(this);
|
||||||
|
this.handleClosePaymentDialog = this.handleClosePaymentDialog.bind(this);
|
||||||
|
this.handleSubmitPayment = this.handleSubmitPayment.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOpenPaymentDialog() {
|
||||||
|
const { orderTotal, paidTotal, kind } = this.props;
|
||||||
|
const tot = Number(orderTotal) || 0;
|
||||||
|
const pd = Number(paidTotal) || 0;
|
||||||
|
const absTot = Math.abs(tot);
|
||||||
|
const absPd = Math.abs(pd);
|
||||||
|
const isPaid = Boolean(this.props.paid || (absTot > 0 && absPd >= absTot - 0.005));
|
||||||
|
const remaining = isPaid ? 0 : Math.max(0, absTot - absPd);
|
||||||
|
const defaultAmount = remaining > 0
|
||||||
|
? (kind === 'retoure' || tot < 0 ? -remaining : remaining)
|
||||||
|
: '';
|
||||||
|
this.setState({
|
||||||
|
paymentDialogOpen: true,
|
||||||
|
paymentAmount: defaultAmount !== '' ? String(Math.round(defaultAmount * 100) / 100) : '',
|
||||||
|
paymentType: 'cash',
|
||||||
|
paymentDate: todayInputValue(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClosePaymentDialog() {
|
||||||
|
this.setState({ paymentDialogOpen: false, paymentSaving: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleSubmitPayment(e) {
|
||||||
|
e?.preventDefault?.();
|
||||||
|
const { orderId, onShipmentChanged } = this.props;
|
||||||
|
const { paymentAmount, paymentType, paymentDate, paymentSaving } = this.state;
|
||||||
|
if (paymentSaving || !orderId) return;
|
||||||
|
|
||||||
|
const amt = Number(String(paymentAmount).replace(',', '.'));
|
||||||
|
if (Number.isNaN(amt) || amt === 0) {
|
||||||
|
enqueueSnackbar('Bitte einen gültigen Betrag ungleich 0 eingeben.', { variant: 'warning' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({ paymentSaving: true });
|
||||||
|
try {
|
||||||
|
await paymentApi.create({
|
||||||
|
manifestId: orderId,
|
||||||
|
amount: amt,
|
||||||
|
type: paymentType,
|
||||||
|
date: paymentDate || undefined,
|
||||||
|
});
|
||||||
|
enqueueSnackbar(amt < 0 ? 'Erstattung erfolgreich gebucht!' : 'Zahlung erfolgreich erfasst!', {
|
||||||
|
variant: 'success',
|
||||||
|
});
|
||||||
|
this.handleClosePaymentDialog();
|
||||||
|
onShipmentChanged?.();
|
||||||
|
} catch (err) {
|
||||||
|
notifyError(err);
|
||||||
|
this.setState({ paymentSaving: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleOpenShipment(sh) {
|
handleOpenShipment(sh) {
|
||||||
@@ -163,31 +234,53 @@ export class OrderDocumentsTiles extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderPaymentsTile() {
|
renderPaymentsTile() {
|
||||||
const { payments = [], paid, paidTotal, orderTotal } = this.props;
|
const { payments = [], paid, paidTotal, orderTotal, kind } = this.props;
|
||||||
|
const isRetoure = kind === 'retoure';
|
||||||
|
|
||||||
const tot = Number(orderTotal) || 0;
|
const tot = Number(orderTotal) || 0;
|
||||||
const pd = Number(paidTotal) || 0;
|
const pd = Number(paidTotal) || 0;
|
||||||
const openAmount = Math.max(0, tot - pd);
|
const absTot = Math.abs(tot);
|
||||||
|
const absPd = Math.abs(pd);
|
||||||
|
const isPaid = Boolean(paid || (absTot > 0 && absPd >= absTot - 0.005));
|
||||||
|
|
||||||
const isPaid = Boolean(paid || tot <= 0 || (tot > 0 && pd >= tot));
|
let openAmount = 0;
|
||||||
const statusLabel = isPaid ? 'Bezahlt' : pd > 0 ? 'Teilzahlung' : 'Offen';
|
if (!isPaid) {
|
||||||
const statusColor = isPaid ? 'success' : pd > 0 ? 'warning' : 'error';
|
const remaining = Math.max(0, absTot - absPd);
|
||||||
|
openAmount = tot < 0 ? -remaining : remaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusLabel = isPaid
|
||||||
|
? (isRetoure ? 'Erstattet' : 'Bezahlt')
|
||||||
|
: Math.abs(pd) > 0
|
||||||
|
? 'Teilzahlung'
|
||||||
|
: 'Offen';
|
||||||
|
const statusColor = isPaid ? 'success' : Math.abs(pd) > 0 ? 'warning' : 'error';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PanelTile wide={1} minHeight={220} color={YELLOW_PANEL} title="Zahlungen">
|
<PanelTile wide={1} minHeight={220} color={YELLOW_PANEL} title={isRetoure ? 'Erstattungen / Zahlungen' : 'Zahlungen'}>
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1.5 }}>
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1.5 }}>
|
||||||
<Stack direction="row" spacing={0.75} sx={{ alignItems: 'center' }}>
|
<Stack direction="row" spacing={0.75} sx={{ alignItems: 'center' }}>
|
||||||
<PaymentsOutlinedIcon sx={{ fontSize: 20, color: 'text.secondary' }} />
|
<PaymentsOutlinedIcon sx={{ fontSize: 20, color: 'text.secondary' }} />
|
||||||
<Chip size="small" label={statusLabel} color={statusColor} sx={{ fontWeight: 600, height: 22 }} />
|
<Chip size="small" label={statusLabel} color={statusColor} sx={{ fontWeight: 600, height: 22 }} />
|
||||||
</Stack>
|
</Stack>
|
||||||
<Button
|
<Box sx={{ display: 'flex', gap: 0.5 }}>
|
||||||
size="small"
|
<Button
|
||||||
variant="outlined"
|
size="small"
|
||||||
onClick={this.handleOpenPayments}
|
variant="contained"
|
||||||
sx={{ fontWeight: 600, textTransform: 'none', height: 26, fontSize: '0.75rem', px: 1 }}
|
onClick={this.handleOpenPaymentDialog}
|
||||||
>
|
sx={{ fontWeight: 600, textTransform: 'none', height: 26, fontSize: '0.75rem', px: 1 }}
|
||||||
Zahlungen
|
>
|
||||||
</Button>
|
{isRetoure ? '+ Erstattung' : '+ Zahlung'}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
onClick={this.handleOpenPayments}
|
||||||
|
sx={{ fontWeight: 600, textTransform: 'none', height: 26, fontSize: '0.75rem', px: 1 }}
|
||||||
|
>
|
||||||
|
Journal
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{/* Financial KPI Card */}
|
{/* Financial KPI Card */}
|
||||||
@@ -203,7 +296,7 @@ export class OrderDocumentsTiles extends PureComponent {
|
|||||||
>
|
>
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.25 }}>
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.25 }}>
|
||||||
<Typography variant="caption" color="text.secondary">
|
<Typography variant="caption" color="text.secondary">
|
||||||
Summe:
|
{isRetoure ? 'Gutschrift / Summe:' : 'Summe:'}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="caption" sx={{ fontWeight: 700 }}>
|
<Typography variant="caption" sx={{ fontWeight: 700 }}>
|
||||||
{formatPrice(tot)}
|
{formatPrice(tot)}
|
||||||
@@ -211,7 +304,7 @@ export class OrderDocumentsTiles extends PureComponent {
|
|||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.25 }}>
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.25 }}>
|
||||||
<Typography variant="caption" color="text.secondary">
|
<Typography variant="caption" color="text.secondary">
|
||||||
Bezahlt:
|
{isRetoure ? 'Erstattet:' : 'Bezahlt:'}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="caption" sx={{ fontWeight: 700, color: 'success.main' }}>
|
<Typography variant="caption" sx={{ fontWeight: 700, color: 'success.main' }}>
|
||||||
{formatPrice(pd)}
|
{formatPrice(pd)}
|
||||||
@@ -222,7 +315,7 @@ export class OrderDocumentsTiles extends PureComponent {
|
|||||||
<Typography variant="caption" color="text.secondary">
|
<Typography variant="caption" color="text.secondary">
|
||||||
Offen:
|
Offen:
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="caption" sx={{ fontWeight: 700, color: openAmount > 0 ? 'error.main' : 'text.secondary' }}>
|
<Typography variant="caption" sx={{ fontWeight: 700, color: openAmount !== 0 ? 'error.main' : 'text.secondary' }}>
|
||||||
{formatPrice(openAmount)}
|
{formatPrice(openAmount)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -233,6 +326,8 @@ export class OrderDocumentsTiles extends PureComponent {
|
|||||||
{payments.map((pay) => {
|
{payments.map((pay) => {
|
||||||
const pType = pay.type || pay.paymentType || pay.payment_type;
|
const pType = pay.type || pay.paymentType || pay.payment_type;
|
||||||
const payDate = pay.date || pay.createdAt || pay.created_at || pay.timestamp;
|
const payDate = pay.date || pay.createdAt || pay.created_at || pay.timestamp;
|
||||||
|
const pAmt = Number(pay.amount) || 0;
|
||||||
|
const isRefund = pAmt < 0;
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={pay.id}
|
key={pay.id}
|
||||||
@@ -261,9 +356,15 @@ export class OrderDocumentsTiles extends PureComponent {
|
|||||||
|
|
||||||
<Typography
|
<Typography
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
sx={{ fontWeight: 700, color: 'success.dark', fontVariantNumeric: 'tabular-nums', flexShrink: 0, ml: 1 }}
|
sx={{
|
||||||
|
fontWeight: 700,
|
||||||
|
color: isRefund ? 'error.main' : 'success.dark',
|
||||||
|
fontVariantNumeric: 'tabular-nums',
|
||||||
|
flexShrink: 0,
|
||||||
|
ml: 1,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
+{formatPrice(pay.amount)}
|
{isRefund ? formatPrice(pAmt) : `+${formatPrice(pAmt)}`}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
@@ -289,6 +390,9 @@ export class OrderDocumentsTiles extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { kind } = this.props;
|
||||||
|
const isRetoure = kind === 'retoure';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{this.renderShipmentsTile()}
|
{this.renderShipmentsTile()}
|
||||||
@@ -300,6 +404,56 @@ export class OrderDocumentsTiles extends PureComponent {
|
|||||||
onNavigate={this.props.navigate}
|
onNavigate={this.props.navigate}
|
||||||
onChanged={this.props.onShipmentChanged}
|
onChanged={this.props.onShipmentChanged}
|
||||||
/>
|
/>
|
||||||
|
<AppDialog
|
||||||
|
open={this.state.paymentDialogOpen}
|
||||||
|
onClose={this.handleClosePaymentDialog}
|
||||||
|
title={isRetoure ? 'Erstattung buchen' : 'Zahlung erfassen'}
|
||||||
|
>
|
||||||
|
<Box component="form" onSubmit={this.handleSubmitPayment} sx={{ p: 2, display: 'flex', flexDirection: 'column', gap: 2 }}>
|
||||||
|
<TextField
|
||||||
|
label="Betrag (€)"
|
||||||
|
type="text"
|
||||||
|
autoFocus
|
||||||
|
value={this.state.paymentAmount}
|
||||||
|
onChange={(e) => this.setState({ paymentAmount: e.target.value })}
|
||||||
|
helperText={isRetoure ? 'Negative Beträge für Gutschrift/Erstattung (z.B. -50.00)' : 'Zahlungsbetrag'}
|
||||||
|
fullWidth
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
label="Zahlungsart"
|
||||||
|
value={this.state.paymentType}
|
||||||
|
onChange={(e) => this.setState({ paymentType: e.target.value })}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
{PAYMENT_TYPES.map((t) => (
|
||||||
|
<MenuItem key={t.value} value={t.value}>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||||
|
{typeIcon(t.value, { fontSize: 18 })}
|
||||||
|
<span>{t.label}</span>
|
||||||
|
</Box>
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</TextField>
|
||||||
|
<TextField
|
||||||
|
label="Datum"
|
||||||
|
type="date"
|
||||||
|
value={this.state.paymentDate}
|
||||||
|
onChange={(e) => this.setState({ paymentDate: e.target.value })}
|
||||||
|
slotProps={{ inputLabel: { shrink: true } }}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: 1, mt: 1 }}>
|
||||||
|
<Button onClick={this.handleClosePaymentDialog} disabled={this.state.paymentSaving}>
|
||||||
|
Abbrechen
|
||||||
|
</Button>
|
||||||
|
<Button type="submit" variant="contained" disabled={this.state.paymentSaving}>
|
||||||
|
{this.state.paymentSaving ? 'Bucht…' : 'Buchen'}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</AppDialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import LocalShippingOutlinedIcon from '@mui/icons-material/LocalShippingOutlined
|
|||||||
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
|
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
|
||||||
import { enqueueSnackbar } from 'notistack';
|
import { enqueueSnackbar } from 'notistack';
|
||||||
import AppDialog from '../AppDialog';
|
import AppDialog from '../AppDialog';
|
||||||
import { order as orderApi } from '../../api';
|
import { order as orderApi, retoure as retoureApi } from '../../api';
|
||||||
import { notifyError } from '../../utils/notify';
|
import { notifyError } from '../../utils/notify';
|
||||||
import { formatStock } from '../article/searchFormat';
|
import { formatStock } from '../article/searchFormat';
|
||||||
import artikelAutomat, { getArticle } from '../../automats/artikelAutomat';
|
import artikelAutomat, { getArticle } from '../../automats/artikelAutomat';
|
||||||
@@ -364,7 +364,9 @@ export default class OrderShipmentDialog extends PureComponent {
|
|||||||
lines: linesToShip,
|
lines: linesToShip,
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await orderApi.createShipment(orderId, payload);
|
const res = this.props.kind === 'retoure'
|
||||||
|
? await retoureApi.createShipment(orderId, payload)
|
||||||
|
: await orderApi.createShipment(orderId, payload);
|
||||||
const shipment = res?.shipment;
|
const shipment = res?.shipment;
|
||||||
const shNum = shipment?.number || '';
|
const shNum = shipment?.number || '';
|
||||||
|
|
||||||
@@ -380,7 +382,7 @@ export default class OrderShipmentDialog extends PureComponent {
|
|||||||
this.setState({ saving: false, error: err?.message || String(err) });
|
this.setState({ saving: false, error: err?.message || String(err) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // MARK: calls orderApi.createShipment to ship all remaining lines
|
// // MARK: calls orderApi/retoureApi.createShipment to ship all remaining lines
|
||||||
// #region POST /api/order/:id/shipment — ship all remaining
|
// #region POST /api/order/:id/shipment — ship all remaining
|
||||||
async handleShipAll() {
|
async handleShipAll() {
|
||||||
const { orderId, onClose, onSuccess } = this.props;
|
const { orderId, onClose, onSuccess } = this.props;
|
||||||
@@ -394,7 +396,9 @@ export default class OrderShipmentDialog extends PureComponent {
|
|||||||
externalNumber: externalNumber.trim() || undefined,
|
externalNumber: externalNumber.trim() || undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await orderApi.createShipment(orderId, payload);
|
const res = this.props.kind === 'retoure'
|
||||||
|
? await retoureApi.createShipment(orderId, payload)
|
||||||
|
: await orderApi.createShipment(orderId, payload);
|
||||||
const shipment = res?.shipment;
|
const shipment = res?.shipment;
|
||||||
const shNum = shipment?.number || '';
|
const shNum = shipment?.number || '';
|
||||||
|
|
||||||
|
|||||||
852
src/components/manifest/RetoureList.jsx
Normal file
852
src/components/manifest/RetoureList.jsx
Normal file
@@ -0,0 +1,852 @@
|
|||||||
|
import { PureComponent, createRef } from 'react';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
|
import Chip from '@mui/material/Chip';
|
||||||
|
import CircularProgress from '@mui/material/CircularProgress';
|
||||||
|
import Divider from '@mui/material/Divider';
|
||||||
|
import FormControlLabel from '@mui/material/FormControlLabel';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import ListItemButton from '@mui/material/ListItemButton';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
|
import Checkbox from '@mui/material/Checkbox';
|
||||||
|
import Switch from '@mui/material/Switch';
|
||||||
|
import Skeleton from '@mui/material/Skeleton';
|
||||||
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
|
import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
|
||||||
|
import ViewModuleIcon from '@mui/icons-material/ViewModule';
|
||||||
|
import PaymentsOutlinedIcon from '@mui/icons-material/PaymentsOutlined';
|
||||||
|
import LocalShippingOutlinedIcon from '@mui/icons-material/LocalShippingOutlined';
|
||||||
|
import { enqueueSnackbar } from 'notistack';
|
||||||
|
import SingleLineTextEdit from 'dashgui/SingleLineTextEdit';
|
||||||
|
import FillSpace from 'dashgui/FillSpace';
|
||||||
|
import { PanelTile, PanelTileGrid } from 'dashgui/panels';
|
||||||
|
import BackendError from '../BackendError';
|
||||||
|
import retoureAutomat, {
|
||||||
|
CHUNK_SIZE,
|
||||||
|
isRetourePaid,
|
||||||
|
isRetoureShipped,
|
||||||
|
} from '../../automats/retoureAutomat';
|
||||||
|
import numberAutomat from '../../automats/numberAutomat';
|
||||||
|
import { retoure as retoureApi } from '../../api';
|
||||||
|
import { backendErrorFrom } from '../../utils/backendError';
|
||||||
|
import { notifyError } from '../../utils/notify';
|
||||||
|
import { formatPrice } from '../../utils/price';
|
||||||
|
import { getMaxDocumentNumber } from '../../utils/documentNumber';
|
||||||
|
import PartyFilterPanel, { PartyFilterButton, PartyFilterChip } from './PartyFilterPanel';
|
||||||
|
import withNavigate from '../withNavigate';
|
||||||
|
import {
|
||||||
|
formatDate,
|
||||||
|
loadParties,
|
||||||
|
manifestConfig,
|
||||||
|
numberDisplay,
|
||||||
|
partyDisplayName,
|
||||||
|
} from './manifestConfig';
|
||||||
|
|
||||||
|
// MARK: pure helpers
|
||||||
|
function retoureGrossTotal(lines) {
|
||||||
|
if (!Array.isArray(lines)) return 0;
|
||||||
|
return lines.reduce((acc, line) => {
|
||||||
|
const net = (Number(line.amount) || 0) * (Number(line.net) || 0) * (1 - (Number(line.rebate) || 0) / 100);
|
||||||
|
return acc + net * (1 + (Number(line.taxrate) || 0) / 100);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const cfg = manifestConfig('retoure');
|
||||||
|
|
||||||
|
// Dummy retoure generator using the active sequence scheme with max digits for layout testing
|
||||||
|
export function createDummyTestRetoure() {
|
||||||
|
const maxNumber = getMaxDocumentNumber('retoure');
|
||||||
|
return {
|
||||||
|
id: 999999,
|
||||||
|
number: maxNumber,
|
||||||
|
externalNumber: 'REF-999999',
|
||||||
|
date: '2030-10-30T12:00:00Z',
|
||||||
|
customerName: 'Kunde',
|
||||||
|
positions: 999,
|
||||||
|
grossTotal: -30000.90,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const rowGridSx = {
|
||||||
|
display: 'grid',
|
||||||
|
gridTemplateColumns: 'max-content max-content 1fr max-content max-content max-content max-content auto',
|
||||||
|
gridTemplateRows: '0px 1fr',
|
||||||
|
rowGap: 0,
|
||||||
|
columnGap: 1.5,
|
||||||
|
alignItems: 'center',
|
||||||
|
width: '100%',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
};
|
||||||
|
|
||||||
|
const ellipsisSx = { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' };
|
||||||
|
|
||||||
|
const measuringCellSx = {
|
||||||
|
visibility: 'hidden',
|
||||||
|
height: 0,
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
pointerEvents: 'none',
|
||||||
|
textTransform: 'none',
|
||||||
|
letterSpacing: 'normal',
|
||||||
|
};
|
||||||
|
|
||||||
|
const headerCellSx = {
|
||||||
|
color: 'text.secondary',
|
||||||
|
typography: 'caption',
|
||||||
|
fontWeight: 600,
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
letterSpacing: '0.04em',
|
||||||
|
userSelect: 'none',
|
||||||
|
};
|
||||||
|
|
||||||
|
function renderInvisibleDummyRow(dummy) {
|
||||||
|
const d = dummy || createDummyTestRetoure();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Box aria-hidden sx={{ gridColumn: 1, gridRow: 1, whiteSpace: 'nowrap', ...measuringCellSx }}>
|
||||||
|
<Typography variant="body1" sx={{ fontWeight: 600, fontFamily: 'monospace' }}>{d.number}</Typography>
|
||||||
|
<Typography variant="body2" sx={{ fontFamily: 'monospace' }}>{d.externalNumber || 'Nr. / Ref.'}</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box aria-hidden sx={{ gridColumn: 2, gridRow: 1, whiteSpace: 'nowrap', ...measuringCellSx }}>
|
||||||
|
<Typography variant="body2">{d.date ? formatDate(d.date) : '–'}</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box aria-hidden sx={{ gridColumn: 3, gridRow: 1, whiteSpace: 'nowrap', ...measuringCellSx }}>
|
||||||
|
<Typography variant="body1">{d.customerName}</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box aria-hidden sx={{ gridColumn: 4, gridRow: 1, display: 'flex', justifyContent: 'center', ...measuringCellSx }}>
|
||||||
|
<Checkbox size="small" sx={{ p: 0.5 }} />
|
||||||
|
</Box>
|
||||||
|
<Box aria-hidden sx={{ gridColumn: 5, gridRow: 1, display: 'flex', justifyContent: 'center', ...measuringCellSx }}>
|
||||||
|
<Checkbox size="small" sx={{ p: 0.5 }} />
|
||||||
|
</Box>
|
||||||
|
<Box aria-hidden sx={{ gridColumn: 6, gridRow: 1, display: 'flex', justifyContent: 'center', ...measuringCellSx }}>
|
||||||
|
<Chip size="small" label={d.positions} sx={{ height: 24, '& .MuiChip-label': { px: 0.5 } }} />
|
||||||
|
</Box>
|
||||||
|
<Box aria-hidden sx={{ gridColumn: 7, gridRow: 1, whiteSpace: 'nowrap', display: 'flex', justifyContent: 'flex-end', ...measuringCellSx }}>
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: 600, fontVariantNumeric: 'tabular-nums' }}>
|
||||||
|
{formatPrice(d.grossTotal)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box aria-hidden sx={{ gridColumn: 8, gridRow: 1, display: 'flex', justifyContent: 'center', ...measuringCellSx }}>
|
||||||
|
<IconButton sx={{ width: 40, height: 40 }} />
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ambient context for `RetoureRow`: FillSpace renders rows as bare elements
|
||||||
|
* (`<Row item index />`), so the list publishes callbacks and the party map
|
||||||
|
* here on every render.
|
||||||
|
*/
|
||||||
|
const rowContext = {
|
||||||
|
partiesById: {},
|
||||||
|
busyId: null,
|
||||||
|
onOpen: null,
|
||||||
|
onDelete: null,
|
||||||
|
onTogglePaid: null,
|
||||||
|
onToggleShipped: null,
|
||||||
|
headerItem: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
// MARK: <RetoureRow/>
|
||||||
|
class RetoureRow extends PureComponent {
|
||||||
|
partyName(partyId, fallbackName) {
|
||||||
|
if (partyId == null) return fallbackName || '–';
|
||||||
|
const party = rowContext.partiesById[partyId];
|
||||||
|
return partyDisplayName('retoure', party) || fallbackName || `Kunde #${partyId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { item: retoure, disabled } = this.props;
|
||||||
|
const dummy = this.props.headerItem || rowContext.headerItem;
|
||||||
|
|
||||||
|
// Data-free probe (FillSpace measures the row height with `item` undefined).
|
||||||
|
if (!retoure) {
|
||||||
|
if (disabled) {
|
||||||
|
return (
|
||||||
|
<ListItemButton disabled divider sx={{ ...rowGridSx, height: 64, minHeight: 64, maxHeight: 64, px: 2, py: 0, opacity: 0, pointerEvents: 'none' }}>
|
||||||
|
<Typography variant="body2"> </Typography>
|
||||||
|
</ListItemButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<ListItemButton disabled divider sx={{ ...rowGridSx, height: 64, minHeight: 64, maxHeight: 64, px: 2, py: 0 }}>
|
||||||
|
{renderInvisibleDummyRow(dummy)}
|
||||||
|
<Box sx={{ gridColumn: 1, gridRow: 2 }}><Skeleton variant="text" width="90%" height={20} /></Box>
|
||||||
|
<Box sx={{ gridColumn: 2, gridRow: 2 }}><Skeleton variant="text" width="90%" height={20} /></Box>
|
||||||
|
<Box sx={{ gridColumn: 3, gridRow: 2 }}><Skeleton variant="text" width="60%" height={20} /></Box>
|
||||||
|
<Box sx={{ gridColumn: 4, gridRow: 2, display: 'flex', justifyContent: 'center' }}><Skeleton variant="circular" width={20} height={20} /></Box>
|
||||||
|
<Box sx={{ gridColumn: 5, gridRow: 2, display: 'flex', justifyContent: 'center' }}><Skeleton variant="circular" width={20} height={20} /></Box>
|
||||||
|
<Box sx={{ gridColumn: 6, gridRow: 2, display: 'flex', justifyContent: 'center' }}><Skeleton variant="rounded" width={28} height={20} /></Box>
|
||||||
|
<Box sx={{ gridColumn: 7, gridRow: 2, display: 'flex', justifyContent: 'flex-end' }}><Skeleton variant="text" width="80%" height={20} /></Box>
|
||||||
|
<Box sx={{ gridColumn: 8, gridRow: 2 }} />
|
||||||
|
</ListItemButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { busyId, onOpen, onDelete, onTogglePaid, onToggleShipped } = rowContext;
|
||||||
|
const lines = retoure.lines ?? [];
|
||||||
|
const positions = retoure.positions ?? lines.length;
|
||||||
|
const gross = retoure.gross_total ?? retoure.grossTotal ?? (lines.length > 0 ? retoureGrossTotal(lines) : 0);
|
||||||
|
const paid = isRetourePaid(retoure);
|
||||||
|
const shipped = isRetoureShipped(retoure);
|
||||||
|
const num = retoure.number ?? retoure.retoure_number ?? `RET-${retoure.id}`;
|
||||||
|
const dt = retoure.date ?? retoure.retoure_date;
|
||||||
|
const entityId = retoure.entityId ?? retoure.entity_id;
|
||||||
|
const customer = this.partyName(entityId, retoure.customerName ?? retoure.customer_name);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ListItemButton
|
||||||
|
divider
|
||||||
|
sx={{ ...rowGridSx, height: 64, minHeight: 64, maxHeight: 64, px: 2, py: 0 }}
|
||||||
|
onClick={disabled ? undefined : () => onOpen?.(retoure)}
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
{renderInvisibleDummyRow(dummy)}
|
||||||
|
|
||||||
|
<Box sx={{ gridColumn: 1, gridRow: 2, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||||
|
<Typography variant="body1" sx={{ fontWeight: 600, fontFamily: 'monospace', ...ellipsisSx }}>
|
||||||
|
{num}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" color="text.secondary" sx={{ fontFamily: 'monospace', ...ellipsisSx }}>
|
||||||
|
{numberDisplay(retoure.externalNumber)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ gridColumn: 2, gridRow: 2, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||||
|
<Typography variant="body2" color="text.secondary" sx={ellipsisSx}>
|
||||||
|
{dt ? formatDate(dt) : '–'}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ gridColumn: 3, gridRow: 2, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||||
|
<Typography variant="body1" sx={{ fontWeight: 500, ...ellipsisSx }}>
|
||||||
|
{customer}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ gridColumn: 4, gridRow: 2, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
<Checkbox
|
||||||
|
size="small"
|
||||||
|
checked={paid}
|
||||||
|
color="success"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
onChange={(e) => onTogglePaid?.(retoure, e.target.checked)}
|
||||||
|
slotProps={{ input: { 'aria-label': `Retoure ${num} bezahlt` } }}
|
||||||
|
sx={{ p: 0.5 }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ gridColumn: 5, gridRow: 2, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
<Checkbox
|
||||||
|
size="small"
|
||||||
|
checked={shipped}
|
||||||
|
color="primary"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
onChange={(e) => onToggleShipped?.(retoure, e.target.checked)}
|
||||||
|
slotProps={{ input: { 'aria-label': `Retoure ${num} geliefert` } }}
|
||||||
|
sx={{ p: 0.5 }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ gridColumn: 6, gridRow: 2, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
<Chip
|
||||||
|
size="small"
|
||||||
|
label={positions}
|
||||||
|
title={`${positions} Positionen`}
|
||||||
|
sx={{
|
||||||
|
height: 24,
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
fontVariantNumeric: 'tabular-nums',
|
||||||
|
bgcolor: 'action.hover',
|
||||||
|
color: positions > 0 ? 'text.primary' : 'text.disabled',
|
||||||
|
'& .MuiChip-label': { px: 0.5 },
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ gridColumn: 7, gridRow: 2, display: 'flex', justifyContent: 'flex-end' }}>
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{ fontWeight: 600, fontVariantNumeric: 'tabular-nums', textAlign: 'right', whiteSpace: 'nowrap' }}
|
||||||
|
>
|
||||||
|
{gross !== 0 ? formatPrice(gross) : '—'}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ gridColumn: 8, gridRow: 2, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
<IconButton
|
||||||
|
aria-label={`„${num}“ löschen`}
|
||||||
|
disabled={busyId != null || disabled}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
onDelete?.(retoure);
|
||||||
|
}}
|
||||||
|
onMouseDown={(e) => e.stopPropagation()}
|
||||||
|
sx={{ width: 40, height: 40 }}
|
||||||
|
>
|
||||||
|
<DeleteOutlinedIcon sx={{ fontSize: 24 }} />
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
</ListItemButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: <RetoureSearchField/>
|
||||||
|
class RetoureSearchField extends PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
const s = retoureAutomat.state;
|
||||||
|
const stats = retoureAutomat.getChunkStats?.();
|
||||||
|
this.state = {
|
||||||
|
input: s.filter ?? '',
|
||||||
|
onlyUnpaid: s.onlyUnpaid ?? false,
|
||||||
|
onlyUndelivered: s.onlyUndelivered ?? false,
|
||||||
|
seekMonths: s.seekMonths ?? 0,
|
||||||
|
seekYears: s.seekYears ?? 0,
|
||||||
|
negativeSeekMonths: s.negativeSeekMonths ?? 0,
|
||||||
|
lruChunksCount: stats?.lruChunksCount || 0,
|
||||||
|
maxLruChunks: stats?.maxLruChunks || 50,
|
||||||
|
filterCachesCount: stats?.filterCaches?.length || 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.unsub = retoureAutomat.subscribe(this, (state) => ({
|
||||||
|
input: state.filter ?? '',
|
||||||
|
onlyUnpaid: state.onlyUnpaid ?? false,
|
||||||
|
onlyUndelivered: state.onlyUndelivered ?? false,
|
||||||
|
seekMonths: state.seekMonths ?? 0,
|
||||||
|
seekYears: state.seekYears ?? 0,
|
||||||
|
negativeSeekMonths: state.negativeSeekMonths ?? 0,
|
||||||
|
}));
|
||||||
|
if (import.meta.env.DEV) {
|
||||||
|
this.unsubStats = retoureAutomat.subscribeChunkStats?.((stats) => {
|
||||||
|
this.setState({
|
||||||
|
lruChunksCount: stats.lruChunksCount,
|
||||||
|
maxLruChunks: stats.maxLruChunks,
|
||||||
|
filterCachesCount: stats.filterCaches?.length || 1,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.unsub?.();
|
||||||
|
this.unsubStats?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
inputRef,
|
||||||
|
onCreate,
|
||||||
|
customerFilterOpen,
|
||||||
|
onToggleCustomerFilter,
|
||||||
|
selectedCustomer,
|
||||||
|
onClearCustomerFilter,
|
||||||
|
} = this.props;
|
||||||
|
const { input, onlyUnpaid, onlyUndelivered, seekMonths, seekYears } = this.state;
|
||||||
|
const monthActive = seekMonths > 0;
|
||||||
|
const monthLabel = !monthActive ? '-1 Month' : `-${seekMonths} Month${seekMonths > 1 ? 's' : ''}`;
|
||||||
|
const yearActive = seekYears > 0;
|
||||||
|
const yearLabel = !yearActive ? '-1 Year' : `-${seekYears} Year${seekYears > 1 ? 's' : ''}`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PanelTileGrid>
|
||||||
|
<Box
|
||||||
|
ref={inputRef}
|
||||||
|
sx={{
|
||||||
|
gridColumn: { xs: '1 / -1', sm: 'span 2', md: 'span 2' },
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: 1.25,
|
||||||
|
pb: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Top row: search field, customer filter button, active chip & create button */}
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 1,
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SingleLineTextEdit
|
||||||
|
sx={{ flex: 1, minWidth: { xs: '100%', sm: 220 } }}
|
||||||
|
size="small"
|
||||||
|
search
|
||||||
|
clear
|
||||||
|
value={input}
|
||||||
|
onChange={(next) => retoureAutomat.actions.filter(next)}
|
||||||
|
/>
|
||||||
|
<PartyFilterButton
|
||||||
|
title="Kunden"
|
||||||
|
open={customerFilterOpen}
|
||||||
|
onClick={onToggleCustomerFilter}
|
||||||
|
/>
|
||||||
|
{selectedCustomer && (
|
||||||
|
<PartyFilterChip
|
||||||
|
label={partyDisplayName('retoure', selectedCustomer)}
|
||||||
|
onDelete={onClearCustomerFilter}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Button variant="contained" onClick={onCreate}>
|
||||||
|
{cfg.createButton}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* Filter Bar: "Nur ungezahlte", "Nur ungelieferte", Negativeseek (-1 Month, -1 Year, Reset) */}
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: 1.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Left: Unpaid & Undelivered toggles */}
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: 'inline-flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 1.5,
|
||||||
|
px: 1.5,
|
||||||
|
py: 0.25,
|
||||||
|
borderRadius: 2,
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
boxShadow: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
size="small"
|
||||||
|
color="warning"
|
||||||
|
checked={onlyUnpaid}
|
||||||
|
onChange={(e) => retoureAutomat.actions.setOnlyUnpaid(e.target.checked)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: onlyUnpaid ? 600 : 400, userSelect: 'none' }}>
|
||||||
|
Nur unerstattete
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
sx={{ m: 0 }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Divider orientation="vertical" flexItem sx={{ my: 0.5 }} />
|
||||||
|
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
size="small"
|
||||||
|
color="primary"
|
||||||
|
checked={onlyUndelivered}
|
||||||
|
onChange={(e) => retoureAutomat.actions.setOnlyUndelivered(e.target.checked)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: onlyUndelivered ? 600 : 400, userSelect: 'none' }}>
|
||||||
|
Nur offene
|
||||||
|
</Typography>
|
||||||
|
}
|
||||||
|
sx={{ m: 0 }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* Right: Negativeseek controls (-1 Month, -1 Year, Reset) */}
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, flexWrap: 'wrap' }}>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: 'inline-flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 0.75,
|
||||||
|
px: 1.25,
|
||||||
|
py: 0.25,
|
||||||
|
borderRadius: 2,
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
boxShadow: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant={monthActive ? 'contained' : 'outlined'}
|
||||||
|
color={monthActive ? 'primary' : 'inherit'}
|
||||||
|
onClick={() => retoureAutomat.actions.addSeekMonth()}
|
||||||
|
sx={{
|
||||||
|
minWidth: 88,
|
||||||
|
px: 1.25,
|
||||||
|
py: 0.25,
|
||||||
|
height: 28,
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
textTransform: 'none',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
border: '1px solid',
|
||||||
|
borderColor: monthActive ? 'primary.main' : 'divider',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{monthLabel}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant={yearActive ? 'contained' : 'outlined'}
|
||||||
|
color={yearActive ? 'primary' : 'inherit'}
|
||||||
|
onClick={() => retoureAutomat.actions.addSeekYear()}
|
||||||
|
sx={{
|
||||||
|
minWidth: 78,
|
||||||
|
px: 1.25,
|
||||||
|
py: 0.25,
|
||||||
|
height: 28,
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
textTransform: 'none',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
border: '1px solid',
|
||||||
|
borderColor: yearActive ? 'primary.main' : 'divider',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{yearLabel}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="text"
|
||||||
|
color="inherit"
|
||||||
|
disabled={!monthActive && !yearActive}
|
||||||
|
onClick={() => retoureAutomat.actions.resetNegativeSeek()}
|
||||||
|
sx={{
|
||||||
|
minWidth: 'auto',
|
||||||
|
px: 1,
|
||||||
|
py: 0.25,
|
||||||
|
height: 28,
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
textTransform: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Reset
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{import.meta.env.DEV && (
|
||||||
|
<Tooltip title={`Chunk-Cache-Monitor öffnen (Alt+Shift+C) — ${this.state.lruChunksCount || 0}/${this.state.maxLruChunks || 50} Chunks im RAM über ${this.state.filterCachesCount || 1} Filter`}>
|
||||||
|
<Chip
|
||||||
|
size="small"
|
||||||
|
icon={<ViewModuleIcon sx={{ fontSize: 16 }} />}
|
||||||
|
label={this.state.lruChunksCount > 0 ? `Chunk-Cache (${this.state.lruChunksCount}/${this.state.maxLruChunks || 50})` : 'Chunk-Cache'}
|
||||||
|
onClick={() => window.dispatchEvent(new CustomEvent('dash:toggle-chunk-monitor'))}
|
||||||
|
sx={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
height: 28,
|
||||||
|
fontWeight: 600,
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
bgcolor: 'background.paper',
|
||||||
|
boxShadow: 1,
|
||||||
|
'&:hover': { bgcolor: 'action.hover' },
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</PanelTileGrid>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: <RetoureList/>
|
||||||
|
export class RetoureList extends PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.headerItem = createDummyTestRetoure();
|
||||||
|
// getItems() returns current items or null and triggers loading of the first chunk
|
||||||
|
this.state = {
|
||||||
|
items: retoureAutomat.getItems(),
|
||||||
|
unfilteredTotal: retoureAutomat.state.unfilteredTotal ?? 0,
|
||||||
|
filterKey: retoureAutomat.getFilterKey?.() ?? '',
|
||||||
|
entityId: retoureAutomat.state.entityId ?? null,
|
||||||
|
customerFilterOpen: false,
|
||||||
|
partiesById: {},
|
||||||
|
partiesList: [],
|
||||||
|
busyId: null,
|
||||||
|
};
|
||||||
|
this.searchRef = createRef();
|
||||||
|
this._cancelled = false;
|
||||||
|
this.handleRetry = this.handleRetry.bind(this);
|
||||||
|
this.handleCreate = this.handleCreate.bind(this);
|
||||||
|
this.handleOpen = this.handleOpen.bind(this);
|
||||||
|
this.handleDelete = this.handleDelete.bind(this);
|
||||||
|
this.handleTogglePaid = this.handleTogglePaid.bind(this);
|
||||||
|
this.handleToggleShipped = this.handleToggleShipped.bind(this);
|
||||||
|
this.handlePageChange = this.handlePageChange.bind(this);
|
||||||
|
this.handleToggleCustomerFilter = this.handleToggleCustomerFilter.bind(this);
|
||||||
|
this.handleSelectCustomer = this.handleSelectCustomer.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this._cancelled = false;
|
||||||
|
this.unsub = retoureAutomat.subscribe(this, (state) => ({
|
||||||
|
items: state.items,
|
||||||
|
unfilteredTotal: state.unfilteredTotal ?? 0,
|
||||||
|
filterKey: retoureAutomat.getFilterKey(state),
|
||||||
|
entityId: state.entityId ?? null,
|
||||||
|
}));
|
||||||
|
this.unsubNumber = numberAutomat.subscribe(this, () => {
|
||||||
|
this.headerItem = createDummyTestRetoure();
|
||||||
|
this.forceUpdate();
|
||||||
|
});
|
||||||
|
void this.loadParties();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this._cancelled = true;
|
||||||
|
this.unsub?.();
|
||||||
|
this.unsubNumber?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
handleToggleCustomerFilter() {
|
||||||
|
this.setState((prev) => ({ customerFilterOpen: !prev.customerFilterOpen }));
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSelectCustomer(entityId) {
|
||||||
|
retoureAutomat.actions.setEntityId(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
async loadParties() {
|
||||||
|
try {
|
||||||
|
const parties = await loadParties('retoure');
|
||||||
|
if (!this._cancelled) {
|
||||||
|
this.setState({
|
||||||
|
partiesById: cfg.partiesByIdFromList(parties),
|
||||||
|
partiesList: parties || [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Non-fatal: names fall back to ids.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handlePageChange(page, meta) {
|
||||||
|
const pageSize = meta?.pageSize ?? 10;
|
||||||
|
const startIndex = (page - 1) * pageSize;
|
||||||
|
const items = this.state.items;
|
||||||
|
const maxIndex = items ? items.length - 1 : startIndex;
|
||||||
|
const endIndex = Math.min(maxIndex, startIndex + pageSize - 1);
|
||||||
|
|
||||||
|
const startChunk = Math.floor(startIndex / CHUNK_SIZE);
|
||||||
|
const endChunk = Math.floor(endIndex / CHUNK_SIZE);
|
||||||
|
|
||||||
|
retoureAutomat.requireChunk(startChunk, endChunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleRetry() {
|
||||||
|
void retoureAutomat.actions.requireChunk(0, 0, { immediate: true }).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleCreate() {
|
||||||
|
this.props.navigate(cfg.createPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleOpen(retoure) {
|
||||||
|
this.props.navigate(cfg.editPath(retoure.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleDelete(retoure) {
|
||||||
|
if (this.state.busyId != null) return;
|
||||||
|
const num = retoure.number ?? retoure.retoure_number ?? `RET-${retoure.id}`;
|
||||||
|
if (!window.confirm(cfg.confirmDelete(num))) return;
|
||||||
|
this.setState({ busyId: retoure.id });
|
||||||
|
try {
|
||||||
|
await retoureApi.delete(retoure.id);
|
||||||
|
await retoureAutomat.actions.reload();
|
||||||
|
enqueueSnackbar(cfg.deletedMsg, { variant: 'success' });
|
||||||
|
} catch (err) {
|
||||||
|
notifyError(err);
|
||||||
|
} finally {
|
||||||
|
if (!this._cancelled) this.setState({ busyId: null });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleTogglePaid(retoure, checked) {
|
||||||
|
if (this.state.busyId != null) return;
|
||||||
|
const id = retoure.id ?? retoure.manifest_id;
|
||||||
|
const patch = { isPaid: checked, is_paid: checked, paid: checked };
|
||||||
|
retoureAutomat.actions.patchRetoure(id, patch);
|
||||||
|
try {
|
||||||
|
await retoureApi.update(id, { isPaid: checked });
|
||||||
|
enqueueSnackbar(checked ? 'Retoure als erstattet/bezahlt markiert' : 'Retoure als offen markiert', {
|
||||||
|
variant: 'info',
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[RetoureList] update paid on backend failed:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleToggleShipped(retoure, checked) {
|
||||||
|
if (this.state.busyId != null) return;
|
||||||
|
const id = retoure.id ?? retoure.manifest_id;
|
||||||
|
const patch = { isShipped: checked, is_shipped: checked, delivered: checked };
|
||||||
|
retoureAutomat.actions.patchRetoure(id, patch);
|
||||||
|
try {
|
||||||
|
await retoureApi.update(id, { isShipped: checked });
|
||||||
|
enqueueSnackbar(checked ? 'Retoure als geliefert/eingegangen markiert' : 'Retoure als offen markiert', {
|
||||||
|
variant: 'info',
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[RetoureList] update shipped on backend failed:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
items,
|
||||||
|
unfilteredTotal,
|
||||||
|
filterKey,
|
||||||
|
partiesById,
|
||||||
|
partiesList,
|
||||||
|
entityId,
|
||||||
|
customerFilterOpen,
|
||||||
|
busyId,
|
||||||
|
} = this.state;
|
||||||
|
|
||||||
|
rowContext.partiesById = partiesById;
|
||||||
|
rowContext.busyId = busyId;
|
||||||
|
rowContext.onOpen = this.handleOpen;
|
||||||
|
rowContext.onDelete = this.handleDelete;
|
||||||
|
rowContext.onTogglePaid = this.handleTogglePaid;
|
||||||
|
rowContext.onToggleShipped = this.handleToggleShipped;
|
||||||
|
rowContext.headerItem = this.headerItem;
|
||||||
|
|
||||||
|
const customerCounts = {};
|
||||||
|
if (Array.isArray(items)) {
|
||||||
|
for (const ret of items) {
|
||||||
|
const eId = ret?.entityId ?? ret?.entity_id;
|
||||||
|
if (eId) {
|
||||||
|
customerCounts[eId] = (customerCounts[eId] || 0) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const selectedCustomer = entityId ? (partiesById[entityId] || { id: entityId, name: `Kunde #${entityId}` }) : null;
|
||||||
|
|
||||||
|
const searchField = (
|
||||||
|
<RetoureSearchField
|
||||||
|
inputRef={this.searchRef}
|
||||||
|
onCreate={this.handleCreate}
|
||||||
|
customerFilterOpen={customerFilterOpen}
|
||||||
|
onToggleCustomerFilter={this.handleToggleCustomerFilter}
|
||||||
|
selectedCustomer={selectedCustomer}
|
||||||
|
onClearCustomerFilter={() => this.handleSelectCustomer(null)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (items === null && retoureAutomat.state.status === 'failed') {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{searchField}
|
||||||
|
<PanelTileGrid>
|
||||||
|
<PanelTile wide={3} minHeight={0} color={cfg.listColor} sx={{ p: 2 }}>
|
||||||
|
<BackendError error={backendErrorFrom(retoureAutomat.state.error)} onRetry={this.handleRetry} />
|
||||||
|
</PanelTile>
|
||||||
|
</PanelTileGrid>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{searchField}
|
||||||
|
<Box sx={{ display: 'flex', gap: 2.5, alignItems: 'stretch' }}>
|
||||||
|
{customerFilterOpen && (
|
||||||
|
<PartyFilterPanel
|
||||||
|
title="Kunden"
|
||||||
|
parties={partiesList}
|
||||||
|
selectedId={entityId}
|
||||||
|
onSelect={this.handleSelectCustomer}
|
||||||
|
onClose={this.handleToggleCustomerFilter}
|
||||||
|
counts={customerCounts}
|
||||||
|
searchPlaceholder="Kunde suchen…"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Box sx={{ flexGrow: 1, minWidth: 0 }}>
|
||||||
|
<PanelTileGrid>
|
||||||
|
<PanelTile wide={3} minHeight={0} color={cfg.listColor} sx={{ pb: 0, position: 'relative' }}>
|
||||||
|
<FillSpace
|
||||||
|
aboveRef={[this.searchRef]}
|
||||||
|
reserveBottom={32}
|
||||||
|
minPageSize={8}
|
||||||
|
minHeight={0}
|
||||||
|
resetKey={filterKey}
|
||||||
|
items={items || []}
|
||||||
|
totalCount={items ? items.length : 0}
|
||||||
|
unfilteredTotal={unfilteredTotal}
|
||||||
|
headerItem={this.headerItem}
|
||||||
|
renderItem={RetoureRow}
|
||||||
|
virtualScrollbar
|
||||||
|
header={
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
...rowGridSx,
|
||||||
|
height: 36,
|
||||||
|
minHeight: 36,
|
||||||
|
px: 2,
|
||||||
|
borderBottom: '1px solid',
|
||||||
|
borderColor: 'divider',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{renderInvisibleDummyRow(this.headerItem)}
|
||||||
|
<Box sx={{ gridColumn: 1, gridRow: 2, ...headerCellSx }}>Nr. / Ref.</Box>
|
||||||
|
<Box sx={{ gridColumn: 2, gridRow: 2, ...headerCellSx }}>Datum</Box>
|
||||||
|
<Box sx={{ gridColumn: 3, gridRow: 2, ...headerCellSx }}>Kunde</Box>
|
||||||
|
<Box sx={{ gridColumn: 4, gridRow: 2, display: 'flex', justifyContent: 'center', alignItems: 'center', ...headerCellSx }}>
|
||||||
|
<Tooltip title="Bezahlt">
|
||||||
|
<PaymentsOutlinedIcon sx={{ fontSize: 18 }} />
|
||||||
|
</Tooltip>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ gridColumn: 5, gridRow: 2, display: 'flex', justifyContent: 'center', alignItems: 'center', ...headerCellSx }}>
|
||||||
|
<Tooltip title="Geliefert">
|
||||||
|
<LocalShippingOutlinedIcon sx={{ fontSize: 18 }} />
|
||||||
|
</Tooltip>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ gridColumn: 6, gridRow: 2, display: 'flex', justifyContent: 'center', textAlign: 'center', ...headerCellSx }}>Pos.</Box>
|
||||||
|
<Box sx={{ gridColumn: 7, gridRow: 2, textAlign: 'right', ...headerCellSx }}>Gesamt</Box>
|
||||||
|
<Box sx={{ gridColumn: 8, gridRow: 2, ...headerCellSx }} />
|
||||||
|
</Box>
|
||||||
|
}
|
||||||
|
onPageChange={this.handlePageChange}
|
||||||
|
/>
|
||||||
|
{items === null && (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 52,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 32,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
pointerEvents: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress size={32} />
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</PanelTile>
|
||||||
|
</PanelTileGrid>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withNavigate(RetoureList);
|
||||||
@@ -2,6 +2,7 @@ export { default as ManifestList } from './ManifestList';
|
|||||||
export { default as DeliveryList } from './DeliveryList';
|
export { default as DeliveryList } from './DeliveryList';
|
||||||
export { default as OrderList } from './OrderList';
|
export { default as OrderList } from './OrderList';
|
||||||
export { default as QuoteList } from './QuoteList';
|
export { default as QuoteList } from './QuoteList';
|
||||||
|
export { default as RetoureList } from './RetoureList';
|
||||||
export { default as ShipmentList } from './ShipmentList';
|
export { default as ShipmentList } from './ShipmentList';
|
||||||
export { default as OrderPaymentList } from './OrderPaymentList';
|
export { default as OrderPaymentList } from './OrderPaymentList';
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
delivery as deliveryApi,
|
delivery as deliveryApi,
|
||||||
quote as quoteApi,
|
quote as quoteApi,
|
||||||
order as orderApi,
|
order as orderApi,
|
||||||
|
retoure as retoureApi,
|
||||||
} from '../../api';
|
} from '../../api';
|
||||||
import supplierAutomat from '../../automats/supplierAutomat';
|
import supplierAutomat from '../../automats/supplierAutomat';
|
||||||
import entityAutomat from '../../automats/entityAutomat';
|
import entityAutomat from '../../automats/entityAutomat';
|
||||||
@@ -9,6 +10,7 @@ import customergroupAutomat from '../../automats/customergroupAutomat';
|
|||||||
import deliveryAutomat from '../../automats/deliveryAutomat';
|
import deliveryAutomat from '../../automats/deliveryAutomat';
|
||||||
import quoteAutomat from '../../automats/quoteAutomat';
|
import quoteAutomat from '../../automats/quoteAutomat';
|
||||||
import orderAutomat from '../../automats/orderAutomat';
|
import orderAutomat from '../../automats/orderAutomat';
|
||||||
|
import retoureAutomat from '../../automats/retoureAutomat';
|
||||||
import { getArticle } from '../../automats/artikelAutomat';
|
import { getArticle } from '../../automats/artikelAutomat';
|
||||||
import { selectCompanyTaxrate } from '../../automats/companyAutomat';
|
import { selectCompanyTaxrate } from '../../automats/companyAutomat';
|
||||||
import { netFromGross } from '../../utils/price';
|
import { netFromGross } from '../../utils/price';
|
||||||
@@ -18,6 +20,7 @@ import {
|
|||||||
ORANGE_PANEL,
|
ORANGE_PANEL,
|
||||||
PURPLE_PANEL,
|
PURPLE_PANEL,
|
||||||
YELLOW_PANEL,
|
YELLOW_PANEL,
|
||||||
|
RED_PANEL,
|
||||||
} from '../../colors';
|
} from '../../colors';
|
||||||
|
|
||||||
/** Groups that are not sales customers (filter client-side). */
|
/** Groups that are not sales customers (filter client-side). */
|
||||||
@@ -632,6 +635,7 @@ export function apiFor(cfgOrKind) {
|
|||||||
if (kind === 'delivery') return deliveryApi;
|
if (kind === 'delivery') return deliveryApi;
|
||||||
if (kind === 'quote') return quoteApi;
|
if (kind === 'quote') return quoteApi;
|
||||||
if (kind === 'order') return orderApi;
|
if (kind === 'order') return orderApi;
|
||||||
|
if (kind === 'retoure') return retoureApi;
|
||||||
throw new Error(`Unknown manifest kind: ${kind}`);
|
throw new Error(`Unknown manifest kind: ${kind}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -776,6 +780,40 @@ export function manifestConfig(cfgOrKind) {
|
|||||||
columns: ORDER_LINE_COLUMNS,
|
columns: ORDER_LINE_COLUMNS,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (kind === 'retoure') {
|
||||||
|
return {
|
||||||
|
kind: 'retoure',
|
||||||
|
api: 'retoure',
|
||||||
|
listField: 'retoures',
|
||||||
|
docField: 'retoure',
|
||||||
|
partyField: 'entityId',
|
||||||
|
listPath: '/auftrag/retoure',
|
||||||
|
createPath: '/auftrag/retoure/neu',
|
||||||
|
editPath: (id) => `/auftrag/retoure/${id}`,
|
||||||
|
dateLabel: 'Retourendatum',
|
||||||
|
partyLabel: 'Kunde',
|
||||||
|
emptyList: 'Noch keine Retouren.',
|
||||||
|
createButton: 'Neue Retoure',
|
||||||
|
createdMsg: 'Retoure angelegt.',
|
||||||
|
savedMsg: 'Retoure gespeichert.',
|
||||||
|
deletedMsg: 'Retoure gelöscht.',
|
||||||
|
confirmDelete: (number) => `Retoure „${number}“ wirklich löschen?`,
|
||||||
|
invalidId: 'Ungültige Retouren-ID.',
|
||||||
|
partyGateMessage: null,
|
||||||
|
getPathLabel: 'GET /api/retoure/:id',
|
||||||
|
postPathLabel: 'POST /api/retoure',
|
||||||
|
patchPathLabel: 'PUT /api/retoure/:id',
|
||||||
|
listColor: RED_PANEL,
|
||||||
|
headerColor: RED_PANEL,
|
||||||
|
linesColor: GREEN_PANEL,
|
||||||
|
requirePartyBeforeLines: false,
|
||||||
|
listAutomat: retoureAutomat,
|
||||||
|
partiesByIdFromList: (parties) =>
|
||||||
|
Object.fromEntries(parties.map((row) => [row.id, row])),
|
||||||
|
externalNumber: true,
|
||||||
|
columns: ORDER_LINE_COLUMNS,
|
||||||
|
};
|
||||||
|
}
|
||||||
throw new Error(`Unknown manifest kind: ${kind}`);
|
throw new Error(`Unknown manifest kind: ${kind}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,14 @@ import orderAutomat, {
|
|||||||
isOrderDelivered,
|
isOrderDelivered,
|
||||||
} from '../automats/orderAutomat';
|
} from '../automats/orderAutomat';
|
||||||
import quoteAutomat from '../automats/quoteAutomat';
|
import quoteAutomat from '../automats/quoteAutomat';
|
||||||
|
import retoureAutomat from '../automats/retoureAutomat';
|
||||||
import shipmentAutomat from '../automats/shipmentAutomat';
|
import shipmentAutomat from '../automats/shipmentAutomat';
|
||||||
import deliveryAutomat from '../automats/deliveryAutomat';
|
import deliveryAutomat from '../automats/deliveryAutomat';
|
||||||
import { formatPrice } from '../utils/price';
|
import { formatPrice } from '../utils/price';
|
||||||
|
|
||||||
function getAutomatFor(target) {
|
function getAutomatFor(target) {
|
||||||
if (target === 'quote') return quoteAutomat;
|
if (target === 'quote') return quoteAutomat;
|
||||||
|
if (target === 'retoure') return retoureAutomat;
|
||||||
if (target === 'shipment') return shipmentAutomat;
|
if (target === 'shipment') return shipmentAutomat;
|
||||||
if (target === 'delivery') return deliveryAutomat;
|
if (target === 'delivery') return deliveryAutomat;
|
||||||
return orderAutomat;
|
return orderAutomat;
|
||||||
@@ -55,6 +57,7 @@ function getInitialTarget() {
|
|||||||
const p = window.location.pathname;
|
const p = window.location.pathname;
|
||||||
if (p.startsWith('/lieferung')) return 'delivery';
|
if (p.startsWith('/lieferung')) return 'delivery';
|
||||||
if (p.startsWith('/auftrag/ausliefern')) return 'shipment';
|
if (p.startsWith('/auftrag/ausliefern')) return 'shipment';
|
||||||
|
if (p.startsWith('/auftrag/retoure')) return 'retoure';
|
||||||
if (p.startsWith('/auftrag/angebot')) return 'quote';
|
if (p.startsWith('/auftrag/angebot')) return 'quote';
|
||||||
if (p.startsWith('/auftrag')) return 'order';
|
if (p.startsWith('/auftrag')) return 'order';
|
||||||
}
|
}
|
||||||
@@ -987,13 +990,13 @@ class ChunkCacheMonitor extends PureComponent {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { open, position, tab, stats, pulseCounter } = this.state;
|
const { open, position, tab, stats, pulseCounter } = this.state;
|
||||||
const { lruChunksCount, maxLruChunks, inflightChunks } = stats;
|
const { lruChunksCount = 0, maxLruChunks = MAX_LRU_CHUNKS, inflightChunks = [] } = stats || {};
|
||||||
|
|
||||||
const maxLru = maxLruChunks || MAX_LRU_CHUNKS;
|
const maxLru = maxLruChunks || MAX_LRU_CHUNKS;
|
||||||
const lruCount = lruChunksCount || 0;
|
const lruCount = lruChunksCount || 0;
|
||||||
const lruPercent = Math.min(100, Math.round((lruCount / maxLru) * 100));
|
const lruPercent = Math.min(100, Math.round((lruCount / maxLru) * 100));
|
||||||
const hasInflight = inflightChunks.length > 0;
|
const hasInflight = Array.isArray(inflightChunks) && inflightChunks.length > 0;
|
||||||
const filterCachesCount = stats.filterCaches?.length || 1;
|
const filterCachesCount = stats?.filterCaches?.length || 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import RequestQuoteIcon from '@mui/icons-material/RequestQuote';
|
|||||||
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
|
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
|
||||||
import PaymentsIcon from '@mui/icons-material/Payments';
|
import PaymentsIcon from '@mui/icons-material/Payments';
|
||||||
import LocalShippingOutlinedIcon from '@mui/icons-material/LocalShippingOutlined';
|
import LocalShippingOutlinedIcon from '@mui/icons-material/LocalShippingOutlined';
|
||||||
|
import AssignmentReturnIcon from '@mui/icons-material/AssignmentReturn';
|
||||||
import LabelIcon from '@mui/icons-material/Label';
|
import LabelIcon from '@mui/icons-material/Label';
|
||||||
|
|
||||||
import HistoryIcon from '@mui/icons-material/History';
|
import HistoryIcon from '@mui/icons-material/History';
|
||||||
@@ -221,6 +222,13 @@ export const SUB_NAV = {
|
|||||||
icon: LocalShippingIcon,
|
icon: LocalShippingIcon,
|
||||||
help: 'Auslieferungen und Lieferscheine (Shipments) verwalten und versenden',
|
help: 'Auslieferungen und Lieferscheine (Shipments) verwalten und versenden',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
segment: 'retoure',
|
||||||
|
label: 'Retoure',
|
||||||
|
title: 'Retoure',
|
||||||
|
icon: AssignmentReturnIcon,
|
||||||
|
help: 'Kundenretouren, Rücksendungen und Erstattungen verwalten',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
segment: 'zahlungen',
|
segment: 'zahlungen',
|
||||||
label: 'Zahlungen',
|
label: 'Zahlungen',
|
||||||
|
|||||||
10
src/routes/auftrag/retoure.jsx
Normal file
10
src/routes/auftrag/retoure.jsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { PureComponent } from 'react';
|
||||||
|
import RetoureList from '../../components/manifest/RetoureList';
|
||||||
|
|
||||||
|
class AuftragRetourePage extends PureComponent {
|
||||||
|
render() {
|
||||||
|
return <RetoureList />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AuftragRetourePage;
|
||||||
16
src/routes/auftrag/retoure/_retoureId.jsx
Normal file
16
src/routes/auftrag/retoure/_retoureId.jsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { PureComponent } from 'react';
|
||||||
|
import { ManifestForm, withManifestId } from '../../../components/manifest';
|
||||||
|
|
||||||
|
class AuftragRetoureEditPage extends PureComponent {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<ManifestForm
|
||||||
|
kind="retoure"
|
||||||
|
mode="edit"
|
||||||
|
docId={this.props.docId}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withManifestId('retoureId', AuftragRetoureEditPage);
|
||||||
10
src/routes/auftrag/retoure/neu.jsx
Normal file
10
src/routes/auftrag/retoure/neu.jsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { PureComponent } from 'react';
|
||||||
|
import { ManifestForm } from '../../../components/manifest';
|
||||||
|
|
||||||
|
class AuftragRetoureNeuPage extends PureComponent {
|
||||||
|
render() {
|
||||||
|
return <ManifestForm kind="retoure" mode="create" />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AuftragRetoureNeuPage;
|
||||||
@@ -2,7 +2,8 @@ import numberAutomat from '../automats/numberAutomat';
|
|||||||
import quoteAutomat from '../automats/quoteAutomat';
|
import quoteAutomat from '../automats/quoteAutomat';
|
||||||
import orderAutomat from '../automats/orderAutomat';
|
import orderAutomat from '../automats/orderAutomat';
|
||||||
import deliveryAutomat from '../automats/deliveryAutomat';
|
import deliveryAutomat from '../automats/deliveryAutomat';
|
||||||
import { order as orderApi, quote as quoteApi, delivery as deliveryApi } from '../api';
|
import retoureAutomat from '../automats/retoureAutomat';
|
||||||
|
import { order as orderApi, quote as quoteApi, delivery as deliveryApi, retoure as retoureApi } from '../api';
|
||||||
|
|
||||||
/** Standard cross-platform monospace font stack for numbers from a number scheme. */
|
/** Standard cross-platform monospace font stack for numbers from a number scheme. */
|
||||||
export const MONO_FONT_FAMILY =
|
export const MONO_FONT_FAMILY =
|
||||||
@@ -61,7 +62,11 @@ export function getNextDocumentNumber(kind) {
|
|||||||
pad = refSeq ? Math.max(0, Number(refSeq.padding) || 0) : 6;
|
pad = refSeq ? Math.max(0, Number(refSeq.padding) || 0) : 6;
|
||||||
const prefixStyle = refSeq?.prefix ?? '';
|
const prefixStyle = refSeq?.prefix ?? '';
|
||||||
|
|
||||||
if (kind === 'delivery') {
|
if (kind === 'retoure') {
|
||||||
|
prefix = 'RET-';
|
||||||
|
pad = 5;
|
||||||
|
startNum = 1;
|
||||||
|
} else if (kind === 'delivery') {
|
||||||
prefix = prefixStyle.startsWith('DEL-') ? 'DEL-' : (prefixStyle.startsWith('L-') ? 'L-' : 'LS-');
|
prefix = prefixStyle.startsWith('DEL-') ? 'DEL-' : (prefixStyle.startsWith('L-') ? 'L-' : 'LS-');
|
||||||
} else if (
|
} else if (
|
||||||
prefixStyle.startsWith('ART-') ||
|
prefixStyle.startsWith('ART-') ||
|
||||||
@@ -91,8 +96,8 @@ export function getNextDocumentNumber(kind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check existing docs from quoteAutomat / orderAutomat / deliveryAutomat to avoid collisions
|
// Check existing docs from quoteAutomat / orderAutomat / deliveryAutomat / retoureAutomat to avoid collisions
|
||||||
const listAutomat = kind === 'quote' ? quoteAutomat : (kind === 'order' ? orderAutomat : (kind === 'delivery' ? deliveryAutomat : null));
|
const listAutomat = kind === 'quote' ? quoteAutomat : (kind === 'order' ? orderAutomat : (kind === 'delivery' ? deliveryAutomat : (kind === 'retoure' ? retoureAutomat : null)));
|
||||||
const existingDocs = Array.isArray(listAutomat?.state?.items) ? listAutomat.state.items : [];
|
const existingDocs = Array.isArray(listAutomat?.state?.items) ? listAutomat.state.items : [];
|
||||||
let maxFound = Math.max(startNum - 1, maxKnownNumberByKind.get(kind) ?? 0);
|
let maxFound = Math.max(startNum - 1, maxKnownNumberByKind.get(kind) ?? 0);
|
||||||
|
|
||||||
@@ -128,7 +133,7 @@ export function getNextDocumentNumber(kind) {
|
|||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
export async function ensureDocumentNumber(kind) {
|
export async function ensureDocumentNumber(kind) {
|
||||||
const listAutomat = kind === 'quote' ? quoteAutomat : (kind === 'order' ? orderAutomat : (kind === 'delivery' ? deliveryAutomat : null));
|
const listAutomat = kind === 'quote' ? quoteAutomat : (kind === 'order' ? orderAutomat : (kind === 'delivery' ? deliveryAutomat : (kind === 'retoure' ? retoureAutomat : null)));
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
numberAutomat.actions.ensureLoaded().catch(() => {}),
|
numberAutomat.actions.ensureLoaded().catch(() => {}),
|
||||||
listAutomat?.actions?.ensureLoaded ? listAutomat.actions.ensureLoaded().catch(() => {}) : Promise.resolve(),
|
listAutomat?.actions?.ensureLoaded ? listAutomat.actions.ensureLoaded().catch(() => {}) : Promise.resolve(),
|
||||||
@@ -145,6 +150,9 @@ export async function ensureDocumentNumber(kind) {
|
|||||||
} else if (kind === 'delivery') {
|
} else if (kind === 'delivery') {
|
||||||
const res = await deliveryApi.list({ offset: 0, limit: 10 });
|
const res = await deliveryApi.list({ offset: 0, limit: 10 });
|
||||||
recentDocs = Array.isArray(res?.deliveries) ? res.deliveries : [];
|
recentDocs = Array.isArray(res?.deliveries) ? res.deliveries : [];
|
||||||
|
} else if (kind === 'retoure') {
|
||||||
|
const res = await retoureApi.list({ offset: 0, limit: 10, pageSize: 10 });
|
||||||
|
recentDocs = Array.isArray(res?.retoures) ? res.retoures : (Array.isArray(res?.items) ? res.items : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recentDocs.length > 0) {
|
if (recentDocs.length > 0) {
|
||||||
@@ -152,7 +160,7 @@ export async function ensureDocumentNumber(kind) {
|
|||||||
const seq = numbers.find((r) => r.type === kind);
|
const seq = numbers.find((r) => r.type === kind);
|
||||||
let prefix = seq?.prefix;
|
let prefix = seq?.prefix;
|
||||||
if (prefix == null) {
|
if (prefix == null) {
|
||||||
prefix = kind === 'quote' ? 'ANG-' : (kind === 'order' ? 'AUF-' : 'LS-');
|
prefix = kind === 'quote' ? 'ANG-' : (kind === 'order' ? 'AUF-' : (kind === 'retoure' ? 'RET-' : 'LS-'));
|
||||||
}
|
}
|
||||||
|
|
||||||
let maxFound = maxKnownNumberByKind.get(kind) ?? 0;
|
let maxFound = maxKnownNumberByKind.get(kind) ?? 0;
|
||||||
@@ -206,7 +214,9 @@ export function getMaxDocumentNumber(kind = 'quote') {
|
|||||||
const prefixStyle = refSeq?.prefix ?? '';
|
const prefixStyle = refSeq?.prefix ?? '';
|
||||||
|
|
||||||
let prefix = '';
|
let prefix = '';
|
||||||
if (kind === 'delivery') {
|
if (kind === 'retoure') {
|
||||||
|
return `RET-${'9'.repeat(5)}`;
|
||||||
|
} else if (kind === 'delivery') {
|
||||||
prefix = prefixStyle.startsWith('DEL-') ? 'DEL-' : (prefixStyle.startsWith('L-') ? 'L-' : 'LS-');
|
prefix = prefixStyle.startsWith('DEL-') ? 'DEL-' : (prefixStyle.startsWith('L-') ? 'L-' : 'LS-');
|
||||||
} else if (
|
} else if (
|
||||||
prefixStyle.startsWith('ART-') ||
|
prefixStyle.startsWith('ART-') ||
|
||||||
|
|||||||
Reference in New Issue
Block a user