Add article livesearch lookup

This commit is contained in:
2026-06-07 14:53:44 +02:00
parent 68bb6ce061
commit b6180867ef
9 changed files with 73 additions and 4 deletions
+30
View File
@@ -13,6 +13,7 @@ import type {
AgrarmonitorLoginStrategy,
AgrarmonitorKunde2,
AgrarmonitorRegistrierungStatus,
Artikel,
ArtikelEinheit,
ArtikelKategorie,
EingangsrechnungLivesearchResult,
@@ -474,6 +475,35 @@ export class AgrarmonitorConnector implements AgrarmonitorConnectorResult {
});
}
async getArtikel(artikelGruppe: number, suchstring = ''): Promise<Artikel[]> {
const response = await this.http.get('/module/artikel/livesearch.php', {
params: {
suchstring,
artikel_aktiv: 0,
warengruppe: artikelGruppe,
lagerplatz: 0,
bestand: 0,
itemsperpage: 100000,
seite: 1,
},
});
await this.saveSession();
const document = this.parseHtmlDocument(response.data);
const rows = Array.from(document.querySelectorAll<HTMLTableRowElement>('table#artikel_table tbody tr'));
return rows.map(row => {
const cells = Array.from(row.querySelectorAll<HTMLTableCellElement>('td'));
return {
id: this.parseNumber(row.getAttribute('data-id') ?? row.id),
nummer: cells[0]?.textContent?.trim() ?? '',
bezeichnung: cells[1]?.textContent?.trim() ?? '',
};
});
}
private createHttpClient(): AxiosInstance {
const client = wrapper(
axios.create({
+7
View File
@@ -59,6 +59,7 @@ export interface AgrarmonitorConnectorResult {
getFirmen(): Promise<Firma[]>;
getArtikelEinheiten(): Promise<ArtikelEinheit[]>;
getArtikelKategorien(): Promise<ArtikelKategorie[]>;
getArtikel(artikelGruppe: number, suchstring?: string): Promise<Artikel[]>;
}
export interface AgrarmonitorFreischaltungStatus {
@@ -183,3 +184,9 @@ export interface ArtikelKategorie {
id: number;
name: string;
}
export interface Artikel {
id: number;
nummer: string;
bezeichnung: string;
}