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,
|
||||
firstName: dto.firstName,
|
||||
lastName: dto.lastName,
|
||||
firstNameEn: dto.firstNameEn?.trim() || null,
|
||||
lastNameEn: dto.lastNameEn?.trim() || null,
|
||||
cellVerifiedAt: new Date(),
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -26,6 +26,16 @@ export class CreateCustomerDto {
|
||||
@MinLength(2)
|
||||
lastName!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(2)
|
||||
firstNameEn?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(2)
|
||||
lastNameEn?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsEmail()
|
||||
email?: string;
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
UpdateInvoiceStatusDto,
|
||||
UpdateInvoiceTemplateDto,
|
||||
} 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). */
|
||||
const PUBLIC_ID_MIN = 100_000_000_000;
|
||||
@@ -214,6 +216,7 @@ export class InvoicesService {
|
||||
id: true,
|
||||
name: true,
|
||||
nameFa: true,
|
||||
settings: true,
|
||||
domains: {
|
||||
where: { isActive: true },
|
||||
orderBy: [{ isPrimary: 'desc' as const }, { createdAt: 'asc' as const }],
|
||||
@@ -427,6 +430,7 @@ export class InvoicesService {
|
||||
id: bigint;
|
||||
name: string;
|
||||
nameFa: string | null;
|
||||
settings?: Prisma.JsonValue;
|
||||
domains?: Array<{ host: string }>;
|
||||
};
|
||||
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. */
|
||||
private toPublicInvoicePayload(row: Parameters<InvoicesService['serializeInvoice']>[0]) {
|
||||
const serialized = this.serializeInvoice(row, true);
|
||||
const locale: DashboardLocale = normalizeBusinessSettings(
|
||||
row.business && 'settings' in row.business ? row.business.settings : null,
|
||||
).branding.defaultLocale;
|
||||
|
||||
return {
|
||||
publicId: serialized.publicId,
|
||||
status: serialized.status,
|
||||
name: serialized.name,
|
||||
topText: serialized.topText,
|
||||
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
|
||||
? { firstName: serialized.user.firstName, lastName: serialized.user.lastName }
|
||||
: null,
|
||||
|
||||
Reference in New Issue
Block a user