import type { CustomerCreationResponseDTO } from "@erp/customers/common"; import type { CustomerGetOutput, CustomerUpdateOutput } from "../api"; import type { Customer } from "../entities"; export const GetCustomerByIdAdapter = { fromDTO( dto: CustomerGetOutput | CustomerCreationResponseDTO | CustomerUpdateOutput, context?: unknown ): Customer { const taxesAdapter = (taxes: string) => taxes.split(";").filter((item) => item !== "#" && item.trim() !== ""); const defaultTaxes = taxesAdapter(dto.default_taxes); return { id: dto.id, companyId: dto.company_id, reference: dto.reference, isCompany: dto.is_company === "1", 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, }; }, };