fix tax issue (#953)

* fix tax issue

* remove console log

* update cs fixer package
This commit is contained in:
HarshJagad20
2022-10-26 19:51:36 +05:30
committed by GitHub
parent 4e47f58bad
commit bc8f2cd484
5 changed files with 914 additions and 1510 deletions

View File

@ -38,7 +38,7 @@
"barryvdh/laravel-ide-helper": "^2.6", "barryvdh/laravel-ide-helper": "^2.6",
"beyondcode/laravel-dump-server": "^1.0", "beyondcode/laravel-dump-server": "^1.0",
"facade/ignition": "^2.3.6", "facade/ignition": "^2.3.6",
"friendsofphp/php-cs-fixer": "^3.0", "friendsofphp/php-cs-fixer": "^3.8",
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.3.1", "mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.0", "nunomaduro/collision": "^5.0",

2331
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -17,18 +17,7 @@
<td class="px-5 py-4 text-left align-top"> <td class="px-5 py-4 text-left align-top">
<div class="flex justify-start"> <div class="flex justify-start">
<div <div
class=" class="flex items-center justify-center w-5 h-5 mt-2 mr-2 text-gray-300 cursor-move handle"
flex
items-center
justify-center
w-5
h-5
mt-2
text-gray-300
cursor-move
handle
mr-2
"
> >
<DragIcon /> <DragIcon />
</div> </div>
@ -108,7 +97,7 @@
<BaseIcon <BaseIcon
name="ChevronDownIcon" name="ChevronDownIcon"
class="w-4 h-4 text-gray-500 ml-1" class="w-4 h-4 ml-1 text-gray-500"
/> />
</span> </span>
</BaseButton> </BaseButton>
@ -155,7 +144,7 @@
<BaseContentPlaceholders v-if="loading"> <BaseContentPlaceholders v-if="loading">
<BaseContentPlaceholdersText <BaseContentPlaceholdersText
:lines="1" :lines="1"
class="w-24 h-8 rounded-md border" class="w-24 h-8 border rounded-md"
/> />
</BaseContentPlaceholders> </BaseContentPlaceholders>
@ -175,6 +164,7 @@
:ability="abilities.CREATE_INVOICE" :ability="abilities.CREATE_INVOICE"
:store="store" :store="store"
:store-prop="storeProp" :store-prop="storeProp"
:discount="discount"
@update="updateTax" @update="updateTax"
/> />
</td> </td>

View File

@ -30,24 +30,13 @@
<template v-if="userStore.hasAbilities(ability)" #action> <template v-if="userStore.hasAbilities(ability)" #action>
<button <button
type="button" type="button"
class=" class="flex items-center justify-center w-full px-2 py-2 bg-gray-200 border-none outline-none cursor-pointer "
flex
items-center
justify-center
w-full
px-2
cursor-pointer
py-2
bg-gray-200
border-none
outline-none
"
@click="openTaxModal" @click="openTaxModal"
> >
<BaseIcon name="CheckCircleIcon" class="h-5 text-primary-400" /> <BaseIcon name="CheckCircleIcon" class="h-5 text-primary-400" />
<label <label
class="ml-2 text-sm leading-none text-primary-400 cursor-pointer" class="ml-2 text-sm leading-none cursor-pointer text-primary-400"
>{{ $t('invoices.add_new_tax') }}</label >{{ $t('invoices.add_new_tax') }}</label
> >
</button> </button>
@ -115,6 +104,10 @@ const props = defineProps({
type: Number, type: Number,
default: 0, default: 0,
}, },
discountedTotal: {
type: Number,
default: 0,
},
currency: { currency: {
type: [Object, String], type: [Object, String],
required: true, required: true,
@ -153,19 +146,19 @@ const filteredTypes = computed(() => {
}) })
const taxAmount = computed(() => { const taxAmount = computed(() => {
if (localTax.compound_tax && props.total) { if (localTax.compound_tax && props.discountedTotal) {
return ((props.total + props.totalTax) * localTax.percent) / 100 return ((props.discountedTotal + props.totalTax) * localTax.percent) / 100
} }
if (props.total && localTax.percent) { if (props.discountedTotal && localTax.percent) {
return (props.total * localTax.percent) / 100 return (props.discountedTotal * localTax.percent) / 100
} }
return 0 return 0
}) })
watch( watch(
() => props.total, () => props.discountedTotal,
() => { () => {
updateRowTax() updateRowTax()
} }

View File

@ -29,14 +29,7 @@
<label <label
v-else v-else
class=" class="flex items-center justify-center m-0 text-lg text-black uppercase "
flex
items-center
justify-center
m-0
text-lg text-black
uppercase
"
> >
<BaseFormatMoney <BaseFormatMoney
:amount="store.getSubTotal" :amount="store.getSubTotal"
@ -66,14 +59,7 @@
<label <label
v-else-if="store[storeProp].tax_per_item === 'YES'" v-else-if="store[storeProp].tax_per_item === 'YES'"
class=" class="flex items-center justify-center m-0 text-lg text-black uppercase "
flex
items-center
justify-center
m-0
text-lg text-black
uppercase
"
> >
<BaseFormatMoney :amount="tax.amount" :currency="defaultCurrency" /> <BaseFormatMoney :amount="tax.amount" :currency="defaultCurrency" />
</label> </label>
@ -98,7 +84,7 @@
<BaseContentPlaceholders v-if="isLoading"> <BaseContentPlaceholders v-if="isLoading">
<BaseContentPlaceholdersText <BaseContentPlaceholdersText
:lines="1" :lines="1"
class="w-24 h-8 rounded-md border" class="w-24 h-8 border rounded-md"
/> />
</BaseContentPlaceholders> </BaseContentPlaceholders>
<div v-else class="flex" style="width: 140px" role="group"> <div v-else class="flex" style="width: 140px" role="group">
@ -114,7 +100,7 @@
<BaseDropdown position="bottom-end"> <BaseDropdown position="bottom-end">
<template #activator> <template #activator>
<BaseButton <BaseButton
class="rounded-tr-md rounded-br-md p-2 rounded-none" class="p-2 rounded-none rounded-tr-md rounded-br-md"
type="button" type="button"
variant="white" variant="white"
> >
@ -127,7 +113,7 @@
<BaseIcon <BaseIcon
name="ChevronDownIcon" name="ChevronDownIcon"
class="w-4 h-4 text-gray-500 ml-1" class="w-4 h-4 ml-1 text-gray-500"
/> />
</span> </span>
</BaseButton> </BaseButton>
@ -180,15 +166,7 @@
</div> </div>
<div <div
class=" class="flex items-center justify-between w-full pt-2 mt-5 border-t border-gray-200 border-solid "
flex
items-center
justify-between
w-full
pt-2
mt-5
border-t border-gray-200 border-solid
"
> >
<BaseContentPlaceholders v-if="isLoading"> <BaseContentPlaceholders v-if="isLoading">
<BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" />
@ -204,14 +182,7 @@
</BaseContentPlaceholders> </BaseContentPlaceholders>
<label <label
v-else v-else
class=" class="flex items-center justify-center text-lg uppercase text-primary-400"
flex
items-center
justify-center
text-lg
uppercase
text-primary-400
"
> >
<BaseFormatMoney :amount="store.getTotal" :currency="defaultCurrency" /> <BaseFormatMoney :amount="store.getTotal" :currency="defaultCurrency" />
</label> </label>
@ -334,6 +305,7 @@ function selectPercentage() {
function onSelectTax(selectedTax) { function onSelectTax(selectedTax) {
let amount = 0 let amount = 0
if (selectedTax.compound_tax && props.store.getSubtotalWithDiscount) { if (selectedTax.compound_tax && props.store.getSubtotalWithDiscount) {
amount = Math.round( amount = Math.round(
((props.store.getSubtotalWithDiscount + props.store.getTotalSimpleTax) * ((props.store.getSubtotalWithDiscount + props.store.getTotalSimpleTax) *