#6321 - Negative ticket #158

Open
jsegarra wants to merge 156 commits from 6321_negative_tickets into dev
14 changed files with 142 additions and 81 deletions
Showing only changes of commit 967fb4592b - Show all commits

View File

@ -5,16 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2416.01] - 2024-04-18
### Added
## [2414.01] - 2024-04-04
### Added
- (Tickets) => Se añade la opción de clonar ticket. #6951
- (Parking) => Se añade la sección Parking. #5186
### Changed
### Fixed
- (General) => Se corrige la redirección cuando hay 1 solo registro y cuando se aplica un filtro diferente al id al hacer una búsqueda general. #6893
## [2400.01] - 2024-01-04
### Added

View File

@ -1,6 +1,6 @@
{
"name": "salix-front",
"version": "24.14.0",
"version": "24.16.0",
"description": "Salix frontend",
"productName": "Salix",
"author": "Verdnatura",

View File

@ -198,9 +198,11 @@ function addDefaultData(data) {
en:
contentTypesInfo: Allowed file types {allowedContentTypes}
EntryDmsDescription: Reference {reference}
SupplierDmsDescription: Reference {reference}
es:
Generate identifier for original file: Generar identificador para archivo original
contentTypesInfo: Tipos de archivo permitidos {allowedContentTypes}
EntryDmsDescription: Referencia {reference}
SupplierDmsDescription: Referencia {reference}
</i18n>

View File

@ -1,11 +1,9 @@
<script setup>
import { onMounted, ref } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import VnInput from 'src/components/common/VnInput.vue';
import { useArrayData } from 'composables/useArrayData';
import VnInput from 'src/components/common/VnInput.vue';
const quasar = useQuasar();
@ -68,9 +66,8 @@ const props = defineProps({
});
const router = useRouter();
const route = useRoute();
const arrayData = useArrayData(props.dataKey, { ...props });
const store = arrayData.store;
const { store } = arrayData;
const searchText = ref('');
onMounted(() => {
@ -92,18 +89,26 @@ async function search() {
});
if (!props.redirect) return;
if (props.customRouteRedirectName) {
router.push({
if (props.customRouteRedirectName)
return router.push({
name: props.customRouteRedirectName,
params: { id: searchText.value },
});
return;
}
const { matched: matches } = route;
const { path } = matches[matches.length - 1];
const newRoute = path.replace(':id', searchText.value);
await router.push(newRoute);
const { matched: matches } = router.currentRoute.value;
const { path } = matches.at(-1);
const [, moduleName] = path.split('/');
if (!store.data.length || store.data.length > 1)
return router.push({ path: `/${moduleName}/list` });
const targetId = store.data[0].id;
let targetUrl;
if (path.endsWith('/list')) targetUrl = path.replace('/list', `/${targetId}/summary`);
else if (path.includes(':id')) targetUrl = path.replace(':id', targetId);
await router.push({ path: targetUrl });
}
</script>

View File

@ -4,7 +4,7 @@ import { useQuasar } from 'quasar';
export function usePrintService() {
const quasar = useQuasar();
const { getToken } = useSession();
const { getTokenMultimedia } = useSession();
function sendEmail(path, params) {
return axios.post(path, params).then(() =>
@ -19,7 +19,7 @@ export function usePrintService() {
function openReport(path, params) {
params = Object.assign(
{
access_token: getToken(),
access_token: getTokenMultimedia(),
},
params
);

View File

@ -130,4 +130,4 @@ input::-webkit-inner-spin-button {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
}
}

View File

@ -503,6 +503,7 @@ export default {
request: 'Request',
weight: 'Weight',
goTo: 'Go to',
summaryAmount: 'Summary',
},
negative: {
hour: 'Hour',
@ -1082,6 +1083,7 @@ export default {
addresses: 'Addresses',
consumption: 'Consumption',
agencyTerm: 'Agency agreement',
dms: 'File management',
},
list: {
payMethod: 'Pay method',

View File

@ -546,6 +546,7 @@ export default {
request: 'Petición de compra',
weight: 'Peso',
goTo: 'Ir a',
summaryAmount: 'Resumen',
},
},
claim: {
@ -1081,6 +1082,7 @@ export default {
addresses: 'Direcciones',
consumption: 'Consumo',
agencyTerm: 'Acuerdo agencia',
dms: 'Gestión documental',
},
list: {
payMethod: 'Método de pago',

View File

@ -22,7 +22,7 @@ const { t } = useI18n();
const router = useRouter();
const stateStore = useStateStore();
const session = useSession();
const token = session.getToken();
const tokenMultimedia = session.getTokenMultimedia();
const { viewSummary } = useSummaryDialog();
const manualInvoiceDialogRef = ref(null);
@ -66,7 +66,7 @@ const openPdf = () => {
if (selectedCards.value.size === 1) {
const [invoiceOut] = selectedCardsArray;
const url = `api/InvoiceOuts/${invoiceOut.id}/download?access_token=${token}`;
const url = `api/InvoiceOuts/${invoiceOut.id}/download?access_token=${tokenMultimedia}`;
window.open(url, '_blank');
} else {
const invoiceOutIdsArray = selectedCardsArray.map(
@ -75,7 +75,7 @@ const openPdf = () => {
const invoiceOutIds = invoiceOutIdsArray.join(',');
const params = new URLSearchParams({
access_token: token,
access_token: tokenMultimedia,
ids: invoiceOutIds,
});

View File

@ -0,0 +1,11 @@
<script setup>
import VnDmsList from 'src/components/common/VnDmsList.vue';
</script>
<template>
<VnDmsList
model="SupplierDms"
update-model="SupplierDms"
default-dms-code="supplier"
filter="supplierFk"
/>
</template>

View File

@ -131,22 +131,6 @@ async function changeState(value) {
</QBtnDropdown>
</template>
<template #body>
<QCard class="vn-max">
<div class="taxes">
<VnLv
:label="t('ticket.summary.subtotal')"
:value="toCurrency(ticket.totalWithoutVat)"
/>
<VnLv
:label="t('ticket.summary.vat')"
:value="toCurrency(ticket.totalWithVat - ticket.totalWithoutVat)"
/>
<VnLv
:label="t('ticket.summary.total')"
:value="toCurrency(ticket.totalWithVat)"
/>
</div>
</QCard>
<QCard class="vn-one">
<VnTitle
:url="ticketUrl + 'basic-data/step-one'"
@ -236,7 +220,7 @@ async function changeState(value) {
:value="formattedAddress()"
/>
</QCard>
<QCard class="vn-one">
<QCard class="vn-one" v-if="ticket.notes.length">
<VnTitle
:url="ticketUrl + 'observation'"
:text="t('ticket.pageTitles.notes')"
@ -258,6 +242,23 @@ async function changeState(value) {
</template>
</VnLv>
</QCard>
<QCard class="vn-one">
<VnTitle :text="t('ticket.summary.summaryAmount')" />
<div class="bodyCard">
<VnLv
:label="t('ticket.summary.subtotal')"
:value="toCurrency(ticket.totalWithoutVat)"
/>
<VnLv
:label="t('ticket.summary.vat')"
:value="toCurrency(ticket.totalWithVat - ticket.totalWithoutVat)"
/>
<VnLv
:label="t('ticket.summary.total')"
:value="toCurrency(ticket.totalWithVat)"
/>
</div>
</QCard>
<QCard class="vn-max">
<VnTitle
:url="ticketUrl + 'sale'"
@ -448,21 +449,10 @@ async function changeState(value) {
.notes {
width: max-content;
}
.cardSummary .summaryBody > .q-card > .taxes {
border: 2px solid gray;
padding: 0;
> .vn-label-value {
text-align: right;
display: flex;
flex-direction: row;
margin-top: 5px;
justify-content: flex-end;
padding-right: 20px;
.q-card.q-card--dark.q-dark.vn-one {
& > .bodyCard {
padding: 1%;
}
}
.cardSummary .summaryBody > .q-card:has(.taxes) {
margin-top: 2px;
padding: 0;
}
</style>

View File

@ -22,6 +22,7 @@ export default {
'SupplierAddresses',
'SupplierConsumption',
'SupplierAgencyTerm',
'SupplierDms',
],
},
children: [
@ -161,6 +162,15 @@ export default {
component: () =>
import('src/pages/Supplier/Card/SupplierAgencyTerm.vue'),
},
{
path: 'dms',
name: 'SupplierDms',
meta: {
title: 'dms',
icon: 'smb_share',
},
component: () => import('src/pages/Supplier/Card/SupplierDms.vue'),
},
{
path: 'agency-term/create',
name: 'SupplierAgencyTermCreate',

View File

@ -1,19 +1,42 @@
/// <reference types="cypress" />
describe('VnSearchBar', () => {
const employeeId = ' #1';
const salesPersonId = ' #18';
const idGap = '.q-item > .q-item__label';
const cardList = '.vn-card-list';
let url;
beforeEach(() => {
cy.login('developer');
cy.visit('/');
cy.visit('#/customer/list');
cy.url().then((currentUrl) => (url = currentUrl));
});
it('should redirect to new customer', () => {
cy.visit('#/customer/1112/basic-data');
cy.openLeftMenu();
cy.get('.q-item > .q-item__label').should('have.text', ' #1112');
cy.closeSideMenu();
cy.clearSearchbar();
cy.writeSearchbar('1{enter}');
cy.openLeftMenu();
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
cy.closeSideMenu();
it('should redirect to customer summary page', () => {
searchAndCheck('1', employeeId);
searchAndCheck('salesPerson', salesPersonId);
});
it('should stay on the list page if there are several results or none', () => {
cy.writeSearchbar('salesA{enter}');
checkCardListAndUrl(2);
cy.clearSearchbar();
cy.writeSearchbar('0{enter}');
checkCardListAndUrl(0);
});
const searchAndCheck = (searchTerm, expectedText) => {
cy.clearSearchbar();
cy.writeSearchbar(`${searchTerm}{enter}`);
cy.get(idGap).should('have.text', expectedText);
};
const checkCardListAndUrl = (expectedLength) => {
cy.get(cardList).then(($cardList) => {
expect($cardList.find('.q-card').length).to.equal(expectedLength);
cy.url().then((currentUrl) => expect(currentUrl).to.equal(url));
});
};
});

View File

@ -1,11 +1,11 @@
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper';
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
// Probar a importar como plugin vue-router en archivo helper
describe('VnSearchBar', () => {
let vm;
let wrapper;
let pushSpy;
beforeAll(() => {
wrapper = createWrapper(VnSearchbar, {
@ -16,7 +16,7 @@ describe('VnSearchBar', () => {
},
});
vm = wrapper.vm;
vm.route.matched = [
vm.router.currentRoute.value.matched = [
{
path: '/',
},
@ -30,24 +30,33 @@ describe('VnSearchBar', () => {
path: '/customer/:id/basic-data',
},
];
pushSpy = vi.spyOn(vm.router, 'push');
vi.spyOn(vm.arrayData, 'applyFilter');
});
afterEach(() => {
vi.clearAllMocks();
});
beforeEach(() => (vm.store.data = [{ id: 1112, name: 'Trash' }]));
afterEach(() => vi.clearAllMocks());
it('should be defined', async () => {
expect(vm.searchText).toBeDefined();
expect(vm.searchText).toEqual('');
});
it('should redirect', async () => {
vi.spyOn(vm.router,'push');
vm.searchText = '1';
it('should redirect to list page if there are several results', async () => {
vm.store.data.push({ id: 1, name: 'employee' });
await vm.search();
expect(vm.router.push).toHaveBeenCalledWith('/customer/1/basic-data');
vm.searchText = '1112';
expect(vm.searchText).toEqual('1112');
vi.spyOn(vm.router,'push');
expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/list' });
});
it('should redirect to list page if there is no results', async () => {
vm.store.data.pop();
await vm.search();
expect(vm.router.push).toHaveBeenCalledWith('/customer/1112/basic-data');
});
expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/list' });
});
it('should redirect to basic-data page if there is only one result', async () => {
await vm.search();
expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/1112/basic-data' });
});
});