This commit is contained in:
seb
2026-10-28 00:08:45 +01:00
parent fab291f68e
commit 96d0ae6742
88 changed files with 3871 additions and 5334 deletions

View File

@@ -6,7 +6,7 @@ import {
netFromGross,
parsePriceInput,
} from './price';
import brandAutomat from '../automats/brandAutomat';
import companyAutomat from '../automats/companyAutomat';
export function sortedPhotos(article) {
if (!Array.isArray(article?.photos)) return [];
@@ -176,7 +176,7 @@ export function getArticleBrand(article) {
return String(article.brandName).trim();
}
if (article.brandId != null) {
const brands = brandAutomat?.state?.brands || [];
const brands = companyAutomat?.state?.brands || [];
const b = brands.find((x) => x.id === article.brandId);
if (b?.name) return String(b.name).trim();
}

View File

@@ -1,4 +1,4 @@
import numberAutomat from '../automats/numberAutomat';
import companyAutomat from '../automats/companyAutomat';
import quoteAutomat from '../automats/quoteAutomat';
import orderAutomat from '../automats/orderAutomat';
import deliveryAutomat from '../automats/deliveryAutomat';
@@ -41,7 +41,7 @@ export function formatNumberPattern(prefix, padding, next) {
* @returns {string}
*/
export function getNextDocumentNumber(kind) {
const numbers = numberAutomat.state.items ?? [];
const numbers = companyAutomat.state.numbers ?? [];
const seq = numbers.find((r) => r.type === kind);
let prefix = '';
@@ -135,7 +135,7 @@ export function getNextDocumentNumber(kind) {
export async function ensureDocumentNumber(kind) {
const listAutomat = kind === 'quote' ? quoteAutomat : (kind === 'order' ? orderAutomat : (kind === 'delivery' ? deliveryAutomat : (kind === 'retoure' ? retoureAutomat : null)));
await Promise.all([
numberAutomat.actions.ensureLoaded().catch(() => {}),
companyAutomat.actions.ensureNumbersLoaded().catch(() => {}),
listAutomat?.actions?.ensureLoaded ? listAutomat.actions.ensureLoaded().catch(() => {}) : Promise.resolve(),
]);
@@ -156,7 +156,7 @@ export async function ensureDocumentNumber(kind) {
}
if (recentDocs.length > 0) {
const numbers = numberAutomat.state.items ?? [];
const numbers = companyAutomat.state.numbers ?? [];
const seq = numbers.find((r) => r.type === kind);
let prefix = seq?.prefix;
if (prefix == null) {
@@ -197,7 +197,7 @@ export async function ensureDocumentNumber(kind) {
* @returns {string}
*/
export function getMaxDocumentNumber(kind = 'quote') {
const numbers = numberAutomat.state.items ?? [];
const numbers = companyAutomat.state.numbers ?? [];
const seq = numbers.find((r) => r.type === kind);
if (seq) {
const pad = Math.max(1, Number(seq.padding) || 6);

View File

@@ -1,5 +1,5 @@
import { ledger as defaultLedgerApi, shipment as defaultShipmentApi } from '../api';
import warehouseAutomat from '../automats/warehouseAutomat';
import companyAutomat from '../automats/companyAutomat';
/**
* Fetches ledger entries for an order by inspecting:
@@ -100,7 +100,7 @@ export async function fetchOrderLedgerEntries(orderId, {
})
);
const warehouses = warehouseAutomat.state.warehouses || [];
const warehouses = companyAutomat.state.warehouses || [];
const allEntries = [];
for (const { target, entries } of results) {