.
This commit is contained in:
parent
f96830c3d0
commit
74b67d1e2c
@ -1,7 +1,7 @@
|
||||
import { MoneyDTOHelper, PercentageDTOHelper, QuantityDTOHelper } from "@erp/core";
|
||||
|
||||
import type { GetProformaByIdResponseDTO } from "../../../../common";
|
||||
import type { CreateProformaResult, UpdateProformaByIdResult } from "../api";
|
||||
import type { GetProformaByIdResult } from "../api";
|
||||
import type {
|
||||
Proforma,
|
||||
ProformaItem,
|
||||
@ -10,10 +10,17 @@ import type {
|
||||
ProformaTaxSummary,
|
||||
} from "../entities";
|
||||
|
||||
/**
|
||||
* Adaptador para transformar los datos de la API de GetProformaByIdResult
|
||||
* a la entidad Proforma utilizada en la aplicación.
|
||||
*
|
||||
* @params dto - datos de la proforma desde la API.
|
||||
* @param context - Contexto adicional opcional para la adaptación.
|
||||
* @returns Objeto adaptado a Proforma.
|
||||
*/
|
||||
|
||||
export const GetProformaByIdAdapter = {
|
||||
fromDto(
|
||||
dto: GetProformaByIdResponseDTO | CreateProformaResult | UpdateProformaByIdResult
|
||||
): Proforma {
|
||||
fromDto(dto: GetProformaByIdResult): Proforma {
|
||||
return {
|
||||
id: dto.id,
|
||||
companyId: dto.company_id,
|
||||
@ -37,7 +44,7 @@ export const GetProformaByIdAdapter = {
|
||||
recipient: mapRecipient(dto.recipient),
|
||||
taxes: dto.taxes.map(mapTaxSummary),
|
||||
|
||||
paymentMethod: dto.payment_method?.payment_id ?? "",
|
||||
paymentMethod: dto.payment_method?.payment_id,
|
||||
|
||||
subtotalAmount: MoneyDTOHelper.toNumber(dto.subtotal_amount),
|
||||
|
||||
|
||||
@ -1,24 +1,17 @@
|
||||
import type { CreateCustomerResult, GetCustomerByIdResult, UpdateCustomerByIdResult } from "../api";
|
||||
import type { GetCustomerByIdResult } from "../api";
|
||||
import type { Customer } from "../entities";
|
||||
|
||||
/**
|
||||
* Adaptador para transformar los datos de la API de GetCustomerByIdResult, CustomerCreationResponseDTO o UpdateCustomerByIdResult
|
||||
* Adaptador para transformar los datos de la API de GetCustomerByIdResultt
|
||||
* a la entidad Customer utilizada en la aplicación.
|
||||
* Reglas de adaptación:
|
||||
* - id, company_id, reference se asignan directamente.
|
||||
* - is_company se convierte a booleano (true si es "1", false si es "0").
|
||||
* - default_taxes se divide por ";" y se filtran los valores vacíos o "#".
|
||||
*
|
||||
* @params dto - datos del cliente desde la API.
|
||||
* @param context - Contexto adicional opcional para la adaptación.
|
||||
* @returns {Customer} Objeto adaptado a Customer.
|
||||
* @returns Objeto adaptado a Customer.
|
||||
*/
|
||||
|
||||
export const GetCustomerByIdAdapter = {
|
||||
fromDTO(
|
||||
dto: GetCustomerByIdResult | CreateCustomerResult | UpdateCustomerByIdResult,
|
||||
context?: unknown
|
||||
): Customer {
|
||||
fromDTO(dto: GetCustomerByIdResult, context?: unknown): Customer {
|
||||
const taxesAdapter = (taxes: string) =>
|
||||
taxes.split(";").filter((item) => item !== "#" && item.trim() !== "");
|
||||
|
||||
|
||||
@ -1,8 +1,17 @@
|
||||
import type { CreateSupplierResult, GetSupplierByIdResult, UpdateSupplierByIdResult } from "../api";
|
||||
import type { GetSupplierByIdResult } from "../api";
|
||||
import type { Supplier } from "../entities";
|
||||
|
||||
/**
|
||||
* Adaptador para transformar los datos de la API de GetSupplierByIdResult
|
||||
* a la entidad Supplier utilizada en la aplicación.
|
||||
*
|
||||
* @params dto - datos del proveedor desde la API.
|
||||
* @param context - Contexto adicional opcional para la adaptación.
|
||||
* @returns Objeto adaptado a Supplier.
|
||||
*/
|
||||
|
||||
export const GetSupplierByIdAdapter = {
|
||||
fromDTO(dto: GetSupplierByIdResult | CreateSupplierResult | UpdateSupplierByIdResult): Supplier {
|
||||
fromDTO(dto: GetSupplierByIdResult): Supplier {
|
||||
return {
|
||||
id: dto.id,
|
||||
companyId: dto.company_id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user