mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
Expose invoice locale on public payloads and accept English name fields on create customer.
Public invoices need branding defaultLocale for RTL viewers; customer create aligns with the business add-customer form. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
73118f38d5
commit
49a9f0c289
@@ -286,6 +286,8 @@ export class CustomersService {
|
|||||||
email: dto.email,
|
email: dto.email,
|
||||||
firstName: dto.firstName,
|
firstName: dto.firstName,
|
||||||
lastName: dto.lastName,
|
lastName: dto.lastName,
|
||||||
|
firstNameEn: dto.firstNameEn?.trim() || null,
|
||||||
|
lastNameEn: dto.lastNameEn?.trim() || null,
|
||||||
cellVerifiedAt: new Date(),
|
cellVerifiedAt: new Date(),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -26,6 +26,16 @@ export class CreateCustomerDto {
|
|||||||
@MinLength(2)
|
@MinLength(2)
|
||||||
lastName!: string;
|
lastName!: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@MinLength(2)
|
||||||
|
firstNameEn?: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@MinLength(2)
|
||||||
|
lastNameEn?: string;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsEmail()
|
@IsEmail()
|
||||||
email?: string;
|
email?: string;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import {
|
|||||||
UpdateInvoiceStatusDto,
|
UpdateInvoiceStatusDto,
|
||||||
UpdateInvoiceTemplateDto,
|
UpdateInvoiceTemplateDto,
|
||||||
} from './dto/invoice.dto';
|
} from './dto/invoice.dto';
|
||||||
|
import { normalizeBusinessSettings } from '../business-settings/business-settings.util';
|
||||||
|
import type { DashboardLocale } from '../business-settings/business-settings.types';
|
||||||
|
|
||||||
/** 12-digit unguessable public link token (not the sequential PK). */
|
/** 12-digit unguessable public link token (not the sequential PK). */
|
||||||
const PUBLIC_ID_MIN = 100_000_000_000;
|
const PUBLIC_ID_MIN = 100_000_000_000;
|
||||||
@@ -214,6 +216,7 @@ export class InvoicesService {
|
|||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
nameFa: true,
|
nameFa: true,
|
||||||
|
settings: true,
|
||||||
domains: {
|
domains: {
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
orderBy: [{ isPrimary: 'desc' as const }, { createdAt: 'asc' as const }],
|
orderBy: [{ isPrimary: 'desc' as const }, { createdAt: 'asc' as const }],
|
||||||
@@ -427,6 +430,7 @@ export class InvoicesService {
|
|||||||
id: bigint;
|
id: bigint;
|
||||||
name: string;
|
name: string;
|
||||||
nameFa: string | null;
|
nameFa: string | null;
|
||||||
|
settings?: Prisma.JsonValue;
|
||||||
domains?: Array<{ host: string }>;
|
domains?: Array<{ host: string }>;
|
||||||
};
|
};
|
||||||
issuer?: { id: bigint; firstName: string | null; lastName: string | null } | null;
|
issuer?: { id: bigint; firstName: string | null; lastName: string | null } | null;
|
||||||
@@ -1244,13 +1248,26 @@ export class InvoicesService {
|
|||||||
/** Public payload: no internal notes / issuer / sequential id / user contact info. */
|
/** Public payload: no internal notes / issuer / sequential id / user contact info. */
|
||||||
private toPublicInvoicePayload(row: Parameters<InvoicesService['serializeInvoice']>[0]) {
|
private toPublicInvoicePayload(row: Parameters<InvoicesService['serializeInvoice']>[0]) {
|
||||||
const serialized = this.serializeInvoice(row, true);
|
const serialized = this.serializeInvoice(row, true);
|
||||||
|
const locale: DashboardLocale = normalizeBusinessSettings(
|
||||||
|
row.business && 'settings' in row.business ? row.business.settings : null,
|
||||||
|
).branding.defaultLocale;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
publicId: serialized.publicId,
|
publicId: serialized.publicId,
|
||||||
status: serialized.status,
|
status: serialized.status,
|
||||||
name: serialized.name,
|
name: serialized.name,
|
||||||
topText: serialized.topText,
|
topText: serialized.topText,
|
||||||
issuedAt: serialized.issuedAt,
|
issuedAt: serialized.issuedAt,
|
||||||
business: serialized.business,
|
locale,
|
||||||
|
business: serialized.business
|
||||||
|
? {
|
||||||
|
...serialized.business,
|
||||||
|
displayName:
|
||||||
|
locale === 'fa' && serialized.business.nameFa?.trim()
|
||||||
|
? serialized.business.nameFa.trim()
|
||||||
|
: serialized.business.name,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
user: serialized.user
|
user: serialized.user
|
||||||
? { firstName: serialized.user.firstName, lastName: serialized.user.lastName }
|
? { firstName: serialized.user.firstName, lastName: serialized.user.lastName }
|
||||||
: null,
|
: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user