Add article unit lookup

This commit is contained in:
2026-06-07 14:37:51 +02:00
parent 8ac9b1e58a
commit a5608ab461
9 changed files with 53 additions and 4 deletions
+20
View File
@@ -13,6 +13,7 @@ import type {
AgrarmonitorLoginStrategy,
AgrarmonitorKunde2,
AgrarmonitorRegistrierungStatus,
ArtikelEinheit,
EingangsrechnungLivesearchResult,
Firma,
Logger,
@@ -435,6 +436,25 @@ export class AgrarmonitorConnector implements AgrarmonitorConnectorResult {
});
}
async getArtikelEinheiten(): Promise<ArtikelEinheit[]> {
const response = await this.http.get('/artikel/einheiten');
await this.saveSession();
const document = this.parseHtmlDocument(response.data);
const rows = Array.from(document.querySelectorAll<HTMLTableRowElement>('table#einheiten tbody tr'));
return rows.map(row => {
const cells = Array.from(row.querySelectorAll<HTMLTableCellElement>('td'));
return {
id: this.parseNumber(row.getAttribute('data-id') ?? row.id),
bezeichnung: cells[0]?.textContent?.trim() ?? '',
kurz: cells[1]?.textContent?.trim() ?? '',
};
});
}
private createHttpClient(): AxiosInstance {
const client = wrapper(
axios.create({
+7
View File
@@ -57,6 +57,7 @@ export interface AgrarmonitorConnectorResult {
getMaschinenKategorien(): Promise<MaschinenKategorie[]>;
getMaschinen(gruppenId: number, suchstring?: string): Promise<Maschine[]>;
getFirmen(): Promise<Firma[]>;
getArtikelEinheiten(): Promise<ArtikelEinheit[]>;
}
export interface AgrarmonitorFreischaltungStatus {
@@ -170,3 +171,9 @@ export interface Firma {
id: number;
bezeichnung: string;
}
export interface ArtikelEinheit {
id: number;
bezeichnung: string;
kurz: string;
}