This commit is contained in:
mohadese namavar
2024-06-16 00:22:14 +04:30
commit ec84dfd222
322 changed files with 77942 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
export default (data) => {
const items = {
productsCount: 0,
productsPrice: 0,
discount: 0,
totalFactor: 0
}
items.productsCount = data.length
items.productsPrice =
data.reduce((sum, item) => sum + item.product.price * item.quantity, 0)
items.totalFactor =
data.reduce(
(sum, item) => sum + (item.product.specialPrice || item.product.price) * item.quantity,
0
)
items.discount = items.productsPrice - items.totalFactor
return items;
}