From 5781fbdb24c880fab4786ce8c8f6e3f6aa84e4dd Mon Sep 17 00:00:00 2001 From: David Arranz Date: Mon, 23 Sep 2024 19:37:09 +0200 Subject: [PATCH] . --- .../app/catalog/components/CatalogDataTable.tsx | 4 ++-- .../editors/QuoteDetailsCardEditor.tsx | 16 ++++++++++++++++ client/src/app/quotes/edit.tsx | 2 ++ client/src/app/quotes/list.tsx | 2 +- client/src/locales/i18n.ts | 2 +- .../application/Quote/CreateQuote.useCase.ts | 8 ++++---- .../application/Quote/UpdateQuote.useCase.ts | 8 ++++---- .../sales/domain/entities/Quotes/QuoteItem.ts | 8 ++++---- .../presenter/CreateQuote.presenter.ts | 2 +- .../getQuote/presenter/GetQuote.presenter.ts | 2 +- .../reportQuote/reporter/ReportQuote.reporter.ts | 2 +- .../presenter/UpdateQuote.presenter.ts | 2 +- .../infrastructure/mappers/quoteItem.mapper.ts | 6 +++--- .../CreateQuote.dto/ICreateQuote_Request.dto.ts | 2 +- .../CreateQuote.dto/ICreateQuote_Response.dto.ts | 2 +- .../Quote/GetQuote.dto/IGetQuote_Response.dto.ts | 2 +- .../UpdateQuote.dto/IUpdateQuote_Request.dto.ts | 2 +- .../UpdateQuote.dto/IUpdateQuote_Response.dto.ts | 2 +- 18 files changed, 46 insertions(+), 28 deletions(-) diff --git a/client/src/app/catalog/components/CatalogDataTable.tsx b/client/src/app/catalog/components/CatalogDataTable.tsx index 670fc94..ef83a07 100644 --- a/client/src/app/catalog/components/CatalogDataTable.tsx +++ b/client/src/app/catalog/components/CatalogDataTable.tsx @@ -31,7 +31,7 @@ export const CatalogDataTable = () => { accessorKey: "id", }, { - id: "article_id" as const, + id: "id_article" as const, accessorKey: "id_article", }, { @@ -71,7 +71,7 @@ export const CatalogDataTable = () => { initialState: { columnVisibility: { id: false, - article_id: false, + id_article: false, catalog_name: false, }, }, diff --git a/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx b/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx index a3a367e..bfb8a2e 100644 --- a/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx +++ b/client/src/app/quotes/components/editors/QuoteDetailsCardEditor.tsx @@ -54,6 +54,21 @@ export const QuoteDetailsCardEditor = ({ enableSorting: false, enableResizing: false, },*/ + /*{ + id: "id_article" as const, + accessorKey: "id_article", + header: "artículo", + cell: ({ row: { index, original } }) => { + return ( + + ); + }, + size: 500, + },*/ { id: "description" as const, accessorKey: "description", @@ -200,6 +215,7 @@ export const QuoteDetailsCardEditor = ({ const handleAppendCatalogArticle = useCallback( (article: any) => { + console.log(article); fieldActions.append({ ...article, quantity: { diff --git a/client/src/app/quotes/edit.tsx b/client/src/app/quotes/edit.tsx index f0ae32f..a460bd8 100644 --- a/client/src/app/quotes/edit.tsx +++ b/client/src/app/quotes/edit.tsx @@ -91,6 +91,7 @@ export const QuoteEdit = () => { }, items: [ { + id_article: "", description: "", quantity: { amount: null, @@ -139,6 +140,7 @@ export const QuoteEdit = () => { const onSubmit = async (data: QuoteDataForm, shouldRedirect: boolean) => { // Transformación del form -> typo de request + console.log(data); mutate(data, { onError: (error) => { diff --git a/client/src/app/quotes/list.tsx b/client/src/app/quotes/list.tsx index 6d7f6fa..3fb9896 100644 --- a/client/src/app/quotes/list.tsx +++ b/client/src/app/quotes/list.tsx @@ -34,7 +34,7 @@ export const QuotesList = () => { { value: "draft", label: t("quotes.list.tabs.draft") }, { value: "ready", label: t("quotes.list.tabs.ready") }, { value: "delivered", label: t("quotes.list.tabs.delivered") }, - { value: "accepted", label: t("quotes.list.tabs.delivered") }, + { value: "accepted", label: t("quotes.list.tabs.accepted") }, { value: "rejected", label: t("quotes.list.tabs.rejected") }, { value: "archived", label: t("quotes.list.tabs.archived") }, ]; diff --git a/client/src/locales/i18n.ts b/client/src/locales/i18n.ts index 0d62491..e926d84 100644 --- a/client/src/locales/i18n.ts +++ b/client/src/locales/i18n.ts @@ -14,7 +14,7 @@ i18n // init i18next // for all options read: https://www.i18next.com/overview/configuration-options .init({ - debug: true, + debug: false, fallbackLng: "es", interpolation: { escapeValue: false, diff --git a/server/src/contexts/sales/application/Quote/CreateQuote.useCase.ts b/server/src/contexts/sales/application/Quote/CreateQuote.useCase.ts index e6f4936..e73bef6 100644 --- a/server/src/contexts/sales/application/Quote/CreateQuote.useCase.ts +++ b/server/src/contexts/sales/application/Quote/CreateQuote.useCase.ts @@ -210,9 +210,9 @@ export class CreateQuoteUseCase try { items = new Collection( quoteDTO.items?.map((item) => { - const articleIdOrError = ArticleIdentifier.create(item.article_id); - if (articleIdOrError.isFailure) { - throw articleIdOrError.error; + const idArticleOrError = ArticleIdentifier.create(item.id_article); + if (idArticleOrError.isFailure) { + throw idArticleOrError.error; } const descriptionOrError = Description.create(item.description); @@ -246,7 +246,7 @@ export class CreateQuoteUseCase } const quoteItemOrError = QuoteItem.create({ - articleId: articleIdOrError.object, + idArticle: idArticleOrError.object, description: descriptionOrError.object, quantity: quantityOrError.object, unitPrice: unitPriceOrError.object, diff --git a/server/src/contexts/sales/application/Quote/UpdateQuote.useCase.ts b/server/src/contexts/sales/application/Quote/UpdateQuote.useCase.ts index 49b4c45..59e76c5 100644 --- a/server/src/contexts/sales/application/Quote/UpdateQuote.useCase.ts +++ b/server/src/contexts/sales/application/Quote/UpdateQuote.useCase.ts @@ -199,9 +199,9 @@ export class UpdateQuoteUseCase try { items = new Collection( quoteDTO.items?.map((item) => { - const articleIdOrError = ArticleIdentifier.create(item.article_id); - if (articleIdOrError.isFailure) { - throw articleIdOrError.error; + const idArticleOrError = ArticleIdentifier.create(item.id_article); + if (idArticleOrError.isFailure) { + throw idArticleOrError.error; } const descriptionOrError = Description.create(item.description); @@ -235,7 +235,7 @@ export class UpdateQuoteUseCase } const quoteItemOrError = QuoteItem.create({ - articleId: articleIdOrError.object, + idArticle: idArticleOrError.object, description: descriptionOrError.object, quantity: quantityOrError.object, unitPrice: unitPriceOrError.object, diff --git a/server/src/contexts/sales/domain/entities/Quotes/QuoteItem.ts b/server/src/contexts/sales/domain/entities/Quotes/QuoteItem.ts index 613e1f5..c98a2b6 100644 --- a/server/src/contexts/sales/domain/entities/Quotes/QuoteItem.ts +++ b/server/src/contexts/sales/domain/entities/Quotes/QuoteItem.ts @@ -12,7 +12,7 @@ import { } from "@shared/contexts"; export interface IQuoteItemProps extends IEntityProps { - articleId: ArticleIdentifier; + idArticle: ArticleIdentifier; description: Description; // Descripción del artículo o servicio quantity: Quantity; // Cantidad de unidades unitPrice: MoneyValue; // Precio unitario en la moneda de la factura @@ -22,7 +22,7 @@ export interface IQuoteItemProps extends IEntityProps { } export interface IQuoteItem { - articleId: ArticleIdentifier; + idArticle: ArticleIdentifier; description: Description; quantity: Quantity; unitPrice: MoneyValue; @@ -36,8 +36,8 @@ export class QuoteItem extends Entity implements IQuoteItem { return Result.ok(new QuoteItem(props, id)); } - get articleId(): ArticleIdentifier { - return this.props.articleId; + get idArticle(): ArticleIdentifier { + return this.props.idArticle; } get description(): Description { diff --git a/server/src/contexts/sales/infrastructure/express/controllers/quotes/createQuote/presenter/CreateQuote.presenter.ts b/server/src/contexts/sales/infrastructure/express/controllers/quotes/createQuote/presenter/CreateQuote.presenter.ts index 75ed734..6072dfb 100644 --- a/server/src/contexts/sales/infrastructure/express/controllers/quotes/createQuote/presenter/CreateQuote.presenter.ts +++ b/server/src/contexts/sales/infrastructure/express/controllers/quotes/createQuote/presenter/CreateQuote.presenter.ts @@ -52,7 +52,7 @@ const quoteItemPresenter = ( ): ICreateQuote_QuoteItem_Response_DTO[] => items.totalCount > 0 ? items.items.map((item: QuoteItem) => ({ - article_id: item.articleId.toString(), + id_article: item.idArticle.toString(), description: item.description.toString(), quantity: item.quantity.convertScale(2).toObject(), unit_price: item.unitPrice.convertScale(4).toObject(), diff --git a/server/src/contexts/sales/infrastructure/express/controllers/quotes/getQuote/presenter/GetQuote.presenter.ts b/server/src/contexts/sales/infrastructure/express/controllers/quotes/getQuote/presenter/GetQuote.presenter.ts index 87675aa..d974ec1 100644 --- a/server/src/contexts/sales/infrastructure/express/controllers/quotes/getQuote/presenter/GetQuote.presenter.ts +++ b/server/src/contexts/sales/infrastructure/express/controllers/quotes/getQuote/presenter/GetQuote.presenter.ts @@ -52,7 +52,7 @@ const quoteItemPresenter = ( ): IGetQuote_QuoteItem_Response_DTO[] => items.totalCount > 0 ? items.items.map((item: QuoteItem) => ({ - article_id: item.articleId.toString(), + id_article: item.idArticle.toString(), description: item.description.toString(), quantity: item.quantity.convertScale(2).toObject(), unit_price: item.unitPrice.convertScale(4).toObject(), diff --git a/server/src/contexts/sales/infrastructure/express/controllers/quotes/reportQuote/reporter/ReportQuote.reporter.ts b/server/src/contexts/sales/infrastructure/express/controllers/quotes/reportQuote/reporter/ReportQuote.reporter.ts index 8e9b3e8..645ea18 100644 --- a/server/src/contexts/sales/infrastructure/express/controllers/quotes/reportQuote/reporter/ReportQuote.reporter.ts +++ b/server/src/contexts/sales/infrastructure/express/controllers/quotes/reportQuote/reporter/ReportQuote.reporter.ts @@ -111,7 +111,7 @@ const map = async (quote: Quote, context: ISalesContext) => { const quoteItemPresenter = (items: ICollection, context: ISalesContext): any[] => items.totalCount > 0 ? items.items.map((item: QuoteItem) => ({ - article_id: item.articleId.toString(), + id_article: item.idArticle.toString(), description: item.description.toString(), quantity: item.quantity.toFormat(), unit_price: item.unitPrice.toFormat(), diff --git a/server/src/contexts/sales/infrastructure/express/controllers/quotes/updateQuote/presenter/UpdateQuote.presenter.ts b/server/src/contexts/sales/infrastructure/express/controllers/quotes/updateQuote/presenter/UpdateQuote.presenter.ts index 8ff72e2..3240640 100644 --- a/server/src/contexts/sales/infrastructure/express/controllers/quotes/updateQuote/presenter/UpdateQuote.presenter.ts +++ b/server/src/contexts/sales/infrastructure/express/controllers/quotes/updateQuote/presenter/UpdateQuote.presenter.ts @@ -52,7 +52,7 @@ const quoteItemPresenter = ( ): IUpdateQuote_QuoteItem_Response_DTO[] => items.totalCount > 0 ? items.items.map((item: QuoteItem) => ({ - article_id: item.articleId.toString(), + id_article: item.idArticle.toString(), description: item.description.toString(), quantity: item.quantity.convertScale(2).toObject(), unit_price: item.unitPrice.convertScale(4).toObject(), diff --git a/server/src/contexts/sales/infrastructure/mappers/quoteItem.mapper.ts b/server/src/contexts/sales/infrastructure/mappers/quoteItem.mapper.ts index c8feda8..d380919 100644 --- a/server/src/contexts/sales/infrastructure/mappers/quoteItem.mapper.ts +++ b/server/src/contexts/sales/infrastructure/mappers/quoteItem.mapper.ts @@ -23,10 +23,10 @@ class QuoteItemMapper const { sourceParent } = params; const id = this.mapsValue(source, "item_id", UniqueID.create); - const articleId = this.mapsValue(source, "id_article", ArticleIdentifier.create); + const idArticle = this.mapsValue(source, "id_article", ArticleIdentifier.create); const props: IQuoteItemProps = { - articleId, + idArticle, description: this.mapsValue(source, "description", Description.create), quantity: this.mapsValue(source, "quantity", (quantity) => Quantity.create({ @@ -86,7 +86,7 @@ class QuoteItemMapper item_id: source.id.toString(), quote_id: sourceParent.id.toPrimitive(), position: index, - id_article: source.articleId.toPrimitive(), + id_article: source.idArticle.toPrimitive(), description: source.description.toPrimitive(), quantity: source.quantity.convertScale(2).toPrimitive(), unit_price: source.unitPrice.convertScale(4).toPrimitive(), diff --git a/shared/lib/contexts/sales/application/dto/Quote/CreateQuote.dto/ICreateQuote_Request.dto.ts b/shared/lib/contexts/sales/application/dto/Quote/CreateQuote.dto/ICreateQuote_Request.dto.ts index c88fdcf..625651a 100644 --- a/shared/lib/contexts/sales/application/dto/Quote/CreateQuote.dto/ICreateQuote_Request.dto.ts +++ b/shared/lib/contexts/sales/application/dto/Quote/CreateQuote.dto/ICreateQuote_Request.dto.ts @@ -30,7 +30,7 @@ export interface ICreateQuote_Request_DTO { } export interface ICreateQuoteItem_Request_DTO { - article_id: string; + id_article: string; quantity: IQuantity_Response_DTO; description: string; unit_price: IMoney_Response_DTO; diff --git a/shared/lib/contexts/sales/application/dto/Quote/CreateQuote.dto/ICreateQuote_Response.dto.ts b/shared/lib/contexts/sales/application/dto/Quote/CreateQuote.dto/ICreateQuote_Response.dto.ts index 91cb958..85582f3 100644 --- a/shared/lib/contexts/sales/application/dto/Quote/CreateQuote.dto/ICreateQuote_Response.dto.ts +++ b/shared/lib/contexts/sales/application/dto/Quote/CreateQuote.dto/ICreateQuote_Response.dto.ts @@ -28,7 +28,7 @@ export interface ICreateQuote_Response_DTO { } export interface ICreateQuote_QuoteItem_Response_DTO { - article_id: string; + id_article: string; quantity: IQuantity_DTO; description: string; unit_price: IMoney_DTO; diff --git a/shared/lib/contexts/sales/application/dto/Quote/GetQuote.dto/IGetQuote_Response.dto.ts b/shared/lib/contexts/sales/application/dto/Quote/GetQuote.dto/IGetQuote_Response.dto.ts index 7bc9233..e1026fd 100644 --- a/shared/lib/contexts/sales/application/dto/Quote/GetQuote.dto/IGetQuote_Response.dto.ts +++ b/shared/lib/contexts/sales/application/dto/Quote/GetQuote.dto/IGetQuote_Response.dto.ts @@ -28,7 +28,7 @@ export interface IGetQuote_Response_DTO { } export interface IGetQuote_QuoteItem_Response_DTO { - article_id: string; + id_article: string; quantity: IQuantity_DTO; description: string; unit_price: IMoney_DTO; diff --git a/shared/lib/contexts/sales/application/dto/Quote/UpdateQuote.dto/IUpdateQuote_Request.dto.ts b/shared/lib/contexts/sales/application/dto/Quote/UpdateQuote.dto/IUpdateQuote_Request.dto.ts index ccd547b..21fecfb 100644 --- a/shared/lib/contexts/sales/application/dto/Quote/UpdateQuote.dto/IUpdateQuote_Request.dto.ts +++ b/shared/lib/contexts/sales/application/dto/Quote/UpdateQuote.dto/IUpdateQuote_Request.dto.ts @@ -30,7 +30,7 @@ export interface IUpdateQuote_Request_DTO { } export interface IUpdateQuoteItem_Request_DTO { - article_id: string; + id_article: string; quantity: IQuantity_Response_DTO; description: string; unit_price: IMoney_Response_DTO; diff --git a/shared/lib/contexts/sales/application/dto/Quote/UpdateQuote.dto/IUpdateQuote_Response.dto.ts b/shared/lib/contexts/sales/application/dto/Quote/UpdateQuote.dto/IUpdateQuote_Response.dto.ts index f476391..722f315 100644 --- a/shared/lib/contexts/sales/application/dto/Quote/UpdateQuote.dto/IUpdateQuote_Response.dto.ts +++ b/shared/lib/contexts/sales/application/dto/Quote/UpdateQuote.dto/IUpdateQuote_Response.dto.ts @@ -28,7 +28,7 @@ export interface IUpdateQuote_Response_DTO { } export interface IUpdateQuote_QuoteItem_Response_DTO { - article_id: string; + id_article: string; quantity: IQuantity_DTO; description: string; unit_price: IMoney_DTO;