mirror of
http://172.20.10.11:3000/gitadmin/INSIGHT-MVP.git
synced 2026-06-25 01:36:39 +02:00
fix(crm): fix voucher ID mapping — Lexware API returns 'id' not 'voucherId'
The voucherlist endpoint returns items with 'id' field, but our interface defined it as 'voucherId', causing undefined IDs when fetching voucher details. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4924875e92
commit
068a7b81d5
2 changed files with 10 additions and 5 deletions
|
|
@ -101,15 +101,20 @@ export interface LexwareContactCreateResponse {
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
|
|
||||||
export interface LexwareVoucherListItem {
|
export interface LexwareVoucherListItem {
|
||||||
voucherId: string;
|
id: string;
|
||||||
voucherType: string;
|
voucherType: string;
|
||||||
voucherNumber: string;
|
voucherNumber: string;
|
||||||
voucherDate: string;
|
voucherDate: string;
|
||||||
voucherStatus: string;
|
voucherStatus: string;
|
||||||
totalAmount: number;
|
totalAmount: number;
|
||||||
|
openAmount?: number;
|
||||||
currency: string;
|
currency: string;
|
||||||
contactId?: string;
|
contactId?: string;
|
||||||
contactName?: string;
|
contactName?: string;
|
||||||
|
dueDate?: string;
|
||||||
|
createdDate?: string;
|
||||||
|
updatedDate?: string;
|
||||||
|
archived?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LexwareVoucherListResponse {
|
export interface LexwareVoucherListResponse {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ export class LexwareVouchersService {
|
||||||
const endpoint = voucherTypeToLexwareEndpoint(crmVoucherType);
|
const endpoint = voucherTypeToLexwareEndpoint(crmVoucherType);
|
||||||
const detail =
|
const detail =
|
||||||
await this.lexwareClient.get<LexwareVoucherDetail>(
|
await this.lexwareClient.get<LexwareVoucherDetail>(
|
||||||
`/v1/${endpoint}/${item.voucherId}`,
|
`/v1/${endpoint}/${item.id}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const cacheData = voucherDetailToCacheData(
|
const cacheData = voucherDetailToCacheData(
|
||||||
|
|
@ -92,12 +92,12 @@ export class LexwareVouchersService {
|
||||||
where: {
|
where: {
|
||||||
tenantId_lexwareVoucherId: {
|
tenantId_lexwareVoucherId: {
|
||||||
tenantId,
|
tenantId,
|
||||||
lexwareVoucherId: item.voucherId,
|
lexwareVoucherId: item.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
create: {
|
create: {
|
||||||
tenantId,
|
tenantId,
|
||||||
lexwareVoucherId: item.voucherId,
|
lexwareVoucherId: item.id,
|
||||||
...cacheData,
|
...cacheData,
|
||||||
companyId: companyId || undefined,
|
companyId: companyId || undefined,
|
||||||
contactId: contactId || undefined,
|
contactId: contactId || undefined,
|
||||||
|
|
@ -114,7 +114,7 @@ export class LexwareVouchersService {
|
||||||
totalUpserted++;
|
totalUpserted++;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.warn(
|
this.logger.warn(
|
||||||
`Fehler beim Laden von Beleg ${item.voucherId}: ${error instanceof Error ? error.message : 'Unbekannt'}`,
|
`Fehler beim Laden von Beleg ${item.id}: ${error instanceof Error ? error.message : 'Unbekannt'}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue