Skip to content

chore(fix-final-price): price in proportion to discount#256

Open
matheusgnreis wants to merge 1 commit intomasterfrom
change-price-item-kit
Open

chore(fix-final-price): price in proportion to discount#256
matheusgnreis wants to merge 1 commit intomasterfrom
change-price-item-kit

Conversation

@matheusgnreis
Copy link
Copy Markdown
Member

Show price with proportion instead of equals.
Demand from 2 corps.

Comment on lines +11 to +12
? finalPrice
? finalPrice
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quê isso? 😬

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seria finalPrice || (item.kit_product.price / item.kit_product.pack_quantity) então?

Comment on lines +3 to +8
let multiplier = 1
let finalPrice = 0
if (item.kit_product && item.kit_product.base_price && item.kit_product.price) {
multiplier = item.kit_product.price / item.kit_product.base_price
finalPrice = multiplier * item.price
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esse trecho aqui faz zero sentido 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nem entendi direito o que quis fazer nesse ponto, mas o que tá sendo feito aqui é setar um múltiplo do preço promocional do produto kit (em quê esse múltiplo seria útil?) e depois usando ele pra setar o preço de cada item do kit, isso não faz sentido porque esse múltiplo não tem relação com a composição de preços do kit, o valor aqui só bateria o correto no final por muita coincidência

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Você teria que achar um múltiplo (regra de 3 mesmo) entre o valor do item atual pelo valor do kit (price, base_price não influencia aqui) dividido pela quantidade total de itens.
Esse múltiplo possivelmente também vai te gerar um erro decimal no final, no último item você não poderá usar múltiplo, deverá calcular o que ainda falta na soma em vez disso.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants