mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
remove compound interest and remove unused code
This commit is contained in:
@ -309,7 +309,7 @@ const showRemoveButton = computed(() => {
|
|||||||
const totalSimpleTax = computed(() => {
|
const totalSimpleTax = computed(() => {
|
||||||
return Math.round(
|
return Math.round(
|
||||||
sumBy(props.itemData.taxes, function (tax) {
|
sumBy(props.itemData.taxes, function (tax) {
|
||||||
if (!tax.compound_tax) {
|
if (tax.amount) {
|
||||||
return tax.amount
|
return tax.amount
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
@ -317,18 +317,7 @@ const totalSimpleTax = computed(() => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const totalCompoundTax = computed(() => {
|
const totalTax = computed(() => totalSimpleTax.value)
|
||||||
return Math.round(
|
|
||||||
sumBy(props.itemData.taxes, function (tax) {
|
|
||||||
if (tax.compound_tax) {
|
|
||||||
return tax.amount
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
const totalTax = computed(() => totalSimpleTax.value + totalCompoundTax.value)
|
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
name: {
|
name: {
|
||||||
@ -395,7 +384,7 @@ const v$ = useVuelidate(
|
|||||||
|
|
||||||
function updateTax(data) {
|
function updateTax(data) {
|
||||||
props.store.$patch((state) => {
|
props.store.$patch((state) => {
|
||||||
state[props.storeProp].items[props.index].taxes[data.index] = data.item
|
state[props.storeProp].items[props.index]['taxes'][data.index] = data.item
|
||||||
})
|
})
|
||||||
|
|
||||||
let lastTax = props.itemData.taxes[props.itemData.taxes.length - 1]
|
let lastTax = props.itemData.taxes[props.itemData.taxes.length - 1]
|
||||||
@ -491,7 +480,6 @@ function syncItemToStore() {
|
|||||||
total: total.value,
|
total: total.value,
|
||||||
sub_total: subtotal.value,
|
sub_total: subtotal.value,
|
||||||
totalSimpleTax: totalSimpleTax.value,
|
totalSimpleTax: totalSimpleTax.value,
|
||||||
totalCompoundTax: totalCompoundTax.value,
|
|
||||||
totalTax: totalTax.value,
|
totalTax: totalTax.value,
|
||||||
tax: totalTax.value,
|
tax: totalTax.value,
|
||||||
taxes: [...itemTaxes],
|
taxes: [...itemTaxes],
|
||||||
|
|||||||
@ -146,16 +146,7 @@ const filteredTypes = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const taxAmount = computed(() => {
|
const taxAmount = computed(() => {
|
||||||
if (localTax.compound_tax && props.discountedTotal) {
|
if (props.discountedTotal && localTax.percent) {
|
||||||
const taxPerItemEnabled = props.store[props.storeProp].tax_per_item === 'YES'
|
|
||||||
const discountPerItemEnabled = props.store[props.storeProp].discount_per_item === 'YES'
|
|
||||||
if (taxPerItemEnabled && !discountPerItemEnabled){
|
|
||||||
return getTaxAmount()
|
|
||||||
}
|
|
||||||
return ((props.discountedTotal + props.totalTax) * localTax.percent) / 100
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props.discountedTotal && localTax.percent) {
|
|
||||||
const taxPerItemEnabled = props.store[props.storeProp].tax_per_item === 'YES'
|
const taxPerItemEnabled = props.store[props.storeProp].tax_per_item === 'YES'
|
||||||
const discountPerItemEnabled = props.store[props.storeProp].discount_per_item === 'YES'
|
const discountPerItemEnabled = props.store[props.storeProp].discount_per_item === 'YES'
|
||||||
if (taxPerItemEnabled && !discountPerItemEnabled){
|
if (taxPerItemEnabled && !discountPerItemEnabled){
|
||||||
@ -163,7 +154,6 @@ const taxAmount = computed(() => {
|
|||||||
}
|
}
|
||||||
return (props.discountedTotal * localTax.percent) / 100
|
return (props.discountedTotal * localTax.percent) / 100
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -200,7 +190,6 @@ updateRowTax()
|
|||||||
function onSelectTax(val) {
|
function onSelectTax(val) {
|
||||||
localTax.percent = val.percent
|
localTax.percent = val.percent
|
||||||
localTax.tax_type_id = val.id
|
localTax.tax_type_id = val.id
|
||||||
localTax.compound_tax = val.compound_tax
|
|
||||||
localTax.name = val.name
|
localTax.name = val.name
|
||||||
|
|
||||||
updateRowTax()
|
updateRowTax()
|
||||||
|
|||||||
@ -323,14 +323,7 @@ function selectPercentage() {
|
|||||||
|
|
||||||
function onSelectTax(selectedTax) {
|
function onSelectTax(selectedTax) {
|
||||||
let amount = 0
|
let amount = 0
|
||||||
|
if (props.store.getSubtotalWithDiscount && selectedTax.percent) {
|
||||||
if (selectedTax.compound_tax && props.store.getSubtotalWithDiscount) {
|
|
||||||
amount = Math.round(
|
|
||||||
((props.store.getSubtotalWithDiscount + props.store.getTotalSimpleTax) *
|
|
||||||
selectedTax.percent) /
|
|
||||||
100
|
|
||||||
)
|
|
||||||
} else if (props.store.getSubtotalWithDiscount && selectedTax.percent) {
|
|
||||||
amount = Math.round(
|
amount = Math.round(
|
||||||
(props.store.getSubtotalWithDiscount * selectedTax.percent) / 100
|
(props.store.getSubtotalWithDiscount * selectedTax.percent) / 100
|
||||||
)
|
)
|
||||||
@ -341,7 +334,6 @@ function onSelectTax(selectedTax) {
|
|||||||
id: Guid.raw(),
|
id: Guid.raw(),
|
||||||
name: selectedTax.name,
|
name: selectedTax.name,
|
||||||
percent: selectedTax.percent,
|
percent: selectedTax.percent,
|
||||||
compound_tax: selectedTax.compound_tax,
|
|
||||||
tax_type_id: selectedTax.id,
|
tax_type_id: selectedTax.id,
|
||||||
amount,
|
amount,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,17 +77,6 @@
|
|||||||
@input="v$.currentTaxType.description.$touch()"
|
@input="v$.currentTaxType.description.$touch()"
|
||||||
/>
|
/>
|
||||||
</BaseInputGroup>
|
</BaseInputGroup>
|
||||||
|
|
||||||
<BaseInputGroup
|
|
||||||
:label="$t('tax_types.compound_tax')"
|
|
||||||
variant="horizontal"
|
|
||||||
class="flex flex-row-reverse"
|
|
||||||
>
|
|
||||||
<BaseSwitch
|
|
||||||
v-model="taxTypeStore.currentTaxType.compound_tax"
|
|
||||||
class="flex items-center"
|
|
||||||
/>
|
|
||||||
</BaseInputGroup>
|
|
||||||
</BaseInputGrid>
|
</BaseInputGrid>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -209,14 +198,7 @@ async function submitTaxTypeData() {
|
|||||||
|
|
||||||
function SelectTax(taxData) {
|
function SelectTax(taxData) {
|
||||||
let amount = 0
|
let amount = 0
|
||||||
if (taxData.compound_tax && estimateStore.getSubtotalWithDiscount) {
|
if (estimateStore.getSubtotalWithDiscount && taxData.percent) {
|
||||||
amount = Math.round(
|
|
||||||
((estimateStore.getSubtotalWithDiscount +
|
|
||||||
estimateStore.getTotalSimpleTax) *
|
|
||||||
taxData.percent) /
|
|
||||||
100
|
|
||||||
)
|
|
||||||
} else if (estimateStore.getSubtotalWithDiscount && taxData.percent) {
|
|
||||||
amount = Math.round(
|
amount = Math.round(
|
||||||
(estimateStore.getSubtotalWithDiscount * taxData.percent) / 100
|
(estimateStore.getSubtotalWithDiscount * taxData.percent) / 100
|
||||||
)
|
)
|
||||||
@ -226,7 +208,6 @@ function SelectTax(taxData) {
|
|||||||
id: Guid.raw(),
|
id: Guid.raw(),
|
||||||
name: taxData.name,
|
name: taxData.name,
|
||||||
percent: taxData.percent,
|
percent: taxData.percent,
|
||||||
compound_tax: taxData.compound_tax,
|
|
||||||
tax_type_id: taxData.id,
|
tax_type_id: taxData.id,
|
||||||
amount,
|
amount,
|
||||||
}
|
}
|
||||||
@ -242,7 +223,6 @@ function selectItemTax(taxData) {
|
|||||||
id: Guid.raw(),
|
id: Guid.raw(),
|
||||||
name: taxData.name,
|
name: taxData.name,
|
||||||
percent: taxData.percent,
|
percent: taxData.percent,
|
||||||
compound_tax: taxData.compound_tax,
|
|
||||||
tax_type_id: taxData.id,
|
tax_type_id: taxData.id,
|
||||||
}
|
}
|
||||||
modalStore.refreshData(data)
|
modalStore.refreshData(data)
|
||||||
|
|||||||
@ -20,21 +20,6 @@
|
|||||||
:data="fetchData"
|
:data="fetchData"
|
||||||
:columns="taxTypeColumns"
|
:columns="taxTypeColumns"
|
||||||
>
|
>
|
||||||
<template #cell-compound_tax="{ row }">
|
|
||||||
<BaseBadge
|
|
||||||
:bg-color="
|
|
||||||
utils.getBadgeStatusColor(row.data.compound_tax ? 'YES' : 'NO')
|
|
||||||
.bgColor
|
|
||||||
"
|
|
||||||
:color="
|
|
||||||
utils.getBadgeStatusColor(row.data.compound_tax ? 'YES' : 'NO')
|
|
||||||
.color
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ row.data.compound_tax ? 'Yes' : 'No'.replace('_', ' ') }}
|
|
||||||
</BaseBadge>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #cell-percent="{ row }"> {{ row.data.percent }} % </template>
|
<template #cell-percent="{ row }"> {{ row.data.percent }} % </template>
|
||||||
|
|
||||||
<template v-if="hasAtleastOneAbility()" #cell-actions="{ row }">
|
<template v-if="hasAtleastOneAbility()" #cell-actions="{ row }">
|
||||||
@ -91,11 +76,6 @@ const taxTypeColumns = computed(() => {
|
|||||||
thClass: 'extra',
|
thClass: 'extra',
|
||||||
tdClass: 'font-medium text-gray-900',
|
tdClass: 'font-medium text-gray-900',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'compound_tax',
|
|
||||||
label: t('settings.tax_types.compound_tax'),
|
|
||||||
tdClass: 'font-medium text-gray-900',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'percent',
|
key: 'percent',
|
||||||
label: t('settings.tax_types.percent'),
|
label: t('settings.tax_types.percent'),
|
||||||
|
|||||||
Reference in New Issue
Block a user