refactor: refs #8388 reorganize variable declarations and improve DMS handling in EntryPreAccount.vue
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
parent
ce8127b723
commit
dd3a7c7755
|
@ -27,8 +27,6 @@ const user = useState().getUser();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const updateDialog = ref();
|
const updateDialog = ref();
|
||||||
const uploadDialog = ref();
|
const uploadDialog = ref();
|
||||||
let maxDays;
|
|
||||||
let defaultDays;
|
|
||||||
const dataKey = 'entryPreaccountingFilter';
|
const dataKey = 'entryPreaccountingFilter';
|
||||||
const url = 'Entries/preAccountingFilter';
|
const url = 'Entries/preAccountingFilter';
|
||||||
const arrayData = useArrayData(dataKey);
|
const arrayData = useArrayData(dataKey);
|
||||||
|
@ -45,12 +43,16 @@ const defaultDmsDescription = ref();
|
||||||
const dmsTypeId = ref();
|
const dmsTypeId = ref();
|
||||||
const selectedRows = ref([]);
|
const selectedRows = ref([]);
|
||||||
const totalAmount = ref();
|
const totalAmount = ref();
|
||||||
|
const hasDiferentDms = ref(false);
|
||||||
|
let maxDays;
|
||||||
|
let defaultDays;
|
||||||
|
let supplierRef;
|
||||||
|
let dmsFk;
|
||||||
const totalSelectedAmount = computed(() => {
|
const totalSelectedAmount = computed(() => {
|
||||||
if (!selectedRows.value.length) return 0;
|
if (!selectedRows.value.length) return 0;
|
||||||
return selectedRows.value.reduce((acc, entry) => acc + entry.amount, 0);
|
return selectedRows.value.reduce((acc, entry) => acc + entry.amount, 0);
|
||||||
});
|
});
|
||||||
let supplierRef;
|
|
||||||
let dmsFk;
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
name: 'id',
|
name: 'id',
|
||||||
|
@ -238,8 +240,14 @@ function filterByDaysAgo(val) {
|
||||||
async function preAccount() {
|
async function preAccount() {
|
||||||
const entries = selectedRows.value;
|
const entries = selectedRows.value;
|
||||||
const { companyFk, isAgricultural, landed } = entries.at(0);
|
const { companyFk, isAgricultural, landed } = entries.at(0);
|
||||||
|
supplierRef = null;
|
||||||
|
dmsFk = undefined;
|
||||||
|
hasDiferentDms.value = false;
|
||||||
try {
|
try {
|
||||||
dmsFk = entries.find(({ gestDocFk }) => gestDocFk)?.gestDocFk;
|
entries.forEach(({ gestDocFk }) => {
|
||||||
|
if (!dmsFk) dmsFk = gestDocFk;
|
||||||
|
if (gestDocFk && dmsFk && dmsFk !== gestDocFk) hasDiferentDms.value = true;
|
||||||
|
});
|
||||||
if (isAgricultural) {
|
if (isAgricultural) {
|
||||||
const year = new Date(landed).getFullYear();
|
const year = new Date(landed).getFullYear();
|
||||||
supplierRef = (
|
supplierRef = (
|
||||||
|
@ -296,8 +304,6 @@ async function createInvoice() {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
supplierRef = null;
|
|
||||||
dmsFk = undefined;
|
|
||||||
selectedRows.value.length = 0;
|
selectedRows.value.length = 0;
|
||||||
table.value.reload();
|
table.value.reload();
|
||||||
}
|
}
|
||||||
|
@ -358,6 +364,7 @@ async function createInvoice() {
|
||||||
:search-remove-params="false"
|
:search-remove-params="false"
|
||||||
/>
|
/>
|
||||||
<VnTable
|
<VnTable
|
||||||
|
v-if="isBooked !== undefined && daysAgo !== undefined"
|
||||||
v-model:selected="selectedRows"
|
v-model:selected="selectedRows"
|
||||||
:data-key
|
:data-key
|
||||||
:columns
|
:columns
|
||||||
|
@ -376,7 +383,6 @@ async function createInvoice() {
|
||||||
@on-fetch="
|
@on-fetch="
|
||||||
(data) => (totalAmount = data?.reduce((acc, entry) => acc + entry.amount, 0))
|
(data) => (totalAmount = data?.reduce((acc, entry) => acc + entry.amount, 0))
|
||||||
"
|
"
|
||||||
auto-load
|
|
||||||
>
|
>
|
||||||
<template #top-left>
|
<template #top-left>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -436,6 +442,11 @@ async function createInvoice() {
|
||||||
:title="t('entry.preAccount.dialog.title')"
|
:title="t('entry.preAccount.dialog.title')"
|
||||||
:message="t('entry.preAccount.dialog.message')"
|
:message="t('entry.preAccount.dialog.message')"
|
||||||
>
|
>
|
||||||
|
<template #customHTML v-if="hasDiferentDms">
|
||||||
|
<p class="text-negative">
|
||||||
|
{{ t('differentGestdoc') }}
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<QBtn
|
<QBtn
|
||||||
data-cy="updateFileYes"
|
data-cy="updateFileYes"
|
||||||
|
@ -470,9 +481,11 @@ en:
|
||||||
IntraCommunity: Intra-community
|
IntraCommunity: Intra-community
|
||||||
NonCommunity: Non-community
|
NonCommunity: Non-community
|
||||||
CanaryIslands: Canary Islands
|
CanaryIslands: Canary Islands
|
||||||
|
differentGestdoc: The entries have different gestdoc
|
||||||
es:
|
es:
|
||||||
IntraCommunity: Intracomunitaria
|
IntraCommunity: Intracomunitaria
|
||||||
NonCommunity: Extracomunitaria
|
NonCommunity: Extracomunitaria
|
||||||
CanaryIslands: Islas Canarias
|
CanaryIslands: Islas Canarias
|
||||||
National: Nacional
|
National: Nacional
|
||||||
|
differentGestdoc: Las entradas tienen diferentes gestdoc
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue