init git
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user