bx-935-calc #1

Merged
ksenia_mikhailova merged 15 commits from bx-935-calc into main 2024-07-03 14:57:08 +03:00
2 changed files with 20 additions and 5 deletions
Showing only changes of commit a4dd454a73 - Show all commits

View File

@ -99,16 +99,25 @@ const total_txt = computed(() => {
const pillar = parseFloat(calculatorData.value.pillar)
const pillar_base = parseFloat(calculatorData.value.pillar_base)
const lamelles_block = parseFloat(calculatorData.value.lamelles_block)
const { discount } = calculatorData.value
const sections = section_count.value as number
const extra_m = extra_section.value as number * 0.001
const length_m = fence_section.value as number
const lam_count = lamelles_count.value as number
let discountValue = 1
discount.forEach(element => {
if (sections >= element.min_quantity) {
if (element.max_quantitt && sections >= element.max_quantitt) return
discountValue -= element.percent * 0.01
}
});
const prices = {
pillar_length: pillar,
pillar: (pillar * lam_count * 0.115) + pillar_base,
lam_quad: lamelles_block * lam_count * 0.115,
pillar_length: discountValue * pillar,
pillar: discountValue * ((pillar * lam_count * 0.115) + pillar_base),
lam_quad: discountValue * (lamelles_block * lam_count * 0.115),
}
const extra = {
@ -131,7 +140,7 @@ const total_txt = computed(() => {
txt: `Блок ламелей с направляющей, ${sections} шт`,
value: prices.lam_quad * length_m * sections
},
}
};
const total = [extra, regular].map(item => Object.values(item).map(el => el ? el.value : 0)).flat().reduce((a, b) => a + b, 0)

8
types/index.d.ts vendored
View File

@ -49,11 +49,17 @@ type ApiAdvantageType = {
title: string
content: string
}
type DiscountType = {
id: number
min_quantity: number
max_quantitt?: number
percent: number
}
type ApiCalcType = {
id: number
title: string
pillar: string
pillar_base: string
lamelles_block: string
discount: DiscountType[]
}