fix: refs #8277 update preAccount function to handle agricultural entries and adjust notification checks
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
00063ae20a
commit
d51b03a941
|
@ -230,23 +230,17 @@ function filterByDaysAgo(val) {
|
||||||
|
|
||||||
async function preAccount() {
|
async function preAccount() {
|
||||||
const entries = selectedRows.value;
|
const entries = selectedRows.value;
|
||||||
for (let i = 0; i < entries.length; i++) {
|
const { companyFk, isAgricultural, landed } = entries.at(0);
|
||||||
const { supplierFk, companyFk } = entries[i];
|
|
||||||
const nextEntry = entries[+i + 1];
|
|
||||||
|
|
||||||
if (!dmsFk && entries[i].gestDocFk) dmsFk = entries[i].gestDocFk;
|
|
||||||
if (!nextEntry) break;
|
|
||||||
else if (nextEntry.supplierFk !== supplierFk || nextEntry.companyFk !== companyFk)
|
|
||||||
return notify('Entries must have the same supplier and company', 'negative');
|
|
||||||
}
|
|
||||||
const firstRow = entries.at(0);
|
|
||||||
try {
|
try {
|
||||||
if (firstRow.isAgricultural) {
|
await axios.get('Entries/canAddInvoiceIn', {
|
||||||
const year = new Date(firstRow.landed).getFullYear();
|
params: { entryIds: entries.map(({ id }) => id) },
|
||||||
|
});
|
||||||
|
|
||||||
|
dmsFk = entries.find(({ gestDocFk }) => gestDocFk)?.gestDocFk;
|
||||||
|
if (isAgricultural) {
|
||||||
|
const year = new Date(landed).getFullYear();
|
||||||
supplierRef = (
|
supplierRef = (
|
||||||
await axios.get('InvoiceIns/getMaxRef', {
|
await axios.get('InvoiceIns/getMaxRef', { params: { companyFk, year } })
|
||||||
params: { companyFk: firstRow.companyFk, year },
|
|
||||||
})
|
|
||||||
).data;
|
).data;
|
||||||
return createInvoice();
|
return createInvoice();
|
||||||
} else if (dmsFk) {
|
} else if (dmsFk) {
|
||||||
|
@ -266,7 +260,7 @@ async function preAccount() {
|
||||||
|
|
||||||
async function updateFile() {
|
async function updateFile() {
|
||||||
await axios.post(`Dms/${dmsFk}/updateFile`, { dmsTypeId: dmsTypeId.value });
|
await axios.post(`Dms/${dmsFk}/updateFile`, { dmsTypeId: dmsTypeId.value });
|
||||||
await createInvoice(false);
|
await createInvoice();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function uploadFile() {
|
async function uploadFile() {
|
||||||
|
@ -335,7 +329,7 @@ async function createInvoice() {
|
||||||
url="EntryAccounts"
|
url="EntryAccounts"
|
||||||
:filter="{ fields: ['code', 'type'] }"
|
:filter="{ fields: ['code', 'type'] }"
|
||||||
@on-fetch="
|
@on-fetch="
|
||||||
(data) => (entryAccounts = data.map((x) => ({ ...x, type: $t(x.type) })))
|
(data) => (entryAccounts = data.map((x) => ({ ...x, type: t(x.type) })))
|
||||||
"
|
"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
|
@ -467,3 +461,14 @@ async function createInvoice() {
|
||||||
/>
|
/>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
<i18n>
|
||||||
|
en:
|
||||||
|
IntraCommunity: Intra-community
|
||||||
|
NonCommunity: Non-community
|
||||||
|
CanaryIsland: Canary Islands
|
||||||
|
es:
|
||||||
|
IntraCommunity: Intracomunitario
|
||||||
|
NonCommunity: Extracomunitario
|
||||||
|
CanaryIsland: Islas Canarias
|
||||||
|
National: Nacional
|
||||||
|
</i18n>
|
||||||
|
|
|
@ -11,6 +11,12 @@ describe('Entry PreAccount Functionality', () => {
|
||||||
cy.checkNotification('Entries must have the same supplier and company');
|
cy.checkNotification('Entries must have the same supplier and company');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle entries with different gestdoc files', () => {
|
||||||
|
selectRowsByCol('id', [3, 101]);
|
||||||
|
cy.dataCy('preAccount_btn').click();
|
||||||
|
cy.checkNotification('Entries have different gestdoc file');
|
||||||
|
});
|
||||||
|
|
||||||
it("should pre-account without questions if it's agricultural", () => {
|
it("should pre-account without questions if it's agricultural", () => {
|
||||||
selectRowsByCol('id', [2]);
|
selectRowsByCol('id', [2]);
|
||||||
cy.dataCy('preAccount_btn').click();
|
cy.dataCy('preAccount_btn').click();
|
||||||
|
|
Loading…
Reference in New Issue