forked from verdnatura/salix-front
refs #5835 refactor
This commit is contained in:
parent
2c5dc276b2
commit
d1a5029ef7
|
@ -163,6 +163,8 @@ async function cloneInvoice() {
|
||||||
router.push({ path: `/invoice-in/${data.id}/summary` });
|
router.push({ path: `/invoice-in/${data.id}/summary` });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isAdministrative = () => hasAny(['administrative']);
|
||||||
|
|
||||||
const isAgricultural = () =>
|
const isAgricultural = () =>
|
||||||
invoiceIn.value.supplier.sageWithholdingFk == config.value[0].sageWithholdingFk;
|
invoiceIn.value.supplier.sageWithholdingFk == config.value[0].sageWithholdingFk;
|
||||||
|
|
||||||
|
@ -222,7 +224,7 @@ function triggerMenu(type) {
|
||||||
>
|
>
|
||||||
<template #menu="{ entity }">
|
<template #menu="{ entity }">
|
||||||
<QItem
|
<QItem
|
||||||
v-if="!entity.isBooked && hasAny(['administrative'])"
|
v-if="!entity.isBooked && isAdministrative()"
|
||||||
v-ripple
|
v-ripple
|
||||||
clickable
|
clickable
|
||||||
@click="triggerMenu('book')"
|
@click="triggerMenu('book')"
|
||||||
|
@ -230,7 +232,7 @@ function triggerMenu(type) {
|
||||||
<QItemSection>{{ t('To book') }}</QItemSection>
|
<QItemSection>{{ t('To book') }}</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem
|
<QItem
|
||||||
v-if="hasAny(['administrative'])"
|
v-if="isAdministrative()"
|
||||||
v-ripple
|
v-ripple
|
||||||
clickable
|
clickable
|
||||||
@click="triggerMenu('delete')"
|
@click="triggerMenu('delete')"
|
||||||
|
@ -238,7 +240,7 @@ function triggerMenu(type) {
|
||||||
<QItemSection>{{ t('Delete invoice') }}</QItemSection>
|
<QItemSection>{{ t('Delete invoice') }}</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem
|
<QItem
|
||||||
v-if="hasAny(['administrative'])"
|
v-if="isAdministrative()"
|
||||||
v-ripple
|
v-ripple
|
||||||
clickable
|
clickable
|
||||||
@click="triggerMenu('clone')"
|
@click="triggerMenu('clone')"
|
||||||
|
@ -306,7 +308,6 @@ function triggerMenu(type) {
|
||||||
.q-dialog {
|
.q-dialog {
|
||||||
.q-card {
|
.q-card {
|
||||||
width: 35em;
|
width: 35em;
|
||||||
max-width: 35em;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -19,6 +19,8 @@ const banks = ref([]);
|
||||||
const invoiceInFormRef = ref();
|
const invoiceInFormRef = ref();
|
||||||
const invoiceId = route.params.id;
|
const invoiceId = route.params.id;
|
||||||
|
|
||||||
|
const placeholder = 'yyyy/mm/dd';
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {
|
where: {
|
||||||
invoiceInFk: invoiceId,
|
invoiceInFk: invoiceId,
|
||||||
|
@ -67,7 +69,7 @@ const columns = computed(() => [
|
||||||
const isNotEuro = (code) => code != 'EUR';
|
const isNotEuro = (code) => code != 'EUR';
|
||||||
|
|
||||||
async function insert() {
|
async function insert() {
|
||||||
await axios.post('/InvoiceInDueDays/new ', { id: Number(invoiceId) });
|
await axios.post('/InvoiceInDueDays/new ', { id: +invoiceId });
|
||||||
await invoiceInFormRef.value.reload();
|
await invoiceInFormRef.value.reload();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -99,7 +101,7 @@ async function insert() {
|
||||||
<QInput
|
<QInput
|
||||||
v-model="row.dueDated"
|
v-model="row.dueDated"
|
||||||
mask="date"
|
mask="date"
|
||||||
placeholder="yyyy/mm/dd"
|
:placeholder="placeholder"
|
||||||
clearable
|
clearable
|
||||||
clear-icon="close"
|
clear-icon="close"
|
||||||
>
|
>
|
||||||
|
@ -186,7 +188,7 @@ async function insert() {
|
||||||
:label="t('Date')"
|
:label="t('Date')"
|
||||||
v-model="props.row.dueDated"
|
v-model="props.row.dueDated"
|
||||||
mask="date"
|
mask="date"
|
||||||
placeholder="yyyy/mm/dd"
|
:placeholder="placeholder"
|
||||||
clearable
|
clearable
|
||||||
clear-icon="close"
|
clear-icon="close"
|
||||||
>
|
>
|
||||||
|
|
|
@ -112,16 +112,15 @@ const filter = {
|
||||||
|
|
||||||
const isNotEuro = (code) => code != 'EUR';
|
const isNotEuro = (code) => code != 'EUR';
|
||||||
|
|
||||||
function taxRate(invoiceInTax, sageTaxTypeId) {
|
function taxRate(invoiceInTax) {
|
||||||
|
const sageTaxTypeId = invoiceInTax.taxTypeSageFk;
|
||||||
const taxRateSelection = sageTaxTypes.value.find(
|
const taxRateSelection = sageTaxTypes.value.find(
|
||||||
(transaction) => transaction.id == sageTaxTypeId
|
(transaction) => transaction.id == sageTaxTypeId
|
||||||
);
|
);
|
||||||
const taxTypeSage = taxRateSelection && taxRateSelection.rate;
|
const taxTypeSage = taxRateSelection?.rate ?? 0;
|
||||||
const taxableBase = invoiceInTax && invoiceInTax.taxableBase;
|
const taxableBase = invoiceInTax?.taxableBase ?? 0;
|
||||||
if (taxTypeSage && taxableBase) {
|
|
||||||
return (taxTypeSage / 100) * taxableBase;
|
return (taxTypeSage / 100) * taxableBase;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addExpense() {
|
async function addExpense() {
|
||||||
|
@ -395,11 +394,7 @@ async function addExpense() {
|
||||||
</VnSelectFilter>
|
</VnSelectFilter>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem>
|
||||||
{{
|
{{ toCurrency(taxRate(props.row)) }}
|
||||||
toCurrency(
|
|
||||||
taxRate(props.row, props.row.taxTypeSageFk)
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem>
|
||||||
<QInput
|
<QInput
|
||||||
|
|
|
@ -53,22 +53,20 @@ describe('InvoiceInVat', () => {
|
||||||
|
|
||||||
describe('taxRate()', () => {
|
describe('taxRate()', () => {
|
||||||
it('should correctly compute the tax rate', () => {
|
it('should correctly compute the tax rate', () => {
|
||||||
const invoiceInTax = { taxableBase: 100 };
|
const invoiceInTax = { taxableBase: 100, taxTypeSageFk: 1 };
|
||||||
const sageTaxTypeId = 1;
|
|
||||||
vm.sageTaxTypes = [
|
vm.sageTaxTypes = [
|
||||||
{ id: 1, rate: 10 },
|
{ id: 1, rate: 10 },
|
||||||
{ id: 2, rate: 20 },
|
{ id: 2, rate: 20 },
|
||||||
];
|
];
|
||||||
const result = vm.taxRate(invoiceInTax, sageTaxTypeId);
|
const result = vm.taxRate(invoiceInTax);
|
||||||
expect(result).toBe((10 / 100) * 100);
|
expect(result).toBe((10 / 100) * 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return 0 if there is not tax rate', () => {
|
it('should return 0 if there is not tax rate', () => {
|
||||||
const invoiceInTax = { taxableBase: 100 };
|
const invoiceInTax = { taxableBase: 100, taxTypeSageFk: 1 };
|
||||||
const sageTaxTypeId = 1;
|
|
||||||
vm.sageTaxTypes = [];
|
vm.sageTaxTypes = [];
|
||||||
|
|
||||||
const result = vm.taxRate(invoiceInTax, sageTaxTypeId);
|
const result = vm.taxRate(invoiceInTax);
|
||||||
expect(result).toBe(0);
|
expect(result).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue