u
This commit is contained in:
@@ -431,18 +431,67 @@ class LieferungNeuPage extends PureComponent {
|
||||
async handleAssignArticleForLine(article, line) {
|
||||
const { partyId } = this.state;
|
||||
if (!partyId) {
|
||||
enqueueSnackbar('Bitte wählen Sie zuerst einen Lieferanten aus.', { variant: 'warning' });
|
||||
return;
|
||||
const msg = 'Bitte wählen Sie zuerst einen Lieferanten aus.';
|
||||
enqueueSnackbar(msg, { variant: 'warning' });
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
const internalSku = article?.sku;
|
||||
if (!internalSku) {
|
||||
enqueueSnackbar('Artikel hat keine SKU.', { variant: 'error' });
|
||||
return;
|
||||
const msg = 'Artikel hat keine SKU.';
|
||||
enqueueSnackbar(msg, { variant: 'error' });
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
const supplierSku = line?.sku;
|
||||
|
||||
if (!line) {
|
||||
const supplierArticle =
|
||||
this.state.supplierArticlesMap?.[internalSku.toLowerCase()] ||
|
||||
this.state.supplierArticlesMap?.[internalSku] ||
|
||||
this.state.supplierArticles?.find(
|
||||
(sa) => sa.article?.sku === internalSku || sa.sku === internalSku
|
||||
);
|
||||
|
||||
const supplierSkuVal = supplierArticle?.sku || '';
|
||||
const netVal =
|
||||
supplierArticle?.price?.net != null
|
||||
? String(supplierArticle.price.net)
|
||||
: article.price != null
|
||||
? String(article.price)
|
||||
: article.net != null
|
||||
? String(article.net)
|
||||
: '';
|
||||
const taxVal =
|
||||
supplierArticle?.price?.taxRate != null
|
||||
? String(supplierArticle.price.taxRate)
|
||||
: article.taxrate != null
|
||||
? String(article.taxrate)
|
||||
: article.tax != null
|
||||
? String(article.tax)
|
||||
: '';
|
||||
const puVal = supplierArticle?.pu != null ? Number(supplierArticle.pu) : 1;
|
||||
|
||||
this.automat.actions.addLineitem({
|
||||
amount: 1,
|
||||
sku: supplierSkuVal || internalSku,
|
||||
name: article.name || supplierArticle?.article?.name || '',
|
||||
tax: taxVal,
|
||||
taxrate: taxVal,
|
||||
net: netVal,
|
||||
netprice: netVal,
|
||||
pu: puVal,
|
||||
});
|
||||
|
||||
enqueueSnackbar(`Artikel "${internalSku}" hinzugefügt.`, { variant: 'success' });
|
||||
|
||||
this.setState({
|
||||
articleSearchDialogOpen: false,
|
||||
articleSearchLine: null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await articleApi.addSupplier(internalSku, {
|
||||
entityId: partyId,
|
||||
@@ -454,9 +503,15 @@ class LieferungNeuPage extends PureComponent {
|
||||
});
|
||||
|
||||
if (supplierSku) {
|
||||
this.automat.actions.fetchSupplierArticleForSku(supplierSku, line.key);
|
||||
} else {
|
||||
this.automat.actions.fetchSupplierArticles(partyId);
|
||||
await this.automat.actions.fetchSupplierArticleForSku(supplierSku, line.key);
|
||||
}
|
||||
await this.automat.actions.fetchSupplierArticles(partyId);
|
||||
|
||||
if (!line.name && article.name) {
|
||||
this.automat.actions.updateLineitem({
|
||||
...line,
|
||||
name: article.name,
|
||||
});
|
||||
}
|
||||
|
||||
enqueueSnackbar(
|
||||
@@ -1131,6 +1186,7 @@ class LieferungNeuPage extends PureComponent {
|
||||
columns={DELIVERY_LINE_COLUMNS}
|
||||
lines={lines}
|
||||
saving={saving}
|
||||
partyId={this.state.partyId}
|
||||
wide={
|
||||
this.state.viewerPosition === 'right' && this.isViewerOpen()
|
||||
? 2
|
||||
@@ -1180,6 +1236,8 @@ class LieferungNeuPage extends PureComponent {
|
||||
open={this.state.articleSearchDialogOpen}
|
||||
line={this.state.articleSearchLine}
|
||||
kind="delivery"
|
||||
partyId={this.state.partyId}
|
||||
supplierArticles={this.state.supplierArticles}
|
||||
onClose={this.handleCloseArticleSearch}
|
||||
onAssign={this.handleAssignArticleForLine}
|
||||
/>
|
||||
@@ -1197,6 +1255,7 @@ class LieferungNeuPage extends PureComponent {
|
||||
summary={this.state.ledgerSummary}
|
||||
prefillLineId={this.state.bookDeliveryPrefillLineId}
|
||||
partyName={this.state.deliveryEntities?.find((p) => p.id === this.state.partyId)?.name}
|
||||
supplierArticlesMap={this.state.supplierArticlesMap}
|
||||
onClose={this.handleCloseBookDialog}
|
||||
onBookSuccess={this.handleBookSuccess}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user