mirror of
http://172.20.10.11:3000/gitadmin/INSIGHT-MVP.git
synced 2026-06-24 23:56:40 +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 {
|
||||
voucherId: string;
|
||||
id: string;
|
||||
voucherType: string;
|
||||
voucherNumber: string;
|
||||
voucherDate: string;
|
||||
voucherStatus: string;
|
||||
totalAmount: number;
|
||||
openAmount?: number;
|
||||
currency: string;
|
||||
contactId?: string;
|
||||
contactName?: string;
|
||||
dueDate?: string;
|
||||
createdDate?: string;
|
||||
updatedDate?: string;
|
||||
archived?: boolean;
|
||||
}
|
||||
|
||||
export interface LexwareVoucherListResponse {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ export class LexwareVouchersService {
|
|||
const endpoint = voucherTypeToLexwareEndpoint(crmVoucherType);
|
||||
const detail =
|
||||
await this.lexwareClient.get<LexwareVoucherDetail>(
|
||||
`/v1/${endpoint}/${item.voucherId}`,
|
||||
`/v1/${endpoint}/${item.id}`,
|
||||
);
|
||||
|
||||
const cacheData = voucherDetailToCacheData(
|
||||
|
|
@ -92,12 +92,12 @@ export class LexwareVouchersService {
|
|||
where: {
|
||||
tenantId_lexwareVoucherId: {
|
||||
tenantId,
|
||||
lexwareVoucherId: item.voucherId,
|
||||
lexwareVoucherId: item.id,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
tenantId,
|
||||
lexwareVoucherId: item.voucherId,
|
||||
lexwareVoucherId: item.id,
|
||||
...cacheData,
|
||||
companyId: companyId || undefined,
|
||||
contactId: contactId || undefined,
|
||||
|
|
@ -114,7 +114,7 @@ export class LexwareVouchersService {
|
|||
totalUpserted++;
|
||||
} catch (error) {
|
||||
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