This commit is contained in:
David Arranz 2024-09-23 19:37:09 +02:00
parent debbb3f3dd
commit 5781fbdb24
18 changed files with 46 additions and 28 deletions

View File

@ -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,
},
},

View File

@ -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 (
<FormTextAreaField
readOnly={original?.id_article}
autoSize
{...register(`items.${index}.id_article`)}
/>
);
},
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: {

View File

@ -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) => {

View File

@ -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") },
];

View File

@ -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,

View File

@ -210,9 +210,9 @@ export class CreateQuoteUseCase
try {
items = new Collection<QuoteItem>(
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,

View File

@ -199,9 +199,9 @@ export class UpdateQuoteUseCase
try {
items = new Collection<QuoteItem>(
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,

View File

@ -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<IQuoteItemProps> 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 {

View File

@ -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(),

View File

@ -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(),

View File

@ -111,7 +111,7 @@ const map = async (quote: Quote, context: ISalesContext) => {
const quoteItemPresenter = (items: ICollection<QuoteItem>, 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(),

View File

@ -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(),

View File

@ -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(),

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;