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