import type { IBillingInfoForm } from "@/features/customer/billing-info/billing-info-form"; import type { IPassengerInformation } from "@/services/eva-display/hotel/hotel-booking-request/hotel-booking-request-service.types"; import type { BillingRequest } from "@/services/eva-display/hotel/hotel-validate/hotel-validate-service.types"; export const getBillingRequestDataFromBillingForm = ( billingFormData: IBillingInfoForm, passengerWithBillingInfo: IPassengerInformation, ): BillingRequest => { const isPerson = billingFormData.billing === "person"; const isCompany = billingFormData.billing === "company"; return { IsInvoiceInformationDifferent: true, Type: isPerson ? 0 : 1, InvoiceAccountCode: null, InvoiceFirstName: isPerson ? billingFormData?.name : "", InvoiceLastName: isPerson ? billingFormData?.surname : "", Gender: passengerWithBillingInfo?.Gender ?? 0, InvoiceTitle: !isPerson ? billingFormData?.companyTitle : "", InvoiceTaxOffice: !isPerson ? billingFormData.companyTaxOffice : "", InvoiceIdentityNumber: isPerson || isCompany ? billingFormData.tc : billingFormData.taxNo, InvoiceEmail: billingFormData?.email ?? null, InvoicePhone: passengerWithBillingInfo ?.PhoneNumbers[0] as unknown as string, InvoiceAddress: { AddressName: "", Street: billingFormData.address, City: billingFormData.city, Country: billingFormData.country, PostalCode: null, }, InvoiceCountry: billingFormData?.country, }; }; export const getBillingRequestDataFromPassengerInfo = ( passengerWithBillingInfo: IPassengerInformation, ): BillingRequest => { return { IsInvoiceInformationDifferent: false, Type: 0, InvoiceAccountCode: null, InvoiceFirstName: passengerWithBillingInfo?.Name ?? "", InvoiceLastName: passengerWithBillingInfo?.Surname ?? "", Gender: passengerWithBillingInfo?.Gender ?? 0, InvoiceTitle: "", InvoiceTaxOffice: "", InvoiceIdentityNumber: passengerWithBillingInfo?.TcKimlikNo, InvoiceEmail: passengerWithBillingInfo?.Email ?? null, InvoicePhone: passengerWithBillingInfo ?.PhoneNumbers[0] as unknown as string, InvoiceAddress: passengerWithBillingInfo?.Address ?? { AddressName: null, Street: "", City: null, Country: null, PostalCode: null, }, InvoiceCountry: passengerWithBillingInfo?.Country, }; };