Listado de promociones
This commit is contained in:
@ -18,30 +18,33 @@
|
||||
}
|
||||
draw() {}
|
||||
prices(units) {
|
||||
const prices = []
|
||||
units.forEach(unit => {
|
||||
let price = unit.valor ?? (unit.precio?.valor ?? 0)
|
||||
let amount = 1
|
||||
let diff = 0
|
||||
unit.promotions?.forEach(promotion => {
|
||||
return units.map(unit => {
|
||||
let price = unit.valor ?? (unit.precio?.valor ?? 0)
|
||||
const broker = price / (1 - this.commission)
|
||||
const promotions = unit.promotions?.map(promotion => {
|
||||
if (promotion.type === 1) {
|
||||
diff += promotion.amount
|
||||
return
|
||||
return {
|
||||
name: promotion.description,
|
||||
type: promotion.type,
|
||||
amount: promotion.amount,
|
||||
final: broker + promotion.amount
|
||||
}
|
||||
}
|
||||
amount /= 1/(1 - promotion.amount)
|
||||
})
|
||||
amount = 1 - amount
|
||||
price += diff
|
||||
prices.push({
|
||||
return {
|
||||
name: promotion.description,
|
||||
type: promotion.type,
|
||||
amount: promotion.amount,
|
||||
final: broker / (1 - promotion.amount)
|
||||
}
|
||||
}) ?? []
|
||||
return {
|
||||
id: unit.id,
|
||||
base: price,
|
||||
commission: this.commission,
|
||||
broker: price / (1 - this.commission),
|
||||
amount,
|
||||
final: price / (1 - this.commission) / (1 - amount)
|
||||
})
|
||||
broker,
|
||||
promotions
|
||||
}
|
||||
})
|
||||
return prices
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user