2026-04-03 19:49:59 +00:00
|
|
|
import type { CustomerCreationResponseDTO } from "@erp/customers/common";
|
|
|
|
|
|
|
|
|
|
import type { CustomerGetOutput, CustomerUpdateOutput } from "../api";
|
2026-03-23 11:13:33 +00:00
|
|
|
import type { Customer } from "../entities";
|
|
|
|
|
|
2026-03-31 08:21:48 +00:00
|
|
|
export const GetCustomerByIdAdapter = {
|
2026-04-03 19:49:59 +00:00
|
|
|
fromDTO(
|
|
|
|
|
dto: CustomerGetOutput | CustomerCreationResponseDTO | CustomerUpdateOutput,
|
|
|
|
|
context?: unknown
|
|
|
|
|
): Customer {
|
|
|
|
|
const taxesAdapter = (taxes: string) =>
|
|
|
|
|
taxes.split(";").filter((item) => item !== "#" && item.trim() !== "");
|
2026-03-31 08:21:48 +00:00
|
|
|
|
|
|
|
|
const defaultTaxes = taxesAdapter(dto.default_taxes);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: dto.id,
|
|
|
|
|
companyId: dto.company_id,
|
|
|
|
|
reference: dto.reference,
|
|
|
|
|
|
2026-04-03 19:49:59 +00:00
|
|
|
isCompany: dto.is_company === "1",
|
2026-03-31 08:21:48 +00:00
|
|
|
name: dto.name,
|
|
|
|
|
tradeName: dto.trade_name,
|
|
|
|
|
tin: dto.tin,
|
|
|
|
|
|
|
|
|
|
street: dto.street,
|
|
|
|
|
street2: dto.street2,
|
|
|
|
|
city: dto.city,
|
|
|
|
|
province: dto.province,
|
|
|
|
|
postalCode: dto.postal_code,
|
|
|
|
|
country: dto.country,
|
|
|
|
|
|
|
|
|
|
primaryEmail: dto.email_primary,
|
|
|
|
|
secondaryEmail: dto.email_secondary,
|
|
|
|
|
primaryPhone: dto.phone_primary,
|
|
|
|
|
secondaryPhone: dto.phone_secondary,
|
|
|
|
|
primaryMobile: dto.mobile_primary,
|
|
|
|
|
secondaryMobile: dto.mobile_secondary,
|
|
|
|
|
|
|
|
|
|
fax: dto.fax,
|
|
|
|
|
website: dto.website,
|
|
|
|
|
|
|
|
|
|
legalRecord: dto.legal_record,
|
|
|
|
|
|
|
|
|
|
defaultTaxes: defaultTaxes,
|
|
|
|
|
status: dto.status,
|
|
|
|
|
languageCode: dto.language_code,
|
|
|
|
|
currencyCode: dto.currency_code,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|