Merge pull request 'fix: refs #7967 show userErr & useNotify composable' (!1725) from 7939-showUserErr into dev
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
Reviewed-on: #1725 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
93e29fdde6
|
@ -7,7 +7,7 @@ import { QLayout } from 'quasar';
|
||||||
import mainShortcutMixin from './mainShortcutMixin';
|
import mainShortcutMixin from './mainShortcutMixin';
|
||||||
import { useCau } from 'src/composables/useCau';
|
import { useCau } from 'src/composables/useCau';
|
||||||
|
|
||||||
export default boot(({ app }) => {
|
export default boot(({ app, router }) => {
|
||||||
QForm.mixins = [qFormMixin];
|
QForm.mixins = [qFormMixin];
|
||||||
QLayout.mixins = [mainShortcutMixin];
|
QLayout.mixins = [mainShortcutMixin];
|
||||||
|
|
||||||
|
@ -22,6 +22,14 @@ export default boot(({ app }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (response?.status) {
|
switch (response?.status) {
|
||||||
|
case 401:
|
||||||
|
if (!router.currentRoute.value.name.toLowerCase().includes('login')) {
|
||||||
|
message = 'errors.sessionExpired';
|
||||||
|
} else message = 'login.loginError';
|
||||||
|
break;
|
||||||
|
case 403:
|
||||||
|
if (!message || message.toLowerCase() === 'access denied')
|
||||||
|
message = 'errors.accessDenied';
|
||||||
case 422:
|
case 422:
|
||||||
if (error.name == 'ValidationError')
|
if (error.name == 'ValidationError')
|
||||||
message += ` "${responseError.details.context}.${Object.keys(
|
message += ` "${responseError.details.context}.${Object.keys(
|
||||||
|
|
|
@ -181,6 +181,10 @@ const col = computed(() => {
|
||||||
newColumn.component = 'checkbox';
|
newColumn.component = 'checkbox';
|
||||||
if ($props.default && !newColumn.component) newColumn.component = $props.default;
|
if ($props.default && !newColumn.component) newColumn.component = $props.default;
|
||||||
|
|
||||||
|
if (typeof newColumn.component !== 'string') {
|
||||||
|
newColumn.attrs = { ...newColumn.component.attrs, autofocus: $props.autofocus };
|
||||||
|
newColumn.event = { ...newColumn.component.event, ...$props?.eventHandlers };
|
||||||
|
}
|
||||||
return newColumn;
|
return newColumn;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
<script setup>
|
||||||
|
import { ref, useTemplateRef } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
|
||||||
|
import VnSelectDialog from './VnSelectDialog.vue';
|
||||||
|
import CreateNewExpenseForm from '../CreateNewExpenseForm.vue';
|
||||||
|
import FetchData from '../FetchData.vue';
|
||||||
|
|
||||||
|
const model = defineModel({ type: [String, Number, Object] });
|
||||||
|
const { t } = useI18n();
|
||||||
|
const expenses = ref([]);
|
||||||
|
const selectDialogRef = useTemplateRef('selectDialogRef');
|
||||||
|
|
||||||
|
async function autocompleteExpense(evt) {
|
||||||
|
const val = evt.target.value;
|
||||||
|
if (!val || isNaN(val)) return;
|
||||||
|
const lookup = expenses.value.find(({ id }) => id == useAccountShortToStandard(val));
|
||||||
|
if (selectDialogRef.value)
|
||||||
|
selectDialogRef.value.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<VnSelectDialog
|
||||||
|
v-bind="$attrs"
|
||||||
|
ref="selectDialogRef"
|
||||||
|
v-model="model"
|
||||||
|
:options="expenses"
|
||||||
|
option-value="id"
|
||||||
|
:option-label="(x) => `${x.id}: ${x.name}`"
|
||||||
|
:filter-options="['id', 'name']"
|
||||||
|
:tooltip="t('Create a new expense')"
|
||||||
|
:acls="[{ model: 'Expense', props: '*', accessType: 'WRITE' }]"
|
||||||
|
@keydown.tab.prevent="autocompleteExpense"
|
||||||
|
>
|
||||||
|
<template #form>
|
||||||
|
<CreateNewExpenseForm @on-data-saved="$refs.expensesRef.fetch()" />
|
||||||
|
</template>
|
||||||
|
</VnSelectDialog>
|
||||||
|
<FetchData
|
||||||
|
ref="expensesRef"
|
||||||
|
url="Expenses"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="(data) => (expenses = data)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<i18n>
|
||||||
|
es:
|
||||||
|
Create a new expense: Crear nuevo gasto
|
||||||
|
</i18n>
|
|
@ -400,6 +400,8 @@ errors:
|
||||||
updateUserConfig: Error updating user config
|
updateUserConfig: Error updating user config
|
||||||
tokenConfig: Error fetching token config
|
tokenConfig: Error fetching token config
|
||||||
writeRequest: The requested operation could not be completed
|
writeRequest: The requested operation could not be completed
|
||||||
|
sessionExpired: Your session has expired. Please log in again
|
||||||
|
accessDenied: Access denied
|
||||||
claimBeginningQuantity: Cannot import a line with a claimed quantity of 0
|
claimBeginningQuantity: Cannot import a line with a claimed quantity of 0
|
||||||
login:
|
login:
|
||||||
title: Login
|
title: Login
|
||||||
|
|
|
@ -396,6 +396,8 @@ errors:
|
||||||
updateUserConfig: Error al actualizar la configuración de usuario
|
updateUserConfig: Error al actualizar la configuración de usuario
|
||||||
tokenConfig: Error al obtener configuración de token
|
tokenConfig: Error al obtener configuración de token
|
||||||
writeRequest: No se pudo completar la operación solicitada
|
writeRequest: No se pudo completar la operación solicitada
|
||||||
|
sessionExpired: Tu sesión ha expirado, por favor vuelve a iniciar sesión
|
||||||
|
accessDenied: Acceso denegado
|
||||||
claimBeginningQuantity: No se puede importar una linea sin una cantidad reclamada
|
claimBeginningQuantity: No se puede importar una linea sin una cantidad reclamada
|
||||||
login:
|
login:
|
||||||
title: Inicio de sesión
|
title: Inicio de sesión
|
||||||
|
|
|
@ -73,6 +73,7 @@ const columns = computed(() => [
|
||||||
optionLabel: 'code',
|
optionLabel: 'code',
|
||||||
options: companies.value,
|
options: companies.value,
|
||||||
},
|
},
|
||||||
|
orderBy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'warehouse',
|
name: 'warehouse',
|
||||||
|
|
|
@ -1,21 +1,16 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, nextTick } from 'vue';
|
import { ref, computed, markRaw } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
import { getTotal } from 'src/composables/getTotal';
|
import { getTotal } from 'src/composables/getTotal';
|
||||||
import { toCurrency } from 'src/filters';
|
import { toCurrency } from 'src/filters';
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
|
||||||
import CrudModel from 'src/components/CrudModel.vue';
|
|
||||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
|
||||||
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
|
|
||||||
import CreateNewExpenseForm from 'src/components/CreateNewExpenseForm.vue';
|
|
||||||
import { getExchange } from 'src/composables/getExchange';
|
import { getExchange } from 'src/composables/getExchange';
|
||||||
import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
|
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
|
import VnSelectExpense from 'src/components/common/VnSelectExpense.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const arrayData = useArrayData();
|
const arrayData = useArrayData();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const invoiceIn = computed(() => arrayData.store.data);
|
const invoiceIn = computed(() => arrayData.store.data);
|
||||||
|
@ -24,100 +19,142 @@ const expenses = ref([]);
|
||||||
const sageTaxTypes = ref([]);
|
const sageTaxTypes = ref([]);
|
||||||
const sageTransactionTypes = ref([]);
|
const sageTransactionTypes = ref([]);
|
||||||
const rowsSelected = ref([]);
|
const rowsSelected = ref([]);
|
||||||
const invoiceInFormRef = ref();
|
const invoiceInVatTableRef = ref();
|
||||||
|
|
||||||
defineProps({
|
defineProps({ actionIcon: { type: String, default: 'add' } });
|
||||||
actionIcon: {
|
|
||||||
type: String,
|
function taxRate(invoiceInTax) {
|
||||||
default: 'add',
|
const sageTaxTypeId = invoiceInTax.taxTypeSageFk;
|
||||||
},
|
const taxRateSelection = sageTaxTypes.value.find(
|
||||||
});
|
(transaction) => transaction.id == sageTaxTypeId,
|
||||||
|
);
|
||||||
|
const taxTypeSage = taxRateSelection?.rate ?? 0;
|
||||||
|
const taxableBase = invoiceInTax?.taxableBase ?? 0;
|
||||||
|
|
||||||
|
return (taxTypeSage / 100) * taxableBase;
|
||||||
|
}
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
name: 'expense',
|
name: 'expenseFk',
|
||||||
label: t('Expense'),
|
label: t('Expense'),
|
||||||
field: (row) => row.expenseFk,
|
component: markRaw(VnSelectExpense),
|
||||||
options: expenses.value,
|
format: (row) => {
|
||||||
model: 'expenseFk',
|
const expense = expenses.value.find((e) => e.id === row.expenseFk);
|
||||||
optionValue: 'id',
|
return expense ? `${expense.id}: ${expense.name}` : row.expenseFk;
|
||||||
optionLabel: (row) => `${row.id}: ${row.name}`,
|
},
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
isEditable: true,
|
||||||
|
create: true,
|
||||||
|
width: '250px',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'taxablebase',
|
name: 'taxableBase',
|
||||||
label: t('Taxable base'),
|
label: t('Taxable base'),
|
||||||
field: (row) => row.taxableBase,
|
component: 'number',
|
||||||
model: 'taxableBase',
|
attrs: {
|
||||||
|
clearable: true,
|
||||||
|
'clear-icon': 'close',
|
||||||
|
},
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
isEditable: true,
|
||||||
|
create: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'isDeductible',
|
name: 'isDeductible',
|
||||||
label: t('invoiceIn.isDeductible'),
|
label: t('invoiceIn.isDeductible'),
|
||||||
field: (row) => row.isDeductible,
|
component: 'checkbox',
|
||||||
model: 'isDeductible',
|
|
||||||
align: 'center',
|
align: 'center',
|
||||||
|
isEditable: true,
|
||||||
|
create: true,
|
||||||
|
createAttrs: {
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
width: '100px',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'sageiva',
|
name: 'taxTypeSageFk',
|
||||||
label: t('Sage iva'),
|
label: t('Sage iva'),
|
||||||
field: (row) => row.taxTypeSageFk,
|
component: 'select',
|
||||||
options: sageTaxTypes.value,
|
attrs: {
|
||||||
model: 'taxTypeSageFk',
|
options: sageTaxTypes.value,
|
||||||
optionValue: 'id',
|
optionValue: 'id',
|
||||||
optionLabel: (row) => `${row.id}: ${row.vat}`,
|
optionLabel: (row) => `${row.id}: ${row.vat}`,
|
||||||
|
filterOptions: ['id', 'vat'],
|
||||||
|
'data-cy': 'vat-sageiva',
|
||||||
|
},
|
||||||
|
format: (row) => {
|
||||||
|
const taxType = sageTaxTypes.value.find((t) => t.id === row.taxTypeSageFk);
|
||||||
|
return taxType ? `${taxType.id}: ${taxType.vat}` : row.taxTypeSageFk;
|
||||||
|
},
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
isEditable: true,
|
||||||
|
create: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'sagetransaction',
|
name: 'transactionTypeSageFk',
|
||||||
label: t('Sage transaction'),
|
label: t('Sage transaction'),
|
||||||
field: (row) => row.transactionTypeSageFk,
|
component: 'select',
|
||||||
options: sageTransactionTypes.value,
|
attrs: {
|
||||||
model: 'transactionTypeSageFk',
|
options: sageTransactionTypes.value,
|
||||||
optionValue: 'id',
|
optionValue: 'id',
|
||||||
optionLabel: (row) => `${row.id}: ${row.transaction}`,
|
optionLabel: (row) => `${row.id}: ${row.transaction}`,
|
||||||
|
filterOptions: ['id', 'transaction'],
|
||||||
|
},
|
||||||
|
format: (row) => {
|
||||||
|
const transType = sageTransactionTypes.value.find(
|
||||||
|
(t) => t.id === row.transactionTypeSageFk,
|
||||||
|
);
|
||||||
|
return transType
|
||||||
|
? `${transType.id}: ${transType.transaction}`
|
||||||
|
: row.transactionTypeSageFk;
|
||||||
|
},
|
||||||
sortable: true,
|
sortable: true,
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
isEditable: true,
|
||||||
|
create: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'rate',
|
name: 'rate',
|
||||||
label: t('Rate'),
|
label: t('Rate'),
|
||||||
sortable: true,
|
sortable: false,
|
||||||
field: (row) => taxRate(row, row.taxTypeSageFk),
|
format: (row) => taxRate(row).toFixed(2),
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'foreignvalue',
|
name: 'foreignValue',
|
||||||
label: t('Foreign value'),
|
label: t('Foreign value'),
|
||||||
|
component: 'number',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
field: (row) => row.foreignValue,
|
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
create: true,
|
||||||
|
disable: !isNotEuro(currency.value),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'total',
|
name: 'total',
|
||||||
label: 'Total',
|
label: t('Total'),
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
format: (row) => (Number(row.taxableBase || 0) + Number(taxRate(row))).toFixed(2),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const tableRows = computed(
|
||||||
|
() => invoiceInVatTableRef.value?.CrudModelRef?.formData || [],
|
||||||
|
);
|
||||||
const taxableBaseTotal = computed(() => {
|
const taxableBaseTotal = computed(() => {
|
||||||
return getTotal(invoiceInFormRef.value.formData, 'taxableBase');
|
return getTotal(tableRows.value, 'taxableBase');
|
||||||
});
|
});
|
||||||
|
|
||||||
const taxRateTotal = computed(() => {
|
const taxRateTotal = computed(() => {
|
||||||
return getTotal(invoiceInFormRef.value.formData, null, {
|
return tableRows.value.reduce((sum, row) => sum + Number(taxRate(row)), 0);
|
||||||
cb: taxRate,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const combinedTotal = computed(() => {
|
const combinedTotal = computed(() => {
|
||||||
return +taxableBaseTotal.value + +taxRateTotal.value;
|
return +taxableBaseTotal.value + +taxRateTotal.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = {
|
const filter = computed(() => ({
|
||||||
fields: [
|
fields: [
|
||||||
'id',
|
'id',
|
||||||
'invoiceInFk',
|
'invoiceInFk',
|
||||||
|
@ -131,389 +168,75 @@ const filter = {
|
||||||
where: {
|
where: {
|
||||||
invoiceInFk: route.params.id,
|
invoiceInFk: route.params.id,
|
||||||
},
|
},
|
||||||
};
|
}));
|
||||||
|
|
||||||
const isNotEuro = (code) => code != 'EUR';
|
const isNotEuro = (code) => code != 'EUR';
|
||||||
|
|
||||||
function taxRate(invoiceInTax) {
|
async function handleForeignValueUpdate(val, row) {
|
||||||
const sageTaxTypeId = invoiceInTax.taxTypeSageFk;
|
if (!isNotEuro(currency.value)) return;
|
||||||
const taxRateSelection = sageTaxTypes.value.find(
|
row.taxableBase = await getExchange(
|
||||||
(transaction) => transaction.id == sageTaxTypeId,
|
val,
|
||||||
|
invoiceIn.value?.currencyFk,
|
||||||
|
invoiceIn.value?.issued,
|
||||||
);
|
);
|
||||||
const taxTypeSage = taxRateSelection?.rate ?? 0;
|
|
||||||
const taxableBase = invoiceInTax?.taxableBase ?? 0;
|
|
||||||
|
|
||||||
return ((taxTypeSage / 100) * taxableBase).toFixed(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
function autocompleteExpense(evt, row, col, ref) {
|
|
||||||
const val = evt.target.value;
|
|
||||||
if (!val) return;
|
|
||||||
|
|
||||||
const param = isNaN(val) ? row[col.model] : val;
|
|
||||||
const lookup = expenses.value.find(
|
|
||||||
({ id }) => id == useAccountShortToStandard(param),
|
|
||||||
);
|
|
||||||
|
|
||||||
ref.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCursor(ref) {
|
|
||||||
nextTick(() => {
|
|
||||||
const select = ref.vnSelectDialogRef
|
|
||||||
? ref.vnSelectDialogRef.vnSelectRef
|
|
||||||
: ref.vnSelectRef;
|
|
||||||
select.$el.querySelector('input').setSelectionRange(0, 0);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData url="Expenses" auto-load @on-fetch="(data) => (expenses = data)" />
|
||||||
ref="expensesRef"
|
|
||||||
url="Expenses"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (expenses = data)"
|
|
||||||
/>
|
|
||||||
<FetchData url="SageTaxTypes" auto-load @on-fetch="(data) => (sageTaxTypes = data)" />
|
<FetchData url="SageTaxTypes" auto-load @on-fetch="(data) => (sageTaxTypes = data)" />
|
||||||
<FetchData
|
<FetchData
|
||||||
url="sageTransactionTypes"
|
url="sageTransactionTypes"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (sageTransactionTypes = data)"
|
@on-fetch="(data) => (sageTransactionTypes = data)"
|
||||||
/>
|
/>
|
||||||
<CrudModel
|
<VnTable
|
||||||
ref="invoiceInFormRef"
|
|
||||||
v-if="invoiceIn"
|
v-if="invoiceIn"
|
||||||
|
ref="invoiceInVatTableRef"
|
||||||
data-key="InvoiceInTaxes"
|
data-key="InvoiceInTaxes"
|
||||||
url="InvoiceInTaxes"
|
url="InvoiceInTaxes"
|
||||||
|
save-url="InvoiceInTaxes/crud"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
:data-required="{ invoiceInFk: $route.params.id }"
|
:data-required="{ invoiceInFk: $route.params.id }"
|
||||||
:insert-on-load="true"
|
:insert-on-load="true"
|
||||||
auto-load
|
auto-load
|
||||||
v-model:selected="rowsSelected"
|
v-model:selected="rowsSelected"
|
||||||
:go-to="`/invoice-in/${$route.params.id}/due-day`"
|
:columns="columns"
|
||||||
|
:is-editable="true"
|
||||||
|
:table="{ selection: 'multiple', 'row-key': '$index' }"
|
||||||
|
footer
|
||||||
|
:right-search="false"
|
||||||
|
:column-search="false"
|
||||||
|
:disable-option="{ card: true }"
|
||||||
|
class="q-pa-none"
|
||||||
|
:create="{
|
||||||
|
urlCreate: 'InvoiceInTaxes',
|
||||||
|
title: t('Add tax'),
|
||||||
|
formInitialData: { invoiceInFk: $route.params.id, isDeductible: true },
|
||||||
|
onDataSaved: () => invoiceInVatTableRef.reload(),
|
||||||
|
}"
|
||||||
|
:crud-model="{ goTo: `/invoice-in/${$route.params.id}/due-day` }"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #column-footer-taxableBase>
|
||||||
<QTable
|
{{ toCurrency(taxableBaseTotal) }}
|
||||||
v-model:selected="rowsSelected"
|
|
||||||
selection="multiple"
|
|
||||||
:columns="columns"
|
|
||||||
:rows="rows"
|
|
||||||
row-key="$index"
|
|
||||||
:grid="$q.screen.lt.sm"
|
|
||||||
>
|
|
||||||
<template #body-cell-expense="{ row, col }">
|
|
||||||
<QTd>
|
|
||||||
<VnSelectDialog
|
|
||||||
:ref="`expenseRef-${row.$index}`"
|
|
||||||
v-model="row[col.model]"
|
|
||||||
:options="col.options"
|
|
||||||
:option-value="col.optionValue"
|
|
||||||
:option-label="col.optionLabel"
|
|
||||||
:filter-options="['id', 'name']"
|
|
||||||
:tooltip="t('Create a new expense')"
|
|
||||||
:acls="[
|
|
||||||
{ model: 'Expense', props: '*', accessType: 'WRITE' },
|
|
||||||
]"
|
|
||||||
@keydown.tab.prevent="
|
|
||||||
autocompleteExpense(
|
|
||||||
$event,
|
|
||||||
row,
|
|
||||||
col,
|
|
||||||
$refs[`expenseRef-${row.$index}`],
|
|
||||||
)
|
|
||||||
"
|
|
||||||
@update:model-value="
|
|
||||||
setCursor($refs[`expenseRef-${row.$index}`])
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
{{ `${scope.opt.id}: ${scope.opt.name}` }}
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
<template #form>
|
|
||||||
<CreateNewExpenseForm
|
|
||||||
@on-data-saved="$refs.expensesRef.fetch()"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</VnSelectDialog>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-isDeductible="{ row }">
|
|
||||||
<QTd align="center">
|
|
||||||
<QCheckbox
|
|
||||||
v-model="row.isDeductible"
|
|
||||||
data-cy="isDeductible_checkbox"
|
|
||||||
/>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-taxablebase="{ row }">
|
|
||||||
<QTd shrink>
|
|
||||||
<VnInputNumber
|
|
||||||
clear-icon="close"
|
|
||||||
v-model="row.taxableBase"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-sageiva="{ row, col }">
|
|
||||||
<QTd>
|
|
||||||
<VnSelect
|
|
||||||
:ref="`sageivaRef-${row.$index}`"
|
|
||||||
v-model="row[col.model]"
|
|
||||||
:options="col.options"
|
|
||||||
:option-value="col.optionValue"
|
|
||||||
:option-label="col.optionLabel"
|
|
||||||
:filter-options="['id', 'vat']"
|
|
||||||
data-cy="vat-sageiva"
|
|
||||||
@update:model-value="
|
|
||||||
setCursor($refs[`sageivaRef-${row.$index}`])
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{ scope.opt.vat }}</QItemLabel>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ `#${scope.opt.id}` }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-sagetransaction="{ row, col }">
|
|
||||||
<QTd>
|
|
||||||
<VnSelect
|
|
||||||
:ref="`sagetransactionRef-${row.$index}`"
|
|
||||||
v-model="row[col.model]"
|
|
||||||
:options="col.options"
|
|
||||||
:option-value="col.optionValue"
|
|
||||||
:option-label="col.optionLabel"
|
|
||||||
:filter-options="['id', 'transaction']"
|
|
||||||
@update:model-value="
|
|
||||||
setCursor($refs[`sagetransactionRef-${row.$index}`])
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{
|
|
||||||
scope.opt.transaction
|
|
||||||
}}</QItemLabel>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ `#${scope.opt.id}` }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-foreignvalue="{ row }">
|
|
||||||
<QTd shrink>
|
|
||||||
<VnInputNumber
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': !isNotEuro(currency),
|
|
||||||
}"
|
|
||||||
:disable="!isNotEuro(currency)"
|
|
||||||
v-model="row.foreignValue"
|
|
||||||
@update:model-value="
|
|
||||||
async (val) => {
|
|
||||||
if (!isNotEuro(currency)) return;
|
|
||||||
row.taxableBase = await getExchange(
|
|
||||||
val,
|
|
||||||
row.currencyFk,
|
|
||||||
invoiceIn.issued,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #bottom-row>
|
|
||||||
<QTr class="bg">
|
|
||||||
<QTd />
|
|
||||||
<QTd />
|
|
||||||
<QTd>
|
|
||||||
{{ toCurrency(taxableBaseTotal) }}
|
|
||||||
</QTd>
|
|
||||||
<QTd />
|
|
||||||
<QTd />
|
|
||||||
<QTd />
|
|
||||||
<QTd>
|
|
||||||
{{ toCurrency(taxRateTotal) }}
|
|
||||||
</QTd>
|
|
||||||
<QTd />
|
|
||||||
<QTd>
|
|
||||||
{{ toCurrency(combinedTotal) }}
|
|
||||||
</QTd>
|
|
||||||
</QTr>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #item="props">
|
|
||||||
<div class="q-pa-xs col-xs-12 col-sm-6 grid-style-transition">
|
|
||||||
<QCard bordered flat class="q-my-xs">
|
|
||||||
<QCardSection>
|
|
||||||
<QCheckbox v-model="props.selected" dense />
|
|
||||||
</QCardSection>
|
|
||||||
<QSeparator />
|
|
||||||
<QList>
|
|
||||||
<QItem>
|
|
||||||
<VnSelectDialog
|
|
||||||
:label="t('Expense')"
|
|
||||||
class="full-width"
|
|
||||||
v-model="props.row['expenseFk']"
|
|
||||||
:options="expenses"
|
|
||||||
option-value="id"
|
|
||||||
:option-label="(row) => `${row.id}:${row.name}`"
|
|
||||||
:filter-options="['id', 'name']"
|
|
||||||
:tooltip="t('Create a new expense')"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
{{ `${scope.opt.id}: ${scope.opt.name}` }}
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
<template #form>
|
|
||||||
<CreateNewExpenseForm />
|
|
||||||
</template>
|
|
||||||
</VnSelectDialog>
|
|
||||||
</QItem>
|
|
||||||
<QItem>
|
|
||||||
<VnInputNumber
|
|
||||||
:label="t('Taxable base')"
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': isNotEuro(currency),
|
|
||||||
}"
|
|
||||||
class="full-width"
|
|
||||||
:disable="isNotEuro(currency)"
|
|
||||||
clear-icon="close"
|
|
||||||
v-model="props.row.taxableBase"
|
|
||||||
clearable
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
<QItem>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('Sage iva')"
|
|
||||||
class="full-width"
|
|
||||||
v-model="props.row['taxTypeSageFk']"
|
|
||||||
:options="sageTaxTypes"
|
|
||||||
option-value="id"
|
|
||||||
:option-label="(row) => `${row.id}:${row.vat}`"
|
|
||||||
:filter-options="['id', 'vat']"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{
|
|
||||||
scope.opt.vat
|
|
||||||
}}</QItemLabel>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ `#${scope.opt.id}` }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</QItem>
|
|
||||||
<QItem>
|
|
||||||
<VnSelect
|
|
||||||
class="full-width"
|
|
||||||
v-model="props.row['transactionTypeSageFk']"
|
|
||||||
:options="sageTransactionTypes"
|
|
||||||
option-value="id"
|
|
||||||
:option-label="
|
|
||||||
(row) => `${row.id}:${row.transaction}`
|
|
||||||
"
|
|
||||||
:filter-options="['id', 'transaction']"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{
|
|
||||||
scope.opt.transaction
|
|
||||||
}}</QItemLabel>
|
|
||||||
<QItemLabel>
|
|
||||||
{{ `#${scope.opt.id}` }}
|
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelect>
|
|
||||||
</QItem>
|
|
||||||
<QItem>
|
|
||||||
{{ toCurrency(taxRate(props.row), currency) }}
|
|
||||||
</QItem>
|
|
||||||
<QItem>
|
|
||||||
<VnInputNumber
|
|
||||||
:label="t('Foreign value')"
|
|
||||||
class="full-width"
|
|
||||||
:class="{
|
|
||||||
'no-pointer-events': !isNotEuro(currency),
|
|
||||||
}"
|
|
||||||
:disable="!isNotEuro(currency)"
|
|
||||||
v-model="props.row.foreignValue"
|
|
||||||
/>
|
|
||||||
</QItem>
|
|
||||||
</QList>
|
|
||||||
</QCard>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</QTable>
|
|
||||||
</template>
|
</template>
|
||||||
</CrudModel>
|
<template #column-footer-rate>
|
||||||
<QPageSticky position="bottom-right" :offset="[25, 25]">
|
{{ toCurrency(taxRateTotal) }}
|
||||||
<QBtn
|
</template>
|
||||||
color="primary"
|
<template #column-footer-total>
|
||||||
icon="add"
|
{{ toCurrency(combinedTotal) }}
|
||||||
size="lg"
|
</template>
|
||||||
v-shortcut="'+'"
|
</VnTable>
|
||||||
round
|
|
||||||
@click="invoiceInFormRef.insert()"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Add tax') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</QPageSticky>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.bg {
|
|
||||||
background-color: var(--vn-light-gray);
|
|
||||||
}
|
|
||||||
@media (max-width: $breakpoint-xs) {
|
|
||||||
.q-dialog {
|
|
||||||
.q-card {
|
|
||||||
&__section:not(:first-child) {
|
|
||||||
.q-item {
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.q-checkbox {
|
|
||||||
margin-top: 2rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.q-item {
|
|
||||||
min-height: 0;
|
|
||||||
}
|
|
||||||
.default-icon {
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 50px;
|
|
||||||
background-color: $primary;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Expense: Gasto
|
Expense: Gasto
|
||||||
Create a new expense: Crear nuevo gasto
|
Create a new expense: Crear nuevo gasto
|
||||||
Add tax: Crear gasto
|
Add tax: Añadir Gasto/IVA # Changed label slightly
|
||||||
Taxable base: Base imp.
|
Taxable base: Base imp.
|
||||||
Sage tax: Sage iva
|
Sage iva: Sage iva # Kept original label
|
||||||
Sage transaction: Sage transacción
|
Sage transaction: Sage transacción
|
||||||
Rate: Tasa
|
Rate: Cuota # Changed label
|
||||||
Foreign value: Divisa
|
Foreign value: Divisa
|
||||||
|
Total: Total
|
||||||
|
invoiceIn.isDeductible: Deducible
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { Notify } from 'quasar';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { useLogin } from 'src/composables/useLogin';
|
import { useLogin } from 'src/composables/useLogin';
|
||||||
|
import useNotify from 'src/composables/useNotify';
|
||||||
import VnLogo from 'components/ui/VnLogo.vue';
|
import VnLogo from 'components/ui/VnLogo.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -15,16 +14,14 @@ const session = useSession();
|
||||||
const loginCache = useLogin();
|
const loginCache = useLogin();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const { notify } = useNotify();
|
||||||
|
|
||||||
const username = ref('');
|
const username = ref('');
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
const keepLogin = ref(true);
|
const keepLogin = ref(true);
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
const params = {
|
const params = { user: username.value, password: password.value };
|
||||||
user: username.value,
|
|
||||||
password: password.value,
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.post('Accounts/login', params);
|
const { data } = await axios.post('Accounts/login', params);
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
@ -33,11 +30,7 @@ async function onSubmit() {
|
||||||
await session.setLogin(data);
|
await session.setLogin(data);
|
||||||
} catch (res) {
|
} catch (res) {
|
||||||
if (res.response?.data?.error?.code === 'REQUIRES_2FA') {
|
if (res.response?.data?.error?.code === 'REQUIRES_2FA') {
|
||||||
Notify.create({
|
notify(t('login.twoFactorRequired'), 'warning', 'phoneLink_lock');
|
||||||
message: t('login.twoFactorRequired'),
|
|
||||||
icon: 'phoneLink_lock',
|
|
||||||
type: 'warning',
|
|
||||||
});
|
|
||||||
params.keepLogin = keepLogin.value;
|
params.keepLogin = keepLogin.value;
|
||||||
loginCache.setUser(params);
|
loginCache.setUser(params);
|
||||||
return router.push({
|
return router.push({
|
||||||
|
@ -45,10 +38,7 @@ async function onSubmit() {
|
||||||
query: router.currentRoute.value?.query,
|
query: router.currentRoute.value?.query,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Notify.create({
|
throw res;
|
||||||
message: t('login.loginError'),
|
|
||||||
type: 'negative',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,33 +5,28 @@ describe('Logout', { testIsolation: true }, () => {
|
||||||
cy.visit(`/#/dashboard`);
|
cy.visit(`/#/dashboard`);
|
||||||
cy.waitForElement('.q-page', 6000);
|
cy.waitForElement('.q-page', 6000);
|
||||||
});
|
});
|
||||||
describe('by user', () => {
|
|
||||||
it('should logout', () => {
|
it('should logout', () => {
|
||||||
cy.get('#user').click();
|
cy.get('#user').click();
|
||||||
cy.get('#logout').click();
|
cy.get('#logout').click();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
describe('not user', () => {
|
|
||||||
beforeEach(() => {
|
it('should throw session expired error if token has expired or is not valid during navigation', () => {
|
||||||
cy.intercept('GET', '**StarredModules**', {
|
cy.intercept('GET', '**StarredModules**', {
|
||||||
statusCode: 401,
|
statusCode: 401,
|
||||||
body: {
|
body: {
|
||||||
error: {
|
error: {
|
||||||
statusCode: 401,
|
statusCode: 401,
|
||||||
name: 'Error',
|
name: 'Error',
|
||||||
message: 'Authorization Required',
|
message: 'Authorization Required',
|
||||||
code: 'AUTHORIZATION_REQUIRED',
|
code: 'AUTHORIZATION_REQUIRED',
|
||||||
},
|
|
||||||
},
|
},
|
||||||
statusMessage: 'AUTHORIZATION_REQUIRED',
|
},
|
||||||
}).as('badRequest');
|
statusMessage: 'AUTHORIZATION_REQUIRED',
|
||||||
});
|
}).as('badRequest');
|
||||||
|
cy.get('.q-list').should('be.visible').first().should('be.visible').click();
|
||||||
|
cy.wait('@badRequest');
|
||||||
|
|
||||||
it('when token not exists', () => {
|
cy.checkNotification('Your session has expired. Please log in again');
|
||||||
cy.get('.q-list').should('be.visible').first().should('be.visible').click();
|
|
||||||
cy.wait('@badRequest');
|
|
||||||
|
|
||||||
cy.checkNotification('Authorization Required');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue