-
Anonymous
Проблемы с суммой значений MI Totaltem, которые не собираются на кредитную карту, где мне нужны полные значения: [закрыт
Сообщение
Anonymous »
async findone (id: string) {
const Budget = await this.budgetentity
.findbyid(id)
.populate([br /> {path: 'seller', select: 'name phone'},
{path: 'clients', select: 'name'},
{br /> {path: ', select:' name '},
{
{path. /> Заполнение: [
{
path: 'package',
model: 'packages',
select: 'name showinpdf Описание фото Url',
},
{path: 'clients.client', модель: 'clients', select: 'name'},
],
],
],
]]
]]
]],
]],
]],
]],
]],
]],
]],
]]. />.Lean();;pee>
Код: Выделить всё
// Verificacao inicial de seguranca
if (!budget || !budget.packages) {
return null;
}
// Geração de colunas da tabela
const tableHead = checkRulesForTable(budget.packages);
const tableHeaderArray = generateTableHeader(tableHead);
let total = 0;
// Calculo dos totais por item
const packagesWithPricing = budget.packages.map((section) => {
const sectionPackages = section.package.map((subPkg) => {
const pricingObj = getTotalPricingByType(
subPkg.clients,
tableHeaderArray,
);
const totalItem = Object.values(pricingObj).reduce(
(acc: number, val: any) =>
typeof val === 'number' ? acc + val : acc,
0,
);
total += totalItem;
return {
...subPkg,
pricing: pricingObj,
};
});
return {
...section,
package: sectionPackages,
};
});
const discountRate = 0.1;
const totalCard = +total.toFixed(2);
const totalPix = +(total * (1 - discountRate)).toFixed(2);
return {
...budget,
packages: packagesWithPricing,
table_head: tableHead,
totalPricing: {
totalCard,
totalPix,
discountPercent: discountRate * 100,
},
};
}
Подробнее здесь:
https://stackoverflow.com/questions/795 ... ndo-para-c
1743609222
Anonymous
async findone (id: string) {
const Budget = await this.budgetentity
.findbyid(id)
.populate([br /> {path: 'seller', select: 'name phone'},
{path: 'clients', select: 'name'},
{br /> {path: ', select:' name '},
{
{path. /> Заполнение: [
{
path: 'package',
model: 'packages',
select: 'name showinpdf Описание фото Url',
},
{path: 'clients.client', модель: 'clients', select: 'name'},
],
],
],
]]
]]
]],
]],
]],
]],
]],
]],
]],
]]. />.Lean();;pee>[code]// Verificacao inicial de seguranca
if (!budget || !budget.packages) {
return null;
}
// Geração de colunas da tabela
const tableHead = checkRulesForTable(budget.packages);
const tableHeaderArray = generateTableHeader(tableHead);
let total = 0;
// Calculo dos totais por item
const packagesWithPricing = budget.packages.map((section) => {
const sectionPackages = section.package.map((subPkg) => {
const pricingObj = getTotalPricingByType(
subPkg.clients,
tableHeaderArray,
);
const totalItem = Object.values(pricingObj).reduce(
(acc: number, val: any) =>
typeof val === 'number' ? acc + val : acc,
0,
);
total += totalItem;
return {
...subPkg,
pricing: pricingObj,
};
});
return {
...section,
package: sectionPackages,
};
});
const discountRate = 0.1;
const totalCard = +total.toFixed(2);
const totalPix = +(total * (1 - discountRate)).toFixed(2);
return {
...budget,
packages: packagesWithPricing,
table_head: tableHead,
totalPricing: {
totalCard,
totalPix,
discountPercent: discountRate * 100,
},
};
[/code]
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79551024/problemas-com-a-suma-de-valores-de-mi-coluna-totalitem-que-nao-estao-indo-para-c[/url]