0
0
Fork 0

refs #5835 refactor

This commit is contained in:
Jorge Penadés 2023-12-12 12:11:45 +01:00
parent 2c5dc276b2
commit d1a5029ef7
4 changed files with 21 additions and 25 deletions

View File

@ -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>

View File

@ -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"
>

View File

@ -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) {
return (taxTypeSage / 100) * taxableBase;
}
return 0;
const taxTypeSage = taxRateSelection?.rate ?? 0;
const taxableBase = invoiceInTax?.taxableBase ?? 0;
return (taxTypeSage / 100) * taxableBase;
}
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

View File

@ -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);
});
});