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() {
|
||||
const entries = selectedRows.value;
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
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);
|
||||
const { companyFk, isAgricultural, landed } = entries.at(0);
|
||||
try {
|
||||
if (firstRow.isAgricultural) {
|
||||
const year = new Date(firstRow.landed).getFullYear();
|
||||
await axios.get('Entries/canAddInvoiceIn', {
|
||||
params: { entryIds: entries.map(({ id }) => id) },
|
||||
});
|
||||
|
||||
dmsFk = entries.find(({ gestDocFk }) => gestDocFk)?.gestDocFk;
|
||||
if (isAgricultural) {
|
||||
const year = new Date(landed).getFullYear();
|
||||
supplierRef = (
|
||||
await axios.get('InvoiceIns/getMaxRef', {
|
||||
params: { companyFk: firstRow.companyFk, year },
|
||||
})
|
||||
await axios.get('InvoiceIns/getMaxRef', { params: { companyFk, year } })
|
||||
).data;
|
||||
return createInvoice();
|
||||
} else if (dmsFk) {
|
||||
|
@ -266,7 +260,7 @@ async function preAccount() {
|
|||
|
||||
async function updateFile() {
|
||||
await axios.post(`Dms/${dmsFk}/updateFile`, { dmsTypeId: dmsTypeId.value });
|
||||
await createInvoice(false);
|
||||
await createInvoice();
|
||||
}
|
||||
|
||||
async function uploadFile() {
|
||||
|
@ -335,7 +329,7 @@ async function createInvoice() {
|
|||
url="EntryAccounts"
|
||||
:filter="{ fields: ['code', 'type'] }"
|
||||
@on-fetch="
|
||||
(data) => (entryAccounts = data.map((x) => ({ ...x, type: $t(x.type) })))
|
||||
(data) => (entryAccounts = data.map((x) => ({ ...x, type: t(x.type) })))
|
||||
"
|
||||
auto-load
|
||||
/>
|
||||
|
@ -467,3 +461,14 @@ async function createInvoice() {
|
|||
/>
|
||||
</QDialog>
|
||||
</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');
|
||||
});
|
||||
|
||||
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", () => {
|
||||
selectRowsByCol('id', [2]);
|
||||
cy.dataCy('preAccount_btn').click();
|
||||
|
|
Loading…
Reference in New Issue