import type { Customer } from "../../../../web/shared"; import type { CustomerData } from "../entities"; /** * Mapper explĂ­cito para desacoplar UI del shape de customers/shared. */ export const buildCustomerData = (customer: Customer): CustomerData => { return { id: customer.id, status: customer.status, reference: customer.reference, isCompany: customer.isCompany, name: customer.name, tradeName: customer.tradeName, tin: customer.tin, address: { street: customer.address.street, street2: null, city: customer.address.city, province: customer.address.province, postalCode: customer.address.postalCode, country: customer.address.country, }, contact: { emailPrimary: customer.contact.primaryEmail, emailSecondary: customer.contact.secondaryEmail, phonePrimary: customer.contact.primaryPhone, phoneSecondary: customer.contact.secondaryPhone, mobilePrimary: customer.contact.primaryMobile, mobileSecondary: customer.contact.secondaryMobile, fax: customer.contact.fax, website: customer.contact.website, }, legalRecord: customer.legalRecord, paymentMethod: customer.paymentMethod ? { id: customer.paymentMethod.id, name: customer.paymentMethod.name, description: customer.paymentMethod.description, } : null, paymentTerm: customer.paymentTerm ? { id: customer.paymentTerm.id, description: customer.paymentTerm.description, } : null, taxRegime: customer.taxRegime ? { code: customer.taxRegime.code, description: customer.taxRegime.description, } : null, fiscalDefaults: { usesEquivalenceSurcharge: customer.fiscalDefaults.usesEquivalenceSurcharge, usesRetention: customer.fiscalDefaults.usesRetention, }, languageCode: customer.languageCode, currencyCode: customer.currencyCode, }; };