Limpieza
This commit is contained in:
parent
3042255fad
commit
d837e4d362
@ -1,57 +0,0 @@
|
|||||||
import { IInvoicingContext } from "#/server/intrastructure";
|
|
||||||
import { CustomerRepository } from "#/server/intrastructure/Customer.repository";
|
|
||||||
|
|
||||||
export const updateCustomerController = (context: IInvoicingContext) => {
|
|
||||||
const adapter = context.adapter;
|
|
||||||
const repoManager = context.repositoryManager;
|
|
||||||
|
|
||||||
repoManager.registerRepository("Customer", (params = { transaction: null }) => {
|
|
||||||
const { transaction } = params;
|
|
||||||
|
|
||||||
return new CustomerRepository({
|
|
||||||
transaction,
|
|
||||||
adapter,
|
|
||||||
mapper: createCustomerMapper(context),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
repoManager.registerRepository("Participant", (params = { transaction: null }) => {
|
|
||||||
const { transaction } = params;
|
|
||||||
|
|
||||||
return new CustomerParticipantRepository({
|
|
||||||
transaction,
|
|
||||||
adapter,
|
|
||||||
mapper: createCustomerParticipantMapper(context),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
repoManager.registerRepository("ParticipantAddress", (params = { transaction: null }) => {
|
|
||||||
const { transaction } = params;
|
|
||||||
|
|
||||||
return new CustomerParticipantAddressRepository({
|
|
||||||
transaction,
|
|
||||||
adapter,
|
|
||||||
mapper: createCustomerParticipantAddressMapper(context),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
repoManager.registerRepository("Contact", (params = { transaction: null }) => {
|
|
||||||
const { transaction } = params;
|
|
||||||
|
|
||||||
return new ContactRepository({
|
|
||||||
transaction,
|
|
||||||
adapter,
|
|
||||||
mapper: createContactMapper(context),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateCustomerUseCase = new UpdateCustomerUseCase(context);
|
|
||||||
|
|
||||||
return new UpdateCustomerController(
|
|
||||||
{
|
|
||||||
useCase: updateCustomerUseCase,
|
|
||||||
presenter: updateCustomerPresenter,
|
|
||||||
},
|
|
||||||
context
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
import { CustomerItem } from "@/contexts/invoicing/domain/CustomerItems";
|
|
||||||
import { IInvoicingContext } from "@/contexts/invoicing/intrastructure/InvoicingContext";
|
|
||||||
import { ICollection, IMoney_Response_DTO } from "@shared/contexts";
|
|
||||||
|
|
||||||
export const customerItemPresenter = (
|
|
||||||
items: ICollection<CustomerItem>,
|
|
||||||
context: IInvoicingContext
|
|
||||||
) =>
|
|
||||||
items.totalCount > 0
|
|
||||||
? items.items.map((item: CustomerItem) => ({
|
|
||||||
description: item.description.toString(),
|
|
||||||
quantity: item.quantity.toString(),
|
|
||||||
unit_measure: "",
|
|
||||||
unit_price: item.unitPrice.toPrimitive() as IMoney_Response_DTO,
|
|
||||||
subtotal: item.calculateSubtotal().toPrimitive() as IMoney_Response_DTO,
|
|
||||||
tax_amount: item.calculateTaxAmount().toPrimitive() as IMoney_Response_DTO,
|
|
||||||
total: item.calculateTotal().toPrimitive() as IMoney_Response_DTO,
|
|
||||||
}))
|
|
||||||
: [];
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
import { ICustomerParticipant } from "@/contexts/invoicing/domain";
|
|
||||||
import { IInvoicingContext } from "@/contexts/invoicing/intrastructure/InvoicingContext";
|
|
||||||
import { IUpdateCustomer_Participant_Response_DTO } from "@shared/contexts";
|
|
||||||
import { CustomerParticipantAddressPresenter } from "./CustomerParticipantAddress.presenter";
|
|
||||||
|
|
||||||
export const CustomerParticipantPresenter = (
|
|
||||||
participant: ICustomerParticipant,
|
|
||||||
context: IInvoicingContext,
|
|
||||||
): IUpdateCustomer_Participant_Response_DTO | undefined => {
|
|
||||||
return {
|
|
||||||
id: participant.id.toString(),
|
|
||||||
tin: participant.tin.toString(),
|
|
||||||
first_name: participant.firstName.toString(),
|
|
||||||
last_name: participant.lastName.toString(),
|
|
||||||
company_name: participant.companyName.toString(),
|
|
||||||
|
|
||||||
billing_address: CustomerParticipantAddressPresenter(
|
|
||||||
participant.billingAddress!,
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
shipping_address: CustomerParticipantAddressPresenter(
|
|
||||||
participant.shippingAddress!,
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
import { CustomerParticipantAddress } from "@/contexts/invoicing/domain";
|
|
||||||
import { IInvoicingContext } from "@/contexts/invoicing/intrastructure/InvoicingContext";
|
|
||||||
import { IUpdateCustomer_AddressParticipant_Response_DTO } from "@shared/contexts";
|
|
||||||
|
|
||||||
export const CustomerParticipantAddressPresenter = (
|
|
||||||
address: CustomerParticipantAddress,
|
|
||||||
context: IInvoicingContext,
|
|
||||||
): IUpdateCustomer_AddressParticipant_Response_DTO => {
|
|
||||||
return {
|
|
||||||
id: address.id.toString(),
|
|
||||||
street: address.street.toString(),
|
|
||||||
city: address.city.toString(),
|
|
||||||
postal_code: address.postalCode.toString(),
|
|
||||||
province: address.province.toString(),
|
|
||||||
country: address.country.toString(),
|
|
||||||
email: address.email.toString(),
|
|
||||||
phone: address.phone.toString(),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
import { Customer } from "@/contexts/invoicing/domain";
|
|
||||||
import { IInvoicingContext } from "@/contexts/invoicing/intrastructure/InvoicingContext";
|
|
||||||
import { IUpdateCustomer_Response_DTO } from "@shared/contexts";
|
|
||||||
import { customerItemPresenter } from "./CustomerItem.presenter";
|
|
||||||
import { CustomerParticipantPresenter } from "./CustomerParticipant.presenter";
|
|
||||||
|
|
||||||
export interface IUpdateCustomerPresenter {
|
|
||||||
map: (customer: Customer, context: IInvoicingContext) => IUpdateCustomer_Response_DTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const updateCustomerPresenter: IUpdateCustomerPresenter = {
|
|
||||||
map: (customer: Customer, context: IInvoicingContext): IUpdateCustomer_Response_DTO => {
|
|
||||||
return {
|
|
||||||
id: customer.id.toString(),
|
|
||||||
|
|
||||||
customer_status: customer.status.toString(),
|
|
||||||
customer_number: customer.customerNumber.toString(),
|
|
||||||
customer_series: customer.customerSeries.toString(),
|
|
||||||
invoice_date: customer.invoiceDate.toISO8601(),
|
|
||||||
operation_date: customer.operationDate.toISO8601(),
|
|
||||||
language_code: customer.language.toString(),
|
|
||||||
currency: customer.currency.toString(),
|
|
||||||
subtotal: customer.calculateSubtotal().toPrimitive(),
|
|
||||||
total: customer.calculateTotal().toPrimitive(),
|
|
||||||
|
|
||||||
//sender: {}, //await CustomerParticipantPresenter(customer.senderId, context),
|
|
||||||
|
|
||||||
recipient: CustomerParticipantPresenter(customer.recipient, context),
|
|
||||||
|
|
||||||
items: customerItemPresenter(customer.items, context),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@ -1 +0,0 @@
|
|||||||
export * from "./UpdateCustomer.presenter";
|
|
||||||
Loading…
Reference in New Issue
Block a user