From 5fc221b52c7bd16987355fc1bf81181453de2f28 Mon Sep 17 00:00:00 2001 From: jtubau Date: Fri, 21 Feb 2025 09:11:09 +0100 Subject: [PATCH 01/14] test: refs #8620 add RouteAutonomous e2e test --- .../integration/route/routeAutonomous.spec.js | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 test/cypress/integration/route/routeAutonomous.spec.js diff --git a/test/cypress/integration/route/routeAutonomous.spec.js b/test/cypress/integration/route/routeAutonomous.spec.js new file mode 100644 index 000000000..acf82bd95 --- /dev/null +++ b/test/cypress/integration/route/routeAutonomous.spec.js @@ -0,0 +1,121 @@ +describe('RouteAutonomous', () => { + const getLinkSelector = (colField) => + `tr:first-child > [data-col-field="${colField}"] > .no-padding > .link`; + + const selectors = { + reference: 'Reference_input', + date: 'tr:first-child > [data-col-field="dated"]', + total: '.value > .text-h6', + received: getLinkSelector('invoiceInFk'), + autonomous: getLinkSelector('supplierName'), + firstRowCheckbox: '.q-virtual-scroll__content tr:first-child .q-checkbox__bg', + secondRowCheckbox: '.q-virtual-scroll__content tr:nth-child(2) .q-checkbox__bg', + createInvoiceBtn: '.q-card > .q-btn', + saveFormBtn: 'FormModelPopup_save', + summaryIcon: 'tableAction-0', + summaryPopupBtn: '.header > :nth-child(2) > .q-btn__content > .q-icon', + summaryHeader: '.summaryHeader > :nth-child(2)', + descriptorHeader: '.summaryHeader > div', + descriptorTitle: '.q-item__label--header > .title > span', + summaryGoToSummaryBtn: '.header > .q-icon', + descriptorGoToSummaryBtn: '.descriptor > .header > a[href] > .q-btn', + }; + + const data = { + reference: 'Test invoice', + total: '€206.40', + supplier: 'PLANTS SL', + route: 'first route', + }; + + const summaryUrl = '/summary'; + const dataSaved = 'Data saved'; + + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/route/agency-term`); + cy.typeSearchbar('{enter}'); + }); + + it('Should list autonomous routes', () => { + cy.get('.q-table') + .children() + .should('be.visible') + .should('have.length.greaterThan', 0); + }); + + it('Should create invoice in to selected route', () => { + cy.get(selectors.firstRowCheckbox).click(); + cy.get(selectors.createInvoiceBtn).click(); + cy.dataCy(selectors.reference).type(data.reference); + cy.get('.q-file').selectFile('test/cypress/fixtures/image.jpg', { + force: true, + }); + cy.dataCy(selectors.saveFormBtn).click(); + cy.checkNotification(dataSaved); + cy.typeSearchbar('{enter}'); + }); + + it('Should display the total price of the selected rows', () => { + cy.get(selectors.firstRowCheckbox).click(); + cy.get(selectors.secondRowCheckbox).click(); + cy.validateContent(selectors.total, data.total); + }); + + it('Should redirect to the summary when clicking a route', () => { + cy.get(selectors.date).click(); + cy.get(selectors.summaryHeader).should('contain', data.route); + cy.url().should('include', summaryUrl); + }); + + describe('Received pop-ups', () => { + it('Should redirect to invoice in summary from the received descriptor pop-up', () => { + cy.get(selectors.received).click(); + cy.validateContent(selectors.descriptorTitle, data.reference); + cy.get(selectors.descriptorGoToSummaryBtn).click(); + cy.get(selectors.descriptorHeader).should('contain', data.supplier); + cy.url().should('include', summaryUrl); + }); + + it('Should redirect to the invoiceIn summary from summary pop-up from the received descriptor pop-up', () => { + cy.get(selectors.received).click(); + cy.validateContent(selectors.descriptorTitle, data.reference); + cy.get(selectors.summaryPopupBtn).click(); + cy.get(selectors.descriptorHeader).should('contain', data.supplier); + cy.get(selectors.summaryGoToSummaryBtn).click(); + cy.get(selectors.descriptorHeader).should('contain', data.supplier); + cy.url().should('include', summaryUrl); + }); + }); + + describe('Autonomous pop-ups', () => { + it('Should redirect to the supplier summary from the received descriptor pop-up', () => { + cy.get(selectors.autonomous).click(); + cy.validateContent(selectors.descriptorTitle, data.supplier); + cy.get(selectors.descriptorGoToSummaryBtn).click(); + cy.get(selectors.summaryHeader).should('contain', data.supplier); + cy.url().should('include', summaryUrl); + }); + + it('Should redirect to the supplier summary from summary pop-up from the autonomous descriptor pop-up', () => { + cy.get(selectors.autonomous).click(); + cy.get(selectors.descriptorTitle).should('contain', data.supplier); + cy.get(selectors.summaryPopupBtn).click(); + cy.get(selectors.summaryHeader).should('contain', data.supplier); + cy.get(selectors.summaryGoToSummaryBtn).click(); + cy.get(selectors.summaryHeader).should('contain', data.supplier); + cy.url().should('include', summaryUrl); + }); + }); + + describe('Route pop-ups', () => { + it('Should redirect to the summary from the route summary pop-up', () => { + cy.dataCy(selectors.summaryIcon).first().click(); + cy.get(selectors.summaryHeader).should('contain', data.route); + cy.get(selectors.summaryGoToSummaryBtn).click(); + cy.get(selectors.summaryHeader).should('contain', data.route); + cy.url().should('include', summaryUrl); + }); + }); +}); From 9e1ab1028d76bbd13bdfcc4b7c58bf1d885e78f1 Mon Sep 17 00:00:00 2001 From: jtubau Date: Fri, 21 Feb 2025 09:11:55 +0100 Subject: [PATCH 02/14] fix: refs #8620 add module name to InvoiceInSummary --- src/pages/InvoiceIn/Card/InvoiceInSummary.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue index d358601d3..18602f043 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue @@ -185,6 +185,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; data-key="InvoiceInSummary" :url="`InvoiceIns/${entityId}/summary`" @on-fetch="(data) => init(data)" + module-name="InvoiceIn" > From 0225dcc736f8ba749688a96fa6a8f33b168682f6 Mon Sep 17 00:00:00 2001 From: jtubau Date: Wed, 26 Feb 2025 11:47:31 +0100 Subject: [PATCH 04/14] fix: fixed agency and vehicle Fk and add select fields on create form --- src/pages/Route/RouteList.vue | 40 ++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/pages/Route/RouteList.vue b/src/pages/Route/RouteList.vue index bc3227f6c..899b3b8c3 100644 --- a/src/pages/Route/RouteList.vue +++ b/src/pages/Route/RouteList.vue @@ -38,6 +38,17 @@ const columns = computed(() => [ align: 'left', name: 'workerFk', label: t('route.Worker'), + component: 'select', + attrs: { + url: 'Workers/activeWithInheritedRole', + fields: ['id', 'name'], + useLike: false, + optionFilter: 'firstName', + find: { + value: 'workerFk', + label: 'workerUserName', + }, + }, create: true, cardVisible: true, format: (row, dashIfEmpty) => dashIfEmpty(row.travelRef), @@ -45,18 +56,40 @@ const columns = computed(() => [ }, { align: 'left', - name: 'agencyName', + name: 'agencyModeFk', label: t('route.Agency'), + format: (row) => row?.agencyName, cardVisible: true, + component: 'select', + attrs: { + url: 'agencyModes', + fields: ['id', 'name'], + find: { + value: 'agencyModeFk', + label: 'agencyName', + }, + }, create: true, columnClass: 'expand', columnFilter: false, }, { align: 'left', - name: 'vehiclePlateNumber', + name: 'vehicleFk', label: t('route.Vehicle'), + format: (row) => row?.vehiclePlateNumber, cardVisible: true, + component: 'select', + attrs: { + url: 'vehicles', + fields: ['id', 'numberPlate'], + optionLabel: 'numberPlate', + optionFilterValue: 'numberPlate', + find: { + value: 'vehicleFk', + label: 'vehiclePlateNumber', + }, + }, create: true, columnFilter: false, }, @@ -124,6 +157,7 @@ const columns = computed(() => [ - + \ No newline at end of file From 1c568227c2a39b41c8b9f0d3447d9b2d56e6236c Mon Sep 17 00:00:00 2001 From: jtubau Date: Thu, 27 Feb 2025 12:45:20 +0100 Subject: [PATCH 05/14] refactor: replace select component with VnSelectWorker in RouteList.vue --- src/pages/Route/RouteList.vue | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/pages/Route/RouteList.vue b/src/pages/Route/RouteList.vue index 899b3b8c3..58314a2f5 100644 --- a/src/pages/Route/RouteList.vue +++ b/src/pages/Route/RouteList.vue @@ -1,5 +1,5 @@ - @@ -286,7 +276,7 @@ function round(value) { justify-content: center; } .column { - min-width: 40%; + min-width: 35%; margin-top: 5%; display: flex; flex-direction: column; diff --git a/src/pages/Entry/EntryStockBoughtDetail.vue b/src/pages/Entry/EntryStockBoughtDetail.vue index 1a37994d9..4f002ecb9 100644 --- a/src/pages/Entry/EntryStockBoughtDetail.vue +++ b/src/pages/Entry/EntryStockBoughtDetail.vue @@ -14,7 +14,7 @@ const $props = defineProps({ required: true, }, dated: { - type: Date, + type: [Date, String], required: true, }, }); diff --git a/src/pages/Item/Card/ItemDiary.vue b/src/pages/Item/Card/ItemDiary.vue index 31b3c328e..b63a13423 100644 --- a/src/pages/Item/Card/ItemDiary.vue +++ b/src/pages/Item/Card/ItemDiary.vue @@ -12,7 +12,7 @@ import FetchData from 'components/FetchData.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue'; -import { toDateFormat } from 'src/filters/date.js'; +import { toDateTimeFormat } from 'src/filters/date.js'; import { dashIfEmpty } from 'src/filters'; import { date } from 'quasar'; import { useState } from 'src/composables/useState'; @@ -143,7 +143,12 @@ onMounted(async () => { const fetchItemBalances = async () => await arrayDataItemBalances.fetch({}); const getBadgeAttrs = (_date) => { - const isSameDate = date.isSameDate(today, _date); + let today = Date.vnNew(); + today.setHours(0, 0, 0, 0); + let timeTicket = new Date(_date); + timeTicket.setHours(0, 0, 0, 0); + + const isSameDate = date.isSameDate(today, timeTicket); const attrs = { 'text-color': isSameDate ? 'black' : 'white', color: isSameDate ? 'warning' : 'transparent', @@ -153,6 +158,7 @@ const getBadgeAttrs = (_date) => { const scrollToToday = async () => { await nextTick(); + console.log('today.toISOString(): ', today.toISOString()); const todayCell = document.querySelector(`td[data-date="${today.toISOString()}"]`); if (todayCell) { todayCell.scrollIntoView({ behavior: 'smooth', block: 'center' }); @@ -244,7 +250,7 @@ async function updateWarehouse(warehouseFk) { dense style="font-size: 14px" > - {{ toDateFormat(row.shipped) }} + {{ toDateTimeFormat(row.shipped) }} diff --git a/src/pages/Item/Card/ItemLastEntries.vue b/src/pages/Item/Card/ItemLastEntries.vue index 7d8890c2b..1eaaa931f 100644 --- a/src/pages/Item/Card/ItemLastEntries.vue +++ b/src/pages/Item/Card/ItemLastEntries.vue @@ -11,7 +11,6 @@ import { toCurrency } from 'filters/index'; import { useArrayData } from 'composables/useArrayData'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; - const { t } = useI18n(); const route = useRoute(); const from = ref(); @@ -41,7 +40,7 @@ const itemLastEntries = ref([]); const columns = computed(() => [ { - label: 'Nv', + label: 'NV', name: 'ig', align: 'center', }, @@ -70,6 +69,7 @@ const columns = computed(() => [ field: 'reference', align: 'center', format: (_, row) => toCurrency(row.price2) + ' / ' + toCurrency(row.price3), + style: (row) => highlightedRow(row), }, { label: t('lastEntries.printedStickers'), @@ -84,6 +84,7 @@ const columns = computed(() => [ field: 'stickers', align: 'center', format: (val) => dashIfEmpty(val), + style: (row) => highlightedRow(row), }, { label: 'Packing', @@ -102,12 +103,14 @@ const columns = computed(() => [ name: 'stems', field: 'stems', align: 'center', + style: (row) => highlightedRow(row), }, { label: t('lastEntries.quantity'), name: 'quantity', field: 'quantity', align: 'center', + style: (row) => highlightedRow(row), }, { label: t('lastEntries.cost'), @@ -120,12 +123,14 @@ const columns = computed(() => [ name: 'weight', field: 'weight', align: 'center', + style: (row) => highlightedRow(row), }, { label: t('lastEntries.cube'), name: 'cube', field: 'packagingFk', align: 'center', + style: (row) => highlightedRow(row), }, { label: t('lastEntries.supplier'), @@ -203,11 +208,28 @@ onMounted(async () => { if (nTo && nTo != oTo) nTo = getDate(new Date(nTo), 'to'); updateFilter(); }); + + const rows = document.querySelectorAll('tr'); + console.log('rows: ', rows); + rows.forEach((row) => { + const td = row.querySelector('td[data-is-inventory="1"]'); + if (td) { + row.classList.add('inventory-row'); + } + }); }); function getBadgeClass(groupingMode, expectedGrouping) { return groupingMode === expectedGrouping ? 'accent-badge' : 'simple-badge'; } + +function highlightedRow(row) { + return row?.isInventorySupplier + ? { + 'background-color': 'var(--vn-section-hover-color)', + } + : ''; +}