u
This commit is contained in:
@@ -9,6 +9,8 @@ import customergroupAutomat from '../../automats/customergroupAutomat';
|
||||
import deliveryAutomat from '../../automats/deliveryAutomat';
|
||||
import quoteAutomat from '../../automats/quoteAutomat';
|
||||
import orderAutomat from '../../automats/orderAutomat';
|
||||
import { getArticle } from '../../automats/artikelAutomat';
|
||||
import { selectCompanyTaxrate } from '../../automats/companyAutomat';
|
||||
import { netFromGross } from '../../utils/price';
|
||||
import {
|
||||
GREEN_PANEL,
|
||||
@@ -22,7 +24,8 @@ export const EXCLUDED_CUSTOMER_GROUP_NAMES = new Set(['Lieferanten', 'POS']);
|
||||
|
||||
export function entityDisplayName(entity) {
|
||||
if (!entity) return '';
|
||||
return [entity.firstName, entity.name].filter(Boolean).join(' ');
|
||||
const fullName = [entity.firstName, entity.name].filter(Boolean).join(' ');
|
||||
return fullName || entity.name || entity.firstName || (entity.number ? `Kunde ${entity.number}` : (entity.id ? `Kunde #${entity.id}` : ''));
|
||||
}
|
||||
|
||||
export function sortEntities(entities) {
|
||||
@@ -81,19 +84,20 @@ export function dateInputValue(iso) {
|
||||
}
|
||||
|
||||
export function emptyLine() {
|
||||
const normTax = selectCompanyTaxrate() != null ? String(selectCompanyTaxrate()) : '19';
|
||||
return {
|
||||
key: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
||||
amount: '',
|
||||
amount: '1',
|
||||
sku: '',
|
||||
tax: '',
|
||||
rebate: '',
|
||||
name: '',
|
||||
tax: normTax,
|
||||
taxrate: normTax,
|
||||
rebate: '0',
|
||||
net: '',
|
||||
gross: '',
|
||||
name: '',
|
||||
pu: '',
|
||||
pu: '1',
|
||||
unit: '',
|
||||
netprice: '',
|
||||
taxrate: '',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -148,9 +152,8 @@ export function hasArticleLines(lines) {
|
||||
if (!l) return false;
|
||||
const sku = String(l.sku ?? '').trim();
|
||||
const name = String(l.name ?? '').trim();
|
||||
const amount = String(l.amount ?? '').trim();
|
||||
const net = String(l.net ?? l.netprice ?? l.gross ?? '').trim();
|
||||
return Boolean(sku || name || amount || net);
|
||||
return Boolean(sku || name || net);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -162,7 +165,7 @@ export function buildLines(lines, { requireAtLeastOne }) {
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
const sku = String(line.sku ?? '').trim();
|
||||
const name = String(line.name ?? '').trim();
|
||||
const name = String(line.name ?? (sku ? getArticle(sku)?.name : '') ?? '').trim();
|
||||
const rawAmount = getFirstVal(line.amount, line.count);
|
||||
const amount = parseNum(rawAmount);
|
||||
const rawNet = getFirstVal(line.net, line.netprice, line.netPrice, line.eknetto);
|
||||
@@ -177,8 +180,7 @@ export function buildLines(lines, { requireAtLeastOne }) {
|
||||
const rebate = parseNum(getFirstVal(line.rebate));
|
||||
const rawPu = getFirstVal(line.pu, line.vpe);
|
||||
const pu = parseNum(rawPu);
|
||||
const blank =
|
||||
!sku && !name && amount == null && net == null && gross == null && tax == null && rebate == null;
|
||||
const blank = !sku && !name && net == null && gross == null;
|
||||
if (blank) continue;
|
||||
|
||||
const missing = [];
|
||||
@@ -499,12 +501,15 @@ export async function buildManifestBody(
|
||||
export const LINE_COLUMNS = [
|
||||
{ id: 'amount', label: 'Amount', width: 80, align: 'right', type: 'number' },
|
||||
{ id: 'sku', label: 'SKU', width: 130, align: 'left', type: 'text' },
|
||||
{ id: 'name', label: 'Name', width: 200, align: 'left', type: 'text' },
|
||||
{ id: 'tax', label: 'Tax', width: 70, align: 'right', type: 'number' },
|
||||
{ id: 'rebate', label: 'Rebate', width: 75, align: 'right', type: 'number' },
|
||||
{ id: 'net', label: 'Net', width: 95, align: 'right', type: 'number' },
|
||||
{ id: 'gross', label: 'Gross', width: 95, align: 'right', type: 'number' },
|
||||
];
|
||||
|
||||
export const QUOTE_LINE_COLUMNS = LINE_COLUMNS;
|
||||
|
||||
export const ORDER_LINE_COLUMNS = [
|
||||
{ id: 'pos', label: 'Pos', width: 44, align: 'center' },
|
||||
{ id: 'sku', label: 'SKU', width: 130, align: 'left', type: 'text' },
|
||||
@@ -557,11 +562,8 @@ export async function loadParties(cfgOrKind) {
|
||||
const list = await supplierAutomat.actions.load();
|
||||
return sortSuppliers(list);
|
||||
}
|
||||
const [entities, groups] = await Promise.all([
|
||||
entityAutomat.actions.ensureLoaded(),
|
||||
customergroupAutomat.actions.ensureLoaded(),
|
||||
]);
|
||||
return filterCustomerEntities(entities, groups);
|
||||
const entities = await entityAutomat.actions.ensureLoaded();
|
||||
return entities ?? entityAutomat.state.items ?? [];
|
||||
}
|
||||
|
||||
export function partyDisplayName(cfgOrKind, party) {
|
||||
@@ -623,7 +625,7 @@ export function manifestConfig(cfgOrKind) {
|
||||
docField: 'quote',
|
||||
partyField: 'entityId',
|
||||
listPath: '/auftrag',
|
||||
createPath: '/auftrag/neu',
|
||||
createPath: '/auftrag/neuesangebot',
|
||||
editPath: (id) => `/auftrag/${id}`,
|
||||
dateLabel: 'Gültig bis',
|
||||
partyLabel: 'Kunde',
|
||||
|
||||
Reference in New Issue
Block a user