Listado de promociones

This commit is contained in:
Juan Pablo Vial
2025-04-22 18:34:23 -04:00
parent 90b05ca25c
commit 966b341b65
4 changed files with 210 additions and 55 deletions

View File

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