u
This commit is contained in:
@@ -142,11 +142,45 @@ export default function add(provider) {
|
||||
companyId,
|
||||
});
|
||||
|
||||
const upperType = String(transactionType).toUpperCase();
|
||||
const isDelivery =
|
||||
upperType === 'DELIVERY' ||
|
||||
upperType === 'GOODS_RECEIPT' ||
|
||||
(manifestArticle.manifestType === 'delivery' &&
|
||||
!upperType.includes('ADJUST') &&
|
||||
!upperType.includes('LOSS') &&
|
||||
!upperType.includes('WRITE_OFF'));
|
||||
|
||||
let historyText = transactionText;
|
||||
if (isDelivery) {
|
||||
const details = [];
|
||||
if (manifestArticle.supplierName) {
|
||||
details.push(`Lieferant: "${manifestArticle.supplierName}"`);
|
||||
}
|
||||
if (manifestArticle.net != null && Number.isFinite(Number(manifestArticle.net))) {
|
||||
const net = Number(manifestArticle.net);
|
||||
const rebate = Number(manifestArticle.rebate ?? 0);
|
||||
const taxrate = Number(manifestArticle.taxrate ?? 0);
|
||||
const netAfterRebate = net * (1 - rebate / 100);
|
||||
const brutto = netAfterRebate * (1 + taxrate / 100);
|
||||
const ekBrutto = (Math.round(brutto * 100) / 100).toFixed(2);
|
||||
details.push(`EK brutto: ${ekBrutto}`);
|
||||
}
|
||||
if (amount != null && Number.isFinite(Number(amount))) {
|
||||
details.push(`Menge: ${amount}`);
|
||||
}
|
||||
const suffix = details.length ? ` (${details.join(', ')})` : '';
|
||||
const base =
|
||||
transactionText?.trim() ||
|
||||
(manifestArticle.manifestNumber ? `Lieferung ${manifestArticle.manifestNumber}` : 'Lieferung');
|
||||
historyText = `${base}${suffix}`;
|
||||
}
|
||||
|
||||
for (const match of articleMatches.rows) {
|
||||
await runner.query(queries.INSERT_ARTICLE_HISTORY, {
|
||||
articleId: match.articleId,
|
||||
companyuserId,
|
||||
text: transactionText,
|
||||
text: historyText,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user