Compare commits
6 Commits
37acaf9554
...
47bac6024c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47bac6024c | ||
|
|
657d184d1c | ||
|
|
a90776bb8b | ||
|
|
670184c633 | ||
|
|
7114258a96 | ||
|
|
40bf70a41c |
@@ -17,20 +17,20 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
|||||||
### Reusable types
|
### Reusable types
|
||||||
|
|
||||||
- `T1` = `{ order: T2 }`
|
- `T1` = `{ order: T2 }`
|
||||||
- `T2` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T29[], createdAt?: str, shipping?: T37|null, shippings?: T37[], payment?: T43|null, payments?: T43[], paid?: bool, shipped?: bool, delivered?: bool, orderTotal?: num, paidTotal?: num, orderedQuantity?: num, shippedQuantity?: num, shipments?: T5[], files?: T15[] }`
|
- `T2` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T29[], externalNumber?: str|null, createdAt?: str, shipping?: T37|null, shippings?: T37[], payment?: T43|null, payments?: T43[], paid?: bool, shipped?: bool, delivered?: bool, orderTotal?: num, paidTotal?: num, orderedQuantity?: num, shippedQuantity?: num, shipments?: T5[], files?: T15[] }`
|
||||||
- `T3` = `{ article: T4 }`
|
- `T3` = `{ article: T4 }`
|
||||||
- `T4` = `{ id: int, sku: str, name: str, slug: str, desc: str|null, seo: str|null, track_stock: bool, unitamount: num|null, weight: num|null, unit: T40, brand: T38|null, categoryIds: int[], photos: T35[], eans: str[], prices: T47[], suppliers: T17[] }`
|
- `T4` = `{ id: int, sku: str, name: str, slug: str, desc: str|null, seo: str|null, track_stock: bool, unitamount: num|null, weight: num|null, unit: T40, brand: T38|null, categoryIds: int[], photos: T35[], eans: str[], prices: T47[], suppliers: T17[] }`
|
||||||
- `T5` = `{ id: int, number: str, type: str, date: str, lines: T29[], shippings: T37[], entityId?: int|null, externalNumber?: str|null, createdAt?: str|null, lineCount?: int, packageCount?: int, files?: T15[] }`
|
- `T5` = `{ id: int, number: str, type: str, date: str, lines: T29[], shippings: T37[], entityId?: int|null, externalNumber?: str|null, createdAt?: str|null, lineCount?: int, packageCount?: int, files?: T15[] }`
|
||||||
- `T6` = `{ delivery: T7 }`
|
- `T6` = `{ quote: T7 }`
|
||||||
- `T7` = `{ id: int, number: str, type: str, supplierId: int|null, date: str, lines: T29[], files: T15[], externalNumber?: str|null, createdAt?: str, ledger?: T51 }`
|
- `T7` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T29[], externalNumber?: str|null, createdAt?: str, positions?: int, grossTotal?: num, totalQuantity?: num, customerName?: str|null, files?: T15[] }`
|
||||||
- `T8` = `{ quote: T9 }`
|
- `T8` = `{ delivery: T9 }`
|
||||||
- `T9` = `{ id: int, number: str, type: str, entityId: int|null, date: str, lines: T29[], createdAt?: str, positions?: int, grossTotal?: num, totalQuantity?: num, customerName?: str|null, files?: T15[] }`
|
- `T9` = `{ id: int, number: str, type: str, supplierId: int|null, date: str, lines: T29[], files: T15[], externalNumber?: str|null, createdAt?: str, ledger?: T51 }`
|
||||||
- `T10` = `{ name: str, path: str, totalSizeBytes: int, timestamp: str|null, manifest?: T11|null }`
|
- `T10` = `{ name: str, path: str, totalSizeBytes: int, timestamp: str|null, manifest?: T11|null }`
|
||||||
- `T11` = `{ id: str, timestamp: str, dateKey: str, monthKey: str, dbProvider: str, files: T18, totalSizeBytes: int, durationMs: int }`
|
- `T11` = `{ id: str, timestamp: str, dateKey: str, monthKey: str, dbProvider: str, files: T18, totalSizeBytes: int, durationMs: int }`
|
||||||
- `T12` = `{ labeltemplate: T14 }`
|
- `T12` = `{ labeltemplate: T14 }`
|
||||||
- `T13` = `{ attachment: T15, fileUrl: str }`
|
- `T13` = `{ attachment: T15, fileUrl: str }`
|
||||||
- `T14` = `{ id: int, name: str, width: num, height: num, dpi: int, type: str, content: T25, thumb?: str|null }`
|
- `T14` = `{ id: int, name: str, width: num, height: num, dpi: int, type: str, content: T25, thumb?: str|null }`
|
||||||
- `T15` = `{ id: int, manifestId: int, fileId: int, sort: int, hash: str, mimetype: str, name: str, size: int, created?: str, modified?: str, thumbavif?: str|null, thumbx?: int|null, thumby?: int|null, meta?: { [k]: str }|null }`
|
- `T15` = `{ id: int, manifestId: int, fileId: int, sort: int, hash: str, mimetype: str, name: str, size: int, created?: str, modified?: str, skeledash?: str|null, thumbx?: int|null, thumby?: int|null, meta?: { [k]: str }|null }`
|
||||||
- `T16` = `{ id: int, name: str, pairingpin?: str|null, token?: str|null, pairedAt?: str|null, clientserial?: str|null, rootCategoryId?: int|null, syncRootArticles?: bool, lastseenAt?: str|null, updatedAt?: str|null, categoryIds?: int[] }`
|
- `T16` = `{ id: int, name: str, pairingpin?: str|null, token?: str|null, pairedAt?: str|null, clientserial?: str|null, rootCategoryId?: int|null, syncRootArticles?: bool, lastseenAt?: str|null, updatedAt?: str|null, categoryIds?: int[] }`
|
||||||
- `T17` = `{ id: int, articleId: int, entityId: int, pu: num, sort: int, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T54|null }`
|
- `T17` = `{ id: int, articleId: int, entityId: int, pu: num, sort: int, supplierName?: str|null, sku?: str|null, stock?: num|null, priceId?: int|null, price?: T54|null }`
|
||||||
- `T18` = `{ vfs: T52, storage: T52, database: T45 }`
|
- `T18` = `{ vfs: T52, storage: T52, database: T45 }`
|
||||||
@@ -404,7 +404,7 @@ _none_
|
|||||||
- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int|null, date: str, externalNumber?: str|null, createdAt?: str, ledger?: T51 }[] }`
|
- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int|null, date: str, externalNumber?: str|null, createdAt?: str, ledger?: T51 }[] }`
|
||||||
#### Create delivery — `POST /delivery`
|
#### Create delivery — `POST /delivery`
|
||||||
- Params: `body: { externalNumber: str, date: str, lines: T34[], supplierId?: int|null, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }`
|
- Params: `body: { externalNumber: str, date: str, lines: T34[], supplierId?: int|null, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }`
|
||||||
- Returns: `201 T6`
|
- Returns: `201 T8`
|
||||||
#### Parse document (SSE) — `POST /delivery/parse`
|
#### Parse document (SSE) — `POST /delivery/parse`
|
||||||
- Params: `form: { file: str }`
|
- Params: `form: { file: str }`
|
||||||
- Returns: `200 SSE`
|
- Returns: `200 SSE`
|
||||||
@@ -422,10 +422,10 @@ _none_
|
|||||||
- Returns: `204 void`
|
- Returns: `204 void`
|
||||||
#### Get delivery — `GET /delivery/{id}`
|
#### Get delivery — `GET /delivery/{id}`
|
||||||
- Params: `id: int`
|
- Params: `id: int`
|
||||||
- Returns: `200 T6`
|
- Returns: `200 T8`
|
||||||
#### Update delivery — `PATCH /delivery/{id}`
|
#### Update delivery — `PATCH /delivery/{id}`
|
||||||
- Params: `id: int, body: { externalNumber?: str|null, date?: str, supplierId?: int|null, lines?: T34[], files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }`
|
- Params: `id: int, body: { externalNumber?: str|null, date?: str, supplierId?: int|null, lines?: T34[], files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: { [k]: str } }[] }`
|
||||||
- Returns: `200 T6`
|
- Returns: `200 T8`
|
||||||
#### Delete delivery file attachment — `DELETE /delivery/{id}/file/{fileId}`
|
#### Delete delivery file attachment — `DELETE /delivery/{id}/file/{fileId}`
|
||||||
- Params: `id: int, fileId: int`
|
- Params: `id: int, fileId: int`
|
||||||
- Returns: `204 void`
|
- Returns: `204 void`
|
||||||
@@ -631,7 +631,7 @@ _none_
|
|||||||
- Params: `query: offset?: int, limit?: int, search?: str, onlyUnpaid?: bool, onlyUndelivered?: bool, seekMonths?: int`
|
- Params: `query: offset?: int, limit?: int, search?: str, onlyUnpaid?: bool, onlyUndelivered?: bool, seekMonths?: int`
|
||||||
- Returns: `200 { orders: T2[], total: int, unfilteredTotal: int, offset: int, limit: int }`
|
- Returns: `200 { orders: T2[], total: int, unfilteredTotal: int, offset: int, limit: int }`
|
||||||
#### Create order — `POST /order`
|
#### Create order — `POST /order`
|
||||||
- Params: `body: { number: str, date: str, lines: T34[], entityId?: int|null }`
|
- Params: `body: { number: str, date: str, lines: T34[], entityId?: int|null, externalNumber?: str|null }`
|
||||||
- Returns: `201 T1`
|
- Returns: `201 T1`
|
||||||
#### Delete order — `DELETE /order/{id}`
|
#### Delete order — `DELETE /order/{id}`
|
||||||
- Params: `id: int`
|
- Params: `id: int`
|
||||||
@@ -640,7 +640,7 @@ _none_
|
|||||||
- Params: `id: int`
|
- Params: `id: int`
|
||||||
- Returns: `200 T1`
|
- Returns: `200 T1`
|
||||||
#### Update order — `PATCH /order/{id}`
|
#### Update order — `PATCH /order/{id}`
|
||||||
- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T34[] }`
|
- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, externalNumber?: str|null, lines?: T34[] }`
|
||||||
- Returns: `200 T1`
|
- Returns: `200 T1`
|
||||||
#### Delete order file attachment — `DELETE /order/{id}/file/{fileId}`
|
#### Delete order file attachment — `DELETE /order/{id}/file/{fileId}`
|
||||||
- Params: `id: int, fileId: int`
|
- Params: `id: int, fileId: int`
|
||||||
@@ -770,19 +770,19 @@ _none_
|
|||||||
|
|
||||||
#### List quotes — `GET /quote`
|
#### List quotes — `GET /quote`
|
||||||
- Params: `query: offset?: int, limit?: int, search?: str, seekMonths?: int`
|
- Params: `query: offset?: int, limit?: int, search?: str, seekMonths?: int`
|
||||||
- Returns: `200 { quotes: T9[], total: int, unfilteredTotal: int, offset: int, limit: int }`
|
- Returns: `200 { quotes: T7[], total: int, unfilteredTotal: int, offset: int, limit: int }`
|
||||||
#### Create quote — `POST /quote`
|
#### Create quote — `POST /quote`
|
||||||
- Params: `body: { number: str, date: str, lines: T34[], entityId?: int|null }`
|
- Params: `body: { number: str, date: str, lines: T34[], entityId?: int|null, externalNumber?: str|null }`
|
||||||
- Returns: `201 T8`
|
- Returns: `201 T6`
|
||||||
#### Delete quote — `DELETE /quote/{id}`
|
#### Delete quote — `DELETE /quote/{id}`
|
||||||
- Params: `id: int`
|
- Params: `id: int`
|
||||||
- Returns: `204 void`
|
- Returns: `204 void`
|
||||||
#### Get quote — `GET /quote/{id}`
|
#### Get quote — `GET /quote/{id}`
|
||||||
- Params: `id: int`
|
- Params: `id: int`
|
||||||
- Returns: `200 T8`
|
- Returns: `200 T6`
|
||||||
#### Update quote — `PATCH /quote/{id}`
|
#### Update quote — `PATCH /quote/{id}`
|
||||||
- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, lines?: T34[] }`
|
- Params: `id: int, body: { number?: str, date?: str, entityId?: int|null, externalNumber?: str|null, lines?: T34[] }`
|
||||||
- Returns: `200 T8`
|
- Returns: `200 T6`
|
||||||
#### Delete quote file attachment — `DELETE /quote/{id}/file/{fileId}`
|
#### Delete quote file attachment — `DELETE /quote/{id}/file/{fileId}`
|
||||||
- Params: `id: int, fileId: int`
|
- Params: `id: int, fileId: int`
|
||||||
- Returns: `204 void`
|
- Returns: `204 void`
|
||||||
|
|||||||
@@ -75,4 +75,16 @@ export const order = {
|
|||||||
return http(`/api/order/${id}/file/${fileId}`, { method: 'DELETE' });
|
return http(`/api/order/${id}/file/${fileId}`, { method: 'DELETE' });
|
||||||
},
|
},
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/order/:id/pdf
|
||||||
|
* Generates and attaches order confirmation PDF.
|
||||||
|
* @param {number|string} id Order ID
|
||||||
|
* → 201 { attachment: Attachment, fileUrl: string }
|
||||||
|
*/
|
||||||
|
// #region POST /api/order/:id/pdf — createPdf
|
||||||
|
createPdf(id) {
|
||||||
|
return http(`/api/order/${id}/pdf`, { method: 'POST' });
|
||||||
|
},
|
||||||
|
// #endregion
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
emptyLine,
|
emptyLine,
|
||||||
lineFromApi,
|
lineFromApi,
|
||||||
dateInputValue,
|
dateInputValue,
|
||||||
|
todayInputValue,
|
||||||
parseNum,
|
parseNum,
|
||||||
} from '../components/manifest/manifestConfig';
|
} from '../components/manifest/manifestConfig';
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ export function createInitialManifestDraftState(kind) {
|
|||||||
kind,
|
kind,
|
||||||
mode: 'create',
|
mode: 'create',
|
||||||
id: null,
|
id: null,
|
||||||
date: '',
|
date: kind === 'quote' ? todayInputValue() : '',
|
||||||
partyId: null,
|
partyId: null,
|
||||||
number: '',
|
number: '',
|
||||||
externalNumber: '',
|
externalNumber: '',
|
||||||
@@ -444,6 +445,14 @@ export function createManifestEditAutomat({ kind, name }) {
|
|||||||
externalNumber,
|
externalNumber,
|
||||||
lines,
|
lines,
|
||||||
attachments,
|
attachments,
|
||||||
|
shipments: doc.shipments || [],
|
||||||
|
payments: doc.payments || [],
|
||||||
|
shippings: doc.shippings || [],
|
||||||
|
orderTotal: doc.orderTotal ?? null,
|
||||||
|
paidTotal: doc.paidTotal ?? null,
|
||||||
|
paid: Boolean(doc.paid),
|
||||||
|
shipped: Boolean(doc.shipped),
|
||||||
|
delivered: Boolean(doc.delivered),
|
||||||
baseline,
|
baseline,
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
dirtyFields: { ...emptyFields },
|
dirtyFields: { ...emptyFields },
|
||||||
@@ -579,6 +588,12 @@ export const quoteEditAutomat = createManifestEditAutomat({
|
|||||||
name: 'quote-edit',
|
name: 'quote-edit',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** Shared singleton automat for the single last edited order. */
|
||||||
|
export const orderEditAutomat = createManifestEditAutomat({
|
||||||
|
kind: 'order',
|
||||||
|
name: 'order-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'} kind
|
||||||
@@ -586,5 +601,6 @@ export const quoteEditAutomat = createManifestEditAutomat({
|
|||||||
*/
|
*/
|
||||||
export function getManifestEditAutomat(kind) {
|
export function getManifestEditAutomat(kind) {
|
||||||
if (kind === 'quote') return quoteEditAutomat;
|
if (kind === 'quote') return quoteEditAutomat;
|
||||||
|
if (kind === 'order') return orderEditAutomat;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import CircularProgress from '@mui/material/CircularProgress';
|
|||||||
import { enqueueSnackbar } from 'notistack';
|
import { enqueueSnackbar } from 'notistack';
|
||||||
import BackendError from '../BackendError';
|
import BackendError from '../BackendError';
|
||||||
import { PanelTileGrid } from 'dashgui/panels';
|
import { PanelTileGrid } from 'dashgui/panels';
|
||||||
import { delivery as deliveryApi, quote as quoteApi } from '../../api';
|
import { delivery as deliveryApi, quote as quoteApi, order as orderApi, shipment as shipmentApi, payment as paymentApi } from '../../api';
|
||||||
import { requireArray, requireDefined, requireObject } from '../../utils/apiShape';
|
import { requireArray, requireDefined, requireObject } from '../../utils/apiShape';
|
||||||
import { backendErrorFrom } from '../../utils/backendError';
|
import { backendErrorFrom } from '../../utils/backendError';
|
||||||
import { notifyError } from '../../utils/notify';
|
import { notifyError } from '../../utils/notify';
|
||||||
@@ -13,6 +13,7 @@ import ManifestHeader from './ManifestHeader';
|
|||||||
import ManifestLines from './ManifestLines';
|
import ManifestLines from './ManifestLines';
|
||||||
import ManifestPdfDialog from './ManifestPdfDialog';
|
import ManifestPdfDialog from './ManifestPdfDialog';
|
||||||
import ArticleSearchDialog from './ArticleSearchDialog';
|
import ArticleSearchDialog from './ArticleSearchDialog';
|
||||||
|
import OrderDocumentsTiles from './OrderDocumentsTiles';
|
||||||
import artikelAutomat, { getArticle } from '../../automats/artikelAutomat';
|
import artikelAutomat, { getArticle } from '../../automats/artikelAutomat';
|
||||||
import entityAutomat from '../../automats/entityAutomat';
|
import entityAutomat from '../../automats/entityAutomat';
|
||||||
import supplierAutomat from '../../automats/supplierAutomat';
|
import supplierAutomat from '../../automats/supplierAutomat';
|
||||||
@@ -22,6 +23,7 @@ import {
|
|||||||
buildManifestBody,
|
buildManifestBody,
|
||||||
restoreAttachmentsFromApi,
|
restoreAttachmentsFromApi,
|
||||||
dateInputValue,
|
dateInputValue,
|
||||||
|
todayInputValue,
|
||||||
emptyLine,
|
emptyLine,
|
||||||
lineFromApi,
|
lineFromApi,
|
||||||
loadParties,
|
loadParties,
|
||||||
@@ -55,17 +57,38 @@ class ManifestForm extends PureComponent {
|
|||||||
: null;
|
: null;
|
||||||
const initialDoc = initialDraft || initialEdit;
|
const initialDoc = initialDraft || initialEdit;
|
||||||
|
|
||||||
|
const initialDate =
|
||||||
|
initialDoc?.date ||
|
||||||
|
(props.mode === 'create' && props.kind === 'quote' ? todayInputValue() : '');
|
||||||
|
|
||||||
|
if (
|
||||||
|
props.mode === 'create' &&
|
||||||
|
props.kind === 'quote' &&
|
||||||
|
this.draftAutomat &&
|
||||||
|
!this.draftAutomat.state.date
|
||||||
|
) {
|
||||||
|
this.draftAutomat.setState({ date: initialDate });
|
||||||
|
}
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
status: props.mode === 'edit' && !initialEdit ? 'loading' : (partiesReady ? 'ready' : 'loadingParties'),
|
status: props.mode === 'edit' && !initialEdit ? 'loading' : (partiesReady ? 'ready' : 'loadingParties'),
|
||||||
error: null,
|
error: null,
|
||||||
parties: initialParties,
|
parties: initialParties,
|
||||||
partiesLoading: !partiesReady,
|
partiesLoading: !partiesReady,
|
||||||
date: initialDoc?.date || '',
|
date: initialDate,
|
||||||
partyId: initialDoc?.partyId ?? null,
|
partyId: initialDoc?.partyId ?? null,
|
||||||
number: initialDoc?.number || '',
|
number: initialDoc?.number || '',
|
||||||
externalNumber: initialDoc?.externalNumber || '',
|
externalNumber: initialDoc?.externalNumber || '',
|
||||||
lines: initialDoc?.lines?.length > 0 ? initialDoc.lines : [emptyLine()],
|
lines: initialDoc?.lines?.length > 0 ? initialDoc.lines : [emptyLine()],
|
||||||
attachments: initialDoc?.attachments || [],
|
attachments: initialDoc?.attachments || [],
|
||||||
|
shipments: initialEdit?.shipments || [],
|
||||||
|
payments: initialEdit?.payments || [],
|
||||||
|
shippings: initialEdit?.shippings || [],
|
||||||
|
orderTotal: initialEdit?.orderTotal ?? null,
|
||||||
|
paidTotal: initialEdit?.paidTotal ?? null,
|
||||||
|
paid: Boolean(initialEdit?.paid),
|
||||||
|
shipped: Boolean(initialEdit?.shipped),
|
||||||
|
delivered: Boolean(initialEdit?.delivered),
|
||||||
isDirty: Boolean(initialEdit?.isDirty),
|
isDirty: Boolean(initialEdit?.isDirty),
|
||||||
dirtyFields: initialEdit?.dirtyFields || null,
|
dirtyFields: initialEdit?.dirtyFields || null,
|
||||||
dirtyLineKeys: initialEdit?.dirtyLineKeys || [],
|
dirtyLineKeys: initialEdit?.dirtyLineKeys || [],
|
||||||
@@ -174,6 +197,14 @@ class ManifestForm extends PureComponent {
|
|||||||
externalNumber: state.externalNumber || '',
|
externalNumber: state.externalNumber || '',
|
||||||
lines: state.lines?.length > 0 ? state.lines : [emptyLine()],
|
lines: state.lines?.length > 0 ? state.lines : [emptyLine()],
|
||||||
attachments: state.attachments || [],
|
attachments: state.attachments || [],
|
||||||
|
shipments: state.shipments || [],
|
||||||
|
payments: state.payments || [],
|
||||||
|
shippings: state.shippings || [],
|
||||||
|
orderTotal: state.orderTotal ?? null,
|
||||||
|
paidTotal: state.paidTotal ?? null,
|
||||||
|
paid: Boolean(state.paid),
|
||||||
|
shipped: Boolean(state.shipped),
|
||||||
|
delivered: Boolean(state.delivered),
|
||||||
isDirty: Boolean(state.isDirty),
|
isDirty: Boolean(state.isDirty),
|
||||||
dirtyFields: state.dirtyFields,
|
dirtyFields: state.dirtyFields,
|
||||||
dirtyLineKeys: state.dirtyLineKeys,
|
dirtyLineKeys: state.dirtyLineKeys,
|
||||||
@@ -333,6 +364,27 @@ class ManifestForm extends PureComponent {
|
|||||||
const apiFiles = doc.files ?? [];
|
const apiFiles = doc.files ?? [];
|
||||||
const attachments = await restoreAttachmentsFromApi(apiFiles);
|
const attachments = await restoreAttachmentsFromApi(apiFiles);
|
||||||
|
|
||||||
|
let shipments = doc.shipments;
|
||||||
|
let payments = doc.payments;
|
||||||
|
if (kind === 'order') {
|
||||||
|
if (!shipments) {
|
||||||
|
try {
|
||||||
|
const shRes = await shipmentApi.listByOrder(docId);
|
||||||
|
shipments = shRes?.shipments ?? [];
|
||||||
|
} catch {
|
||||||
|
shipments = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!payments) {
|
||||||
|
try {
|
||||||
|
const payRes = await paymentApi.listByOrder(docId);
|
||||||
|
payments = payRes?.payments ?? [];
|
||||||
|
} catch {
|
||||||
|
payments = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loadedDoc = {
|
const loadedDoc = {
|
||||||
date: dateInputValue(doc.date),
|
date: dateInputValue(doc.date),
|
||||||
partyId: doc[cfg.partyField],
|
partyId: doc[cfg.partyField],
|
||||||
@@ -341,6 +393,14 @@ class ManifestForm extends PureComponent {
|
|||||||
doc.externalNumber != null ? String(doc.externalNumber) : '',
|
doc.externalNumber != null ? String(doc.externalNumber) : '',
|
||||||
lines,
|
lines,
|
||||||
attachments,
|
attachments,
|
||||||
|
shipments: shipments || [],
|
||||||
|
payments: payments || [],
|
||||||
|
shippings: doc.shippings || [],
|
||||||
|
orderTotal: doc.orderTotal ?? null,
|
||||||
|
paidTotal: doc.paidTotal ?? null,
|
||||||
|
paid: Boolean(doc.paid),
|
||||||
|
shipped: Boolean(doc.shipped),
|
||||||
|
delivered: Boolean(doc.delivered),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.editAutomat) {
|
if (this.editAutomat) {
|
||||||
@@ -847,19 +907,21 @@ class ManifestForm extends PureComponent {
|
|||||||
async handleCreatePdf(e) {
|
async handleCreatePdf(e) {
|
||||||
e?.preventDefault?.();
|
e?.preventDefault?.();
|
||||||
e?.stopPropagation?.();
|
e?.stopPropagation?.();
|
||||||
const { docId } = this.props;
|
const { docId, kind } = this.props;
|
||||||
if (this.state.pdfCreating || this.state.saving) return;
|
if (this.state.pdfCreating || this.state.saving) return;
|
||||||
if (docId == null) return;
|
if (docId == null) return;
|
||||||
|
|
||||||
this.setState({ pdfCreating: true });
|
this.setState({ pdfCreating: true });
|
||||||
try {
|
try {
|
||||||
const res = await quoteApi.createPdf(docId);
|
const api = kind === 'order' ? orderApi : quoteApi;
|
||||||
requireObject(res, 'POST /api/quote/:id/pdf');
|
const res = await api.createPdf(docId);
|
||||||
|
requireObject(res, `POST /api/${kind}/:id/pdf`);
|
||||||
|
|
||||||
const quoteRes = await quoteApi.get(docId);
|
const getRes = await api.get(docId);
|
||||||
if (quoteRes?.quote?.files && !this._cancelled) {
|
const doc = getRes?.[kind];
|
||||||
|
if (doc?.files && !this._cancelled) {
|
||||||
const attachments = await restoreAttachmentsFromApi(
|
const attachments = await restoreAttachmentsFromApi(
|
||||||
quoteRes.quote.files,
|
doc.files,
|
||||||
this.state.attachments,
|
this.state.attachments,
|
||||||
);
|
);
|
||||||
this.setState({ attachments });
|
this.setState({ attachments });
|
||||||
@@ -868,7 +930,10 @@ class ManifestForm extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enqueueSnackbar('Angebot-PDF erfolgreich erstellt.', { variant: 'success' });
|
enqueueSnackbar(
|
||||||
|
kind === 'order' ? 'Auftrag-PDF erfolgreich erstellt.' : 'Angebot-PDF erfolgreich erstellt.',
|
||||||
|
{ variant: 'success' },
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!this._cancelled) {
|
if (!this._cancelled) {
|
||||||
notifyError(err);
|
notifyError(err);
|
||||||
@@ -1077,7 +1142,7 @@ class ManifestForm extends PureComponent {
|
|||||||
onRestore={this.props.mode === 'edit' && this.state.isDirty ? this.handleRestore : undefined}
|
onRestore={this.props.mode === 'edit' && this.state.isDirty ? this.handleRestore : undefined}
|
||||||
onPdfUpload={kind === 'delivery' ? this.handlePdfUpload : undefined}
|
onPdfUpload={kind === 'delivery' ? this.handlePdfUpload : undefined}
|
||||||
onPdfDelete={this.handleAttachmentDelete}
|
onPdfDelete={this.handleAttachmentDelete}
|
||||||
onPdfCreate={kind === 'quote' ? this.handleCreatePdf : undefined}
|
onPdfCreate={kind === 'quote' || kind === 'order' ? this.handleCreatePdf : undefined}
|
||||||
onSave={this.handleSave}
|
onSave={this.handleSave}
|
||||||
onPartyChange={this.handlePartyChange}
|
onPartyChange={this.handlePartyChange}
|
||||||
onDateChange={this.handleDateChange}
|
onDateChange={this.handleDateChange}
|
||||||
@@ -1085,6 +1150,25 @@ 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' ? (
|
||||||
|
<OrderDocumentsTiles
|
||||||
|
orderId={this.props.docId}
|
||||||
|
orderNumber={number}
|
||||||
|
externalNumber={externalNumber}
|
||||||
|
orderTotal={this.state.orderTotal}
|
||||||
|
paidTotal={this.state.paidTotal}
|
||||||
|
paid={this.state.paid}
|
||||||
|
shipped={this.state.shipped}
|
||||||
|
delivered={this.state.delivered}
|
||||||
|
shipments={this.state.shipments}
|
||||||
|
payments={this.state.payments}
|
||||||
|
attachments={this.state.attachments}
|
||||||
|
onPdfCreate={this.handleCreatePdf}
|
||||||
|
pdfCreating={this.state.pdfCreating}
|
||||||
|
onAttachmentDelete={this.handleAttachmentDelete}
|
||||||
|
navigate={this.props.navigate}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</PanelTileGrid>
|
</PanelTileGrid>
|
||||||
<ManifestPdfDialog
|
<ManifestPdfDialog
|
||||||
open={pdfDialogOpen}
|
open={pdfDialogOpen}
|
||||||
|
|||||||
@@ -523,7 +523,7 @@ class ManifestHeader extends PureComponent {
|
|||||||
: 'Ins Lager buchen'}
|
: 'Ins Lager buchen'}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{kind === 'quote' && onPdfCreate && docId != null && Boolean(number) && (
|
{(kind === 'quote' || kind === 'order') && onPdfCreate && docId != null && Boolean(number) && (
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
|
|||||||
299
src/components/manifest/OrderDocumentsTiles.jsx
Normal file
299
src/components/manifest/OrderDocumentsTiles.jsx
Normal file
@@ -0,0 +1,299 @@
|
|||||||
|
import { PureComponent } from 'react';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
|
import Card from '@mui/material/Card';
|
||||||
|
import Chip from '@mui/material/Chip';
|
||||||
|
import Divider from '@mui/material/Divider';
|
||||||
|
import Stack from '@mui/material/Stack';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
|
import LocalShippingOutlinedIcon from '@mui/icons-material/LocalShippingOutlined';
|
||||||
|
import PaymentsOutlinedIcon from '@mui/icons-material/PaymentsOutlined';
|
||||||
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
|
import { PanelTile } from 'dashgui/panels';
|
||||||
|
import { formatDate } from './manifestConfig';
|
||||||
|
import { formatPrice } from '../../utils/price';
|
||||||
|
import { typeLabel, typeIcon } from './OrderPaymentList';
|
||||||
|
import {
|
||||||
|
GREEN_PANEL,
|
||||||
|
YELLOW_PANEL,
|
||||||
|
WHITE,
|
||||||
|
} from '../../colors';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders 1-wide associated document tiles for an order in edit mode:
|
||||||
|
* 1. Lieferscheine / Auslieferungen (Shipments)
|
||||||
|
* 2. Zahlungen (Payments)
|
||||||
|
*/
|
||||||
|
export class OrderDocumentsTiles extends PureComponent {
|
||||||
|
handleOpenShipment = () => {
|
||||||
|
if (this.props.navigate) {
|
||||||
|
this.props.navigate('/auftrag/ausliefern');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleOpenPayments = () => {
|
||||||
|
if (this.props.navigate) {
|
||||||
|
this.props.navigate('/auftrag/zahlungen');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
renderShipmentsTile() {
|
||||||
|
const { shipments = [], shipped, delivered, navigate } = this.props;
|
||||||
|
|
||||||
|
const statusLabel = delivered
|
||||||
|
? 'Geliefert'
|
||||||
|
: shipped
|
||||||
|
? 'Versendet'
|
||||||
|
: shipments.length > 0
|
||||||
|
? 'Teilweise'
|
||||||
|
: 'Offen';
|
||||||
|
|
||||||
|
const statusColor = delivered || shipped ? 'success' : shipments.length > 0 ? 'warning' : 'default';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PanelTile wide={1} minHeight={220} color={GREEN_PANEL} title="Lieferscheine">
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1.5 }}>
|
||||||
|
<Stack direction="row" spacing={0.75} alignItems="center">
|
||||||
|
<LocalShippingOutlinedIcon sx={{ fontSize: 20, color: 'text.secondary' }} />
|
||||||
|
<Chip size="small" label={statusLabel} color={statusColor} sx={{ fontWeight: 600, height: 22 }} />
|
||||||
|
</Stack>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
startIcon={<AddIcon />}
|
||||||
|
onClick={() => navigate?.('/auftrag/ausliefern')}
|
||||||
|
sx={{ fontWeight: 600, textTransform: 'none', height: 26, fontSize: '0.75rem', px: 1 }}
|
||||||
|
>
|
||||||
|
Liefern
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{shipments.length > 0 ? (
|
||||||
|
<Stack spacing={1}>
|
||||||
|
{shipments.map((sh) => {
|
||||||
|
const carrier = sh.shippings?.[0]?.carrier;
|
||||||
|
const tracking = sh.shippings?.[0]?.trackingCode;
|
||||||
|
const posCount = sh.lineCount ?? sh.lines?.length ?? 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={sh.id ?? sh.number}
|
||||||
|
variant="outlined"
|
||||||
|
onClick={this.handleOpenShipment}
|
||||||
|
sx={{
|
||||||
|
p: 1.25,
|
||||||
|
bgcolor: WHITE,
|
||||||
|
cursor: 'pointer',
|
||||||
|
transition: 'all 0.15s ease',
|
||||||
|
'&:hover': {
|
||||||
|
boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
|
||||||
|
borderColor: 'primary.main',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', mb: 0.25 }}>
|
||||||
|
<Typography variant="subtitle2" sx={{ fontWeight: 700, fontSize: '0.85rem' }}>
|
||||||
|
{sh.number}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
{sh.date ? formatDate(sh.date) : '–'}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{sh.externalNumber ? (
|
||||||
|
<Typography variant="caption" color="text.secondary" sx={{ display: 'block', mb: 0.25 }}>
|
||||||
|
Ref: {sh.externalNumber}
|
||||||
|
</Typography>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mt: 0.5 }}>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
{posCount} Pos.
|
||||||
|
</Typography>
|
||||||
|
{carrier || tracking ? (
|
||||||
|
<Chip
|
||||||
|
size="small"
|
||||||
|
color="primary"
|
||||||
|
variant="outlined"
|
||||||
|
label={carrier || 'Paket'}
|
||||||
|
sx={{ height: 18, fontSize: '0.65rem' }}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</Box>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
) : (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: 1.5,
|
||||||
|
textAlign: 'center',
|
||||||
|
bgcolor: 'rgba(255,255,255,0.6)',
|
||||||
|
borderRadius: 1,
|
||||||
|
border: '1px dashed',
|
||||||
|
borderColor: 'divider',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="caption" color="text.secondary" sx={{ display: 'block', mb: 1 }}>
|
||||||
|
Noch keine Lieferscheine erstellt.
|
||||||
|
</Typography>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="contained"
|
||||||
|
startIcon={<LocalShippingOutlinedIcon />}
|
||||||
|
onClick={() => navigate?.('/auftrag/ausliefern')}
|
||||||
|
sx={{ textTransform: 'none', fontWeight: 600, fontSize: '0.75rem' }}
|
||||||
|
>
|
||||||
|
Lieferschein anlegen
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</PanelTile>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderPaymentsTile() {
|
||||||
|
const { payments = [], paid, paidTotal, orderTotal } = this.props;
|
||||||
|
|
||||||
|
const tot = Number(orderTotal) || 0;
|
||||||
|
const pd = Number(paidTotal) || 0;
|
||||||
|
const openAmount = Math.max(0, tot - pd);
|
||||||
|
|
||||||
|
const statusLabel = paid ? 'Bezahlt' : pd > 0 ? 'Teilzahlung' : 'Offen';
|
||||||
|
const statusColor = paid ? 'success' : pd > 0 ? 'warning' : 'error';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PanelTile wide={1} minHeight={220} color={YELLOW_PANEL} title="Zahlungen">
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 1.5 }}>
|
||||||
|
<Stack direction="row" spacing={0.75} alignItems="center">
|
||||||
|
<PaymentsOutlinedIcon sx={{ fontSize: 20, color: 'text.secondary' }} />
|
||||||
|
<Chip size="small" label={statusLabel} color={statusColor} sx={{ fontWeight: 600, height: 22 }} />
|
||||||
|
</Stack>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
onClick={this.handleOpenPayments}
|
||||||
|
sx={{ fontWeight: 600, textTransform: 'none', height: 26, fontSize: '0.75rem', px: 1 }}
|
||||||
|
>
|
||||||
|
Zahlungen
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* Financial KPI Card */}
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: 1,
|
||||||
|
mb: 1.5,
|
||||||
|
bgcolor: WHITE,
|
||||||
|
borderRadius: 1,
|
||||||
|
border: '1px solid',
|
||||||
|
borderColor: 'divider',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.25 }}>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
Summe:
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" sx={{ fontWeight: 700 }}>
|
||||||
|
{formatPrice(tot)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.25 }}>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
Bezahlt:
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" sx={{ fontWeight: 700, color: 'success.main' }}>
|
||||||
|
{formatPrice(pd)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Divider sx={{ my: 0.5 }} />
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
Offen:
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="caption" sx={{ fontWeight: 700, color: openAmount > 0 ? 'error.main' : 'text.secondary' }}>
|
||||||
|
{formatPrice(openAmount)}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{payments.length > 0 ? (
|
||||||
|
<Stack spacing={1}>
|
||||||
|
{payments.map((pay) => {
|
||||||
|
const pType = pay.type || pay.paymentType || pay.payment_type;
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
key={pay.id}
|
||||||
|
variant="outlined"
|
||||||
|
onClick={this.handleOpenPayments}
|
||||||
|
sx={{
|
||||||
|
p: 1.25,
|
||||||
|
bgcolor: WHITE,
|
||||||
|
cursor: 'pointer',
|
||||||
|
transition: 'all 0.15s ease',
|
||||||
|
'&:hover': {
|
||||||
|
boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
|
||||||
|
borderColor: 'primary.main',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||||
|
<Stack direction="row" spacing={0.75} alignItems="center" sx={{ minWidth: 0, overflow: 'hidden' }}>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', color: 'text.secondary', flexShrink: 0 }}>
|
||||||
|
{typeIcon(pType, { fontSize: 16 })}
|
||||||
|
</Box>
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||||
|
{typeLabel(pType)}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Stack direction="row" spacing={1} alignItems="center" sx={{ flexShrink: 0, ml: 1 }}>
|
||||||
|
{pay.date ? (
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
{formatDate(pay.date)}
|
||||||
|
</Typography>
|
||||||
|
) : null}
|
||||||
|
<Typography
|
||||||
|
variant="subtitle2"
|
||||||
|
sx={{ fontWeight: 700, color: 'success.dark', fontVariantNumeric: 'tabular-nums' }}
|
||||||
|
>
|
||||||
|
+{formatPrice(pay.amount)}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Stack>
|
||||||
|
) : (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: 1.5,
|
||||||
|
textAlign: 'center',
|
||||||
|
bgcolor: 'rgba(255,255,255,0.6)',
|
||||||
|
borderRadius: 1,
|
||||||
|
border: '1px dashed',
|
||||||
|
borderColor: 'divider',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography variant="caption" color="text.secondary">
|
||||||
|
Noch keine Zahlungen erfasst.
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</PanelTile>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{this.renderShipmentsTile()}
|
||||||
|
{this.renderPaymentsTile()}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default OrderDocumentsTiles;
|
||||||
@@ -44,7 +44,7 @@ import {
|
|||||||
|
|
||||||
const cfg = manifestConfig('order');
|
const cfg = manifestConfig('order');
|
||||||
|
|
||||||
const PAYMENT_TYPES = [
|
export const PAYMENT_TYPES = [
|
||||||
{ value: 'transfer', label: 'Banküberweisung', icon: AccountBalanceIcon },
|
{ value: 'transfer', label: 'Banküberweisung', icon: AccountBalanceIcon },
|
||||||
{ value: 'cash', label: 'Barzahlung', icon: PointOfSaleIcon },
|
{ value: 'cash', label: 'Barzahlung', icon: PointOfSaleIcon },
|
||||||
{ value: 'card', label: 'EC- / Kreditkarte', icon: CreditCardIcon },
|
{ value: 'card', label: 'EC- / Kreditkarte', icon: CreditCardIcon },
|
||||||
@@ -54,15 +54,15 @@ const PAYMENT_TYPES = [
|
|||||||
{ value: 'other', label: 'Sonstige', icon: PaymentsIcon },
|
{ value: 'other', label: 'Sonstige', icon: PaymentsIcon },
|
||||||
];
|
];
|
||||||
|
|
||||||
function typeLabel(val) {
|
export function typeLabel(val) {
|
||||||
const match = PAYMENT_TYPES.find((t) => t.value === val);
|
const match = PAYMENT_TYPES.find((t) => t.value === val);
|
||||||
return match?.label || val || 'Zahlung';
|
return match?.label || val || 'Zahlung';
|
||||||
}
|
}
|
||||||
|
|
||||||
function typeIcon(val) {
|
export function typeIcon(val, sx = { fontSize: 18 }) {
|
||||||
const match = PAYMENT_TYPES.find((t) => t.value === val);
|
const match = PAYMENT_TYPES.find((t) => t.value === val);
|
||||||
const IconComp = match?.icon || PaymentsIcon;
|
const IconComp = match?.icon || PaymentsIcon;
|
||||||
return <IconComp sx={{ fontSize: 18 }} />;
|
return <IconComp sx={sx} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rowSx = {
|
const rowSx = {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export { default as TextEditorPanel } from './TextEditorPanel';
|
|||||||
export { default as PdfViewerPanel } from './PdfViewerPanel';
|
export { default as PdfViewerPanel } from './PdfViewerPanel';
|
||||||
export { default as ArticleSearchDialog } from './ArticleSearchDialog';
|
export { default as ArticleSearchDialog } from './ArticleSearchDialog';
|
||||||
export { default as BookDeliveryDialog } from './BookDeliveryDialog';
|
export { default as BookDeliveryDialog } from './BookDeliveryDialog';
|
||||||
|
export { default as OrderDocumentsTiles } from './OrderDocumentsTiles';
|
||||||
export { withManifestId } from './withManifestId';
|
export { withManifestId } from './withManifestId';
|
||||||
export {
|
export {
|
||||||
manifestConfig,
|
manifestConfig,
|
||||||
@@ -29,4 +30,5 @@ export {
|
|||||||
collectFilesForUpload,
|
collectFilesForUpload,
|
||||||
restoreAttachmentsFromApi,
|
restoreAttachmentsFromApi,
|
||||||
dateInputValue,
|
dateInputValue,
|
||||||
|
todayInputValue,
|
||||||
} from './manifestConfig';
|
} from './manifestConfig';
|
||||||
|
|||||||
@@ -77,6 +77,14 @@ export function numberDisplay(value) {
|
|||||||
return String(value);
|
return String(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function todayInputValue() {
|
||||||
|
const d = new Date();
|
||||||
|
const year = d.getFullYear();
|
||||||
|
const month = String(d.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(d.getDate()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function dateInputValue(iso) {
|
export function dateInputValue(iso) {
|
||||||
if (!iso) return '';
|
if (!iso) return '';
|
||||||
const d = new Date(iso);
|
const d = new Date(iso);
|
||||||
@@ -451,11 +459,12 @@ export async function buildManifestBody(
|
|||||||
const date = form.date;
|
const date = form.date;
|
||||||
if (!date) throw new Error('Datum fehlt.');
|
if (!date) throw new Error('Datum fehlt.');
|
||||||
|
|
||||||
|
const externalNumber = String(form.externalNumber ?? '').trim();
|
||||||
|
|
||||||
let body;
|
let body;
|
||||||
if (useExternalNumber) {
|
if (kind === 'delivery') {
|
||||||
// Delivery: number is server-allocated/read-only. The caller-supplied
|
// Delivery: number is server-allocated/read-only. The caller-supplied
|
||||||
// reference goes in externalNumber (nullable; empty string → null).
|
// reference goes in externalNumber (nullable; empty string → null).
|
||||||
const externalNumber = String(form.externalNumber ?? '').trim();
|
|
||||||
body = {
|
body = {
|
||||||
externalNumber: externalNumber || null,
|
externalNumber: externalNumber || null,
|
||||||
date,
|
date,
|
||||||
@@ -472,6 +481,9 @@ export async function buildManifestBody(
|
|||||||
date,
|
date,
|
||||||
lines: buildLines(form.lines, { requireAtLeastOne }),
|
lines: buildLines(form.lines, { requireAtLeastOne }),
|
||||||
};
|
};
|
||||||
|
if (useExternalNumber || form.externalNumber != null) {
|
||||||
|
body.externalNumber = externalNumber || null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (form.partyId != null && form.partyId !== '') {
|
if (form.partyId != null && form.partyId !== '') {
|
||||||
const pid = Number(form.partyId);
|
const pid = Number(form.partyId);
|
||||||
@@ -688,6 +700,7 @@ export function manifestConfig(cfgOrKind) {
|
|||||||
listAutomat: orderAutomat,
|
listAutomat: orderAutomat,
|
||||||
partiesByIdFromList: (parties) =>
|
partiesByIdFromList: (parties) =>
|
||||||
Object.fromEntries(parties.map((row) => [row.id, row])),
|
Object.fromEntries(parties.map((row) => [row.id, row])),
|
||||||
|
externalNumber: true,
|
||||||
columns: ORDER_LINE_COLUMNS,
|
columns: ORDER_LINE_COLUMNS,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user