feat(tahesab): add manual sync to refresh linked customer profiles
Expose sync/customers-now and a settings button so existing linked people get national id, address, city, and rasteh without waiting for the schedule. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -205,6 +205,12 @@ export class SyncGroupsPageDto {
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
/** اجرای دستی همگامسازی همهٔ مشتریان (وارد + بهروز کردن لینکشدهها) */
|
||||
export class SyncAllCustomersDto {
|
||||
@IsString()
|
||||
connectionId!: string;
|
||||
}
|
||||
|
||||
export class ExportPeopleToTahesabDto {
|
||||
@IsString()
|
||||
connectionId!: string;
|
||||
|
||||
@@ -969,6 +969,7 @@ export class TahesabPersonLinkService {
|
||||
...(duplicate ? [`${duplicate} شماره تکراری`] : []),
|
||||
`${failed} خطا`,
|
||||
].join('، ');
|
||||
const error = errors.length ? errors.join('؛ ') : null;
|
||||
await this.prisma.accountingSyncJob.create({
|
||||
data: {
|
||||
organizationId,
|
||||
@@ -978,6 +979,14 @@ export class TahesabPersonLinkService {
|
||||
result: { imported, updated, duplicate, failed, pages: page - 1 } as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
await this.prisma.accountingConnection.update({
|
||||
where: { id: connectionId },
|
||||
data: {
|
||||
customerSyncLastRunAt: new Date(),
|
||||
customerSyncLastSummary: summary,
|
||||
customerSyncLastError: error,
|
||||
},
|
||||
});
|
||||
this.logger.log(`همگامسازی مشتریان تهحساب ${connectionId}: ${summary}`);
|
||||
return {
|
||||
imported,
|
||||
@@ -985,7 +994,7 @@ export class TahesabPersonLinkService {
|
||||
duplicate,
|
||||
failed,
|
||||
summary,
|
||||
error: errors.length ? errors.join('؛ ') : null,
|
||||
error,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
SearchTahesabDto,
|
||||
SearchTahesabProductsDto,
|
||||
SyncAsnadReportDto,
|
||||
SyncAllCustomersDto,
|
||||
SyncGroupsPageDto,
|
||||
UpdateTahesabConnectionDto,
|
||||
UpdateTahesabInvoiceSettingsDto,
|
||||
@@ -237,6 +238,16 @@ export class TahesabController {
|
||||
return this.links.syncGroupsPage(user.organizationId, dto);
|
||||
}
|
||||
|
||||
/** همهٔ مشتریان تهحساب: تازهها وارد، لینکشدهها (نام/موبایل/کدملی/آدرس/شهر/رسته/گروه) بهروز */
|
||||
@Post('sync/customers-now')
|
||||
@Roles('owner', 'admin')
|
||||
syncCustomersNow(
|
||||
@CurrentUser() user: { organizationId: string },
|
||||
@Body() dto: SyncAllCustomersDto,
|
||||
) {
|
||||
return this.links.syncAllCustomers(user.organizationId, dto.connectionId);
|
||||
}
|
||||
|
||||
@Get('sync/unlinked-people')
|
||||
@Roles('owner', 'admin')
|
||||
unlinkedPeople(
|
||||
|
||||
Reference in New Issue
Block a user