-
+
{{
diff --git a/src/pages/Ticket/TicketAdvance.vue b/src/pages/Ticket/TicketAdvance.vue
index 71e3926ac..9b6669acb 100644
--- a/src/pages/Ticket/TicketAdvance.vue
+++ b/src/pages/Ticket/TicketAdvance.vue
@@ -37,6 +37,7 @@ const userParams = reactive({
ipt: 'H',
futureIpt: 'H',
isFullMovable: true,
+ onlyWithDestination: true,
});
const ticketColumns = computed(() => [
@@ -464,6 +465,7 @@ watch(
color="primary"
name="vn:agency-term"
size="xs"
+ class="q-mr-xs"
>
@@ -482,6 +484,14 @@ watch(
+
+ {{ t('advanceTickets.clonedSales') }}
+
diff --git a/src/pages/Ticket/TicketAdvanceFilter.vue b/src/pages/Ticket/TicketAdvanceFilter.vue
index 6528bf380..6d5c7726e 100644
--- a/src/pages/Ticket/TicketAdvanceFilter.vue
+++ b/src/pages/Ticket/TicketAdvanceFilter.vue
@@ -168,6 +168,16 @@ onMounted(async () => await getItemPackingTypes());
+
+
+
+
+
@@ -182,6 +192,7 @@ en:
ipt: Destination IPT
isFullMovable: 100% movable
warehouseFk: Warehouse
+ onlyWithDestination: Only with destination
es:
Horizontal: Horizontal
Vertical: Vertical
@@ -193,4 +204,5 @@ es:
ipt: IPT destino
isFullMovable: 100% movible
warehouseFk: Almacén
+ onlyWithDestination: Solo con destino
diff --git a/src/pages/Ticket/locale/en.yml b/src/pages/Ticket/locale/en.yml
index 56cc798ba..f11b32c3a 100644
--- a/src/pages/Ticket/locale/en.yml
+++ b/src/pages/Ticket/locale/en.yml
@@ -53,6 +53,7 @@ advanceTickets:
errorsList: Errors list
search: Search advance tickets
searchInfo: Search advance tickets by ID or client ID
+ clonedSales: Has turn lines
futureTickets:
problems: Problems
shipped: Date
diff --git a/src/pages/Ticket/locale/es.yml b/src/pages/Ticket/locale/es.yml
index bb068ac5b..945da8367 100644
--- a/src/pages/Ticket/locale/es.yml
+++ b/src/pages/Ticket/locale/es.yml
@@ -91,6 +91,7 @@ advanceTickets:
errorsList: Lista de errores
search: Buscar por tickets adelantados
searchInfo: Buscar tickets adelantados por el identificador o el identificador del cliente
+ clonedSales: Tiene líneas de turno
futureTickets:
problems: Problemas
shipped: Fecha
diff --git a/src/stores/invoiceOutGlobal.js b/src/stores/invoiceOutGlobal.js
index 332494aa8..cc8d86ea8 100644
--- a/src/stores/invoiceOutGlobal.js
+++ b/src/stores/invoiceOutGlobal.js
@@ -19,7 +19,7 @@ export const useInvoiceOutGlobalStore = defineStore({
maxShipped: null,
clientId: null,
printer: null,
- serialType: null,
+ serialType: 'global',
},
addresses: [],
minInvoicingDate: null,
@@ -41,7 +41,6 @@ export const useInvoiceOutGlobalStore = defineStore({
async fetchAllData() {
try {
- const userInfo = await useUserConfig().fetch();
const date = Date.vnNew();
this.formInitialData.maxShipped = new Date(
date.getFullYear(),
@@ -53,7 +52,7 @@ export const useInvoiceOutGlobalStore = defineStore({
await Promise.all([
this.fetchParallelism(),
- this.fetchInvoiceOutConfig(userInfo.companyFk),
+ this.fetchInvoiceOutConfig(),
]);
this.initialDataLoading = false;
@@ -62,21 +61,23 @@ export const useInvoiceOutGlobalStore = defineStore({
}
},
- async fetchInvoiceOutConfig(companyFk) {
+ async fetchInvoiceOutConfig(formData = this.formInitialData) {
try {
- this.formInitialData.companyFk = companyFk;
- const params = { companyFk: companyFk };
+ const userInfo = await useUserConfig().fetch();
+ const params = {
+ companyFk: userInfo.companyFk,
+ serialType: formData.serialType,
+ };
const { data } = await axios.get('InvoiceOuts/getInvoiceDate', {
params,
});
- const stringDate = data.issued.substring(0, 10);
- this.minInvoicingDate = stringDate;
- this.formInitialData.invoiceDate = stringDate;
-
- this.minInvoicingDate = new Date(data.issued);
+ this.minInvoicingDate = data?.issued
+ ? new Date(data.issued)
+ : Date.vnNew();
this.formInitialData.invoiceDate = this.minInvoicingDate;
+ formData.invoiceDate = this.minInvoicingDate;
} catch (err) {
console.error('Error fetching invoice out global initial data');
throw new Error();
diff --git a/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js b/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js
index f6dac4c73..4c2550548 100644
--- a/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js
@@ -2,7 +2,7 @@
describe('InvoiceInIntrastat', () => {
const firstRow = 'tbody > :nth-child(1)';
const thirdRow = 'tbody > :nth-child(3)';
- const firstRowCode = `${firstRow} > :nth-child(2)`;
+ const codes = `[data-cy="intrastat-code"]`;
const firstRowAmount = `${firstRow} > :nth-child(3)`;
beforeEach(() => {
@@ -11,13 +11,12 @@ describe('InvoiceInIntrastat', () => {
});
it('should edit the first line', () => {
- cy.selectOption(firstRowCode, 'Plantas vivas: Esqueje/injerto, Vid');
+ cy.selectOption(`${firstRow} ${codes}`, 'Plantas vivas: Esqueje/injerto, Vid');
cy.get(firstRowAmount).clear();
cy.saveCard();
- cy.get(`${firstRowCode} span`).should(
- 'have.text',
- '6021010:Plantas vivas: Esqueje/injerto, Vid'
- );
+ cy.get(codes)
+ .eq(0)
+ .should('have.value', '6021010: Plantas vivas: Esqueje/injerto, Vid');
});
it('should add a new row', () => {
diff --git a/test/cypress/integration/invoiceIn/invoiceInList.spec.js b/test/cypress/integration/invoiceIn/invoiceInList.spec.js
index fa0d1c5e4..d9ab3f7e7 100644
--- a/test/cypress/integration/invoiceIn/invoiceInList.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInList.spec.js
@@ -1,7 +1,7 @@
///
describe('InvoiceInList', () => {
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
- const firstId = `${firstRow} > td:nth-child(1) span`;
+ const firstId = `${firstRow} > td:nth-child(2) span`;
const firstDetailBtn = `${firstRow} .q-btn:nth-child(1)`;
const summaryHeaders = '.summaryBody .header-link';
diff --git a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
index b84d743d1..f8b403a45 100644
--- a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
@@ -2,6 +2,7 @@
describe('InvoiceInVat', () => {
const thirdRow = 'tbody > :nth-child(3)';
const firstLineVat = 'tbody > :nth-child(1) > :nth-child(4)';
+ const vats = '[data-cy="vat-sageiva"]';
const dialogInputs = '.q-dialog label input';
const addBtn = 'tbody tr:nth-child(1) td:nth-child(2) .--add-icon';
const randomInt = Math.floor(Math.random() * 100);
@@ -14,9 +15,9 @@ describe('InvoiceInVat', () => {
});
it('should edit the sage iva', () => {
- cy.selectOption(firstLineVat, 'H.P. IVA 21% CEE');
+ cy.selectOption(`${firstLineVat} ${vats}`, 'H.P. IVA 21% CEE');
cy.saveCard();
- cy.get(`${firstLineVat} span`).should('have.text', '8:H.P. IVA 21% CEE');
+ cy.get(vats).eq(0).should('have.value', '8: H.P. IVA 21% CEE');
});
it('should add a new row', () => {
diff --git a/test/vitest/__tests__/composables/getExchange.spec.js b/test/vitest/__tests__/composables/getExchange.spec.js
new file mode 100644
index 000000000..dba31458e
--- /dev/null
+++ b/test/vitest/__tests__/composables/getExchange.spec.js
@@ -0,0 +1,45 @@
+import { describe, expect, it, vi } from 'vitest';
+import axios from 'axios';
+import { getExchange } from 'src/composables/getExchange';
+
+vi.mock('axios');
+
+describe('getExchange()', () => {
+ it('should return the correct exchange rate', async () => {
+ axios.get.mockResolvedValue({
+ data: { value: 1.2 },
+ });
+
+ const amount = 100;
+ const currencyFk = 1;
+ const dated = '2023-01-01';
+ const result = await getExchange(amount, currencyFk, dated);
+
+ expect(result).toBe('83.33');
+ });
+
+ it('should return the correct exchange rate with custom decimal places', async () => {
+ axios.get.mockResolvedValue({
+ data: { value: 1.2 },
+ });
+
+ const amount = 100;
+ const currencyFk = 1;
+ const dated = '2023-01-01';
+ const decimalPlaces = 3;
+ const result = await getExchange(amount, currencyFk, dated, decimalPlaces);
+
+ expect(result).toBe('83.333');
+ });
+
+ it('should return null if the API call fails', async () => {
+ axios.get.mockRejectedValue(new Error('Network error'));
+
+ const amount = 100;
+ const currencyFk = 1;
+ const dated = '2023-01-01';
+ const result = await getExchange(amount, currencyFk, dated);
+
+ expect(result).toBeNull();
+ });
+});
diff --git a/test/vitest/__tests__/composables/getTotal.spec.js b/test/vitest/__tests__/composables/getTotal.spec.js
new file mode 100644
index 000000000..789e3fbcf
--- /dev/null
+++ b/test/vitest/__tests__/composables/getTotal.spec.js
@@ -0,0 +1,55 @@
+import { vi, describe, expect, it } from 'vitest';
+import { getTotal } from 'src/composables/getTotal';
+
+vi.mock('src/filters', () => ({
+ toCurrency: vi.fn((value, currency) => `${currency} ${value.toFixed(2)}`),
+}));
+
+describe('getTotal()', () => {
+ const rows = [
+ { amount: 10.5, tax: 2.1 },
+ { amount: 20.75, tax: 3.25 },
+ { amount: 30.25, tax: 4.75 },
+ ];
+
+ it('should calculate the total for a given key', () => {
+ const total = getTotal(rows, 'amount');
+ expect(total).toBe('61.50');
+ });
+
+ it('should calculate the total with a callback function', () => {
+ const total = getTotal(rows, null, { cb: (row) => row.amount + row.tax });
+ expect(total).toBe('71.60');
+ });
+
+ it('should format the total as currency', () => {
+ const total = getTotal(rows, 'amount', { currency: 'USD' });
+ expect(total).toBe('USD 61.50');
+ });
+
+ it('should format the total as currency with default currency', () => {
+ const total = getTotal(rows, 'amount', { currency: 'default' });
+ expect(total).toBe('undefined 61.50');
+ });
+
+ it('should calculate the total with integer formatting', () => {
+ const total = getTotal(rows, 'amount', { decimalPlaces: 0 });
+ expect(total).toBe('62');
+ });
+
+ it('should calculate the total with custom decimal places', () => {
+ const total = getTotal(rows, 'amount', { decimalPlaces: 1 });
+ expect(total).toBe('61.5');
+ });
+
+ it('should handle rows with missing keys', () => {
+ const rowsWithMissingKeys = [{ amount: 10.5 }, { amount: 20.75 }, {}];
+ const total = getTotal(rowsWithMissingKeys, 'amount');
+ expect(total).toBe('31.25');
+ });
+
+ it('should handle empty rows', () => {
+ const total = getTotal([], 'amount');
+ expect(total).toBe('0.00');
+ });
+});
diff --git a/test/vitest/__tests__/composables/useAccountShortToStandard.spec.js b/test/vitest/__tests__/composables/useAccountShortToStandard.spec.js
new file mode 100644
index 000000000..d24585812
--- /dev/null
+++ b/test/vitest/__tests__/composables/useAccountShortToStandard.spec.js
@@ -0,0 +1,9 @@
+import { describe, expect, it } from 'vitest';
+import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
+
+describe('useAccountShortToStandard()', () => {
+ it('should pad the decimal part with zeros for short numbers', () => {
+ expect(useAccountShortToStandard('123.45')).toBe('1230000045');
+ expect(useAccountShortToStandard('123.')).toBe('1230000000');
+ });
+});
diff --git a/test/vitest/__tests__/pages/InvoiceIn/InvoiceInIntrastat.spec.js b/test/vitest/__tests__/pages/InvoiceIn/InvoiceInIntrastat.spec.js
deleted file mode 100644
index adfb054c6..000000000
--- a/test/vitest/__tests__/pages/InvoiceIn/InvoiceInIntrastat.spec.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import { vi, describe, expect, it, beforeAll } from 'vitest';
-import { createWrapper, axios } from 'app/test/vitest/helper';
-import InvoiceInIntrastat from 'src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue';
-
-describe('InvoiceInIntrastat', () => {
- let vm;
-
- beforeAll(() => {
- vm = createWrapper(InvoiceInIntrastat, {
- global: {
- stubs: ['vnPaginate'],
- mocks: {
- fetch: vi.fn(),
- },
- },
- }).vm;
- vi.spyOn(axios, 'get').mockResolvedValue({ data: [{}] });
- });
-
- describe('getTotal()', () => {
- it('should correctly handle the sum', () => {
- const invoceInIntrastat = [
- { amount: 10, stems: 162 },
- { amount: 20, stems: 21 },
- ];
-
- const totalAmount = vm.getTotal(invoceInIntrastat, 'amount');
- const totalStems = vm.getTotal(invoceInIntrastat, 'stems');
-
- expect(totalAmount).toBe(10 + 20);
- expect(totalStems).toBe(162 + 21);
- });
- });
-});
diff --git a/test/vitest/__tests__/pages/InvoiceIn/InvoiceInVat.spec.js b/test/vitest/__tests__/pages/InvoiceIn/InvoiceInVat.spec.js
deleted file mode 100644
index 76453f65a..000000000
--- a/test/vitest/__tests__/pages/InvoiceIn/InvoiceInVat.spec.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import { vi, describe, expect, it, beforeAll } from 'vitest';
-import { createWrapper } from 'app/test/vitest/helper';
-import InvoiceInVat from 'src/pages/InvoiceIn/Card/InvoiceInVat.vue';
-
-describe('InvoiceInVat', () => {
- let vm;
-
- beforeAll(() => {
- vm = createWrapper(InvoiceInVat, {
- global: {
- stubs: [],
- mocks: {
- fetch: vi.fn(),
- },
- },
- }).vm;
- });
-
- describe('taxRate()', () => {
- it('should correctly compute the tax rate', () => {
- const invoiceInTax = { taxableBase: 100, taxTypeSageFk: 1 };
- vm.sageTaxTypes = [
- { id: 1, rate: 10 },
- { id: 2, rate: 20 },
- ];
- const result = vm.taxRate(invoiceInTax);
- expect(result).toBe((10 / 100) * 100);
- });
-
- it('should return 0 if there is not tax rate', () => {
- const invoiceInTax = { taxableBase: 100, taxTypeSageFk: 1 };
- vm.sageTaxTypes = [];
-
- const result = vm.taxRate(invoiceInTax);
- expect(result).toBe(0);
- });
- });
-});