diff --git a/src/components/ui/VnConfirm.vue b/src/components/ui/VnConfirm.vue
index fd4860107..4fa374b62 100644
--- a/src/components/ui/VnConfirm.vue
+++ b/src/components/ui/VnConfirm.vue
@@ -31,6 +31,7 @@ const props = defineProps({
});
defineEmits(['confirm', ...useDialogPluginComponent.emits]);
+defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
const { dialogRef, onDialogOK } = useDialogPluginComponent();
@@ -68,8 +69,10 @@ async function confirm() {
-
+
+
+
diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml
index 362c1ec9f..da86399af 100644
--- a/src/i18n/locale/en.yml
+++ b/src/i18n/locale/en.yml
@@ -98,6 +98,7 @@ globals:
to: To
notes: Notes
refresh: Refresh
+ weight: Weight
pageTitles:
logIn: Login
summary: Summary
diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml
index 34383686c..5e8efff1e 100644
--- a/src/i18n/locale/es.yml
+++ b/src/i18n/locale/es.yml
@@ -100,6 +100,7 @@ globals:
to: Hasta
notes: Notas
refresh: Actualizar
+ weight: Peso
pageTitles:
logIn: Inicio de sesión
summary: Resumen
diff --git a/src/pages/Ticket/Card/TicketDescriptorMenu.vue b/src/pages/Ticket/Card/TicketDescriptorMenu.vue
index 9a50288a0..4cf4e633f 100644
--- a/src/pages/Ticket/Card/TicketDescriptorMenu.vue
+++ b/src/pages/Ticket/Card/TicketDescriptorMenu.vue
@@ -9,6 +9,8 @@ import SendEmailDialog from 'components/common/SendEmailDialog.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
import VnSmsDialog from 'components/common/VnSmsDialog.vue';
import toDate from 'filters/toDate';
+import VnInputNumber from 'src/components/common/VnInputNumber.vue';
+import { useArrayData } from 'src/composables/useArrayData';
const props = defineProps({
ticket: {
@@ -21,9 +23,10 @@ const { push, currentRoute } = useRouter();
const { dialog, notify } = useQuasar();
const { t } = useI18n();
const { openReport, sendEmail } = usePrintService();
-
+const ticketSummary = useArrayData('TicketSummary');
const ticket = ref(props.ticket);
const ticketId = currentRoute.value.params.id;
+const weight = ref();
const actions = {
clone: async () => {
const opts = { message: t('Ticket cloned'), type: 'positive' };
@@ -46,6 +49,25 @@ const actions = {
push({ name: 'TicketSummary', params: { id: clonedTicketId } });
}
},
+ setWeight: async () => {
+ try {
+ const invoiceIds = (
+ await axios.post(`Tickets/${ticketId}/setWeight`, {
+ weight: weight.value,
+ })
+ ).data;
+
+ notify({ message: t('Weight set'), type: 'positive' });
+ if (invoiceIds.length)
+ notify({
+ message: t('invoiceIds', { invoiceIds: invoiceIds.join() }),
+ type: 'positive',
+ });
+ await ticketSummary.fetch({ updateRouter: false });
+ } catch (e) {
+ notify({ message: e.message, type: 'negative' });
+ }
+ },
remove: async () => {
try {
await axios.post(`Tickets/${ticketId}/setDeleted`);
@@ -255,6 +277,12 @@ function openConfirmDialog(callback) {
{{ t('To clone ticket') }}
+
+
+
+
+ {{ t('Set weight') }}
+
@@ -264,9 +292,25 @@ function openConfirmDialog(callback) {
{{ t('Delete ticket') }}
+
+
+
+
+
-
+en:
+ invoiceIds: "Invoices have been generated with the following ids: {invoiceIds}"
+
es:
Open Delivery Note...: Abrir albarán...
Send Delivery Note...: Enviar albarán...
@@ -284,4 +328,8 @@ es:
To clone ticket: Clonar ticket
Ticket cloned: Ticked clonado
It was not able to clone the ticket: No se pudo clonar el ticket
+ Set weight: Establecer peso
+ Weight set: Peso establecido
+ This ticket may be invoiced, do you want to continue?: Es posible que se facture este ticket, desea continuar?
+ invoiceIds: "Se han generado las facturas con los siguientes ids: {invoiceIds}"
diff --git a/src/pages/Ticket/Card/TicketSummary.vue b/src/pages/Ticket/Card/TicketSummary.vue
index 3851bf5d6..d19c1be49 100644
--- a/src/pages/Ticket/Card/TicketSummary.vue
+++ b/src/pages/Ticket/Card/TicketSummary.vue
@@ -31,8 +31,7 @@ const $props = defineProps({
const entityId = computed(() => $props.id || route.params.id);
const summaryRef = ref();
-const ticket = ref();
-const salesLines = ref(null);
+const ticket = computed(() => summaryRef.value?.entity);
const editableStates = ref([]);
const ticketUrl = ref();
const grafanaUrl = 'https://grafana.verdnatura.es';
@@ -40,12 +39,6 @@ const grafanaUrl = 'https://grafana.verdnatura.es';
onMounted(async () => {
ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/';
});
-async function setData(data) {
- if (data) {
- ticket.value = data;
- salesLines.value = data.sales;
- }
-}
function formattedAddress() {
if (!ticket.value) return '';
@@ -89,7 +82,6 @@ async function changeState(value) {
setData(data)"
data-key="TicketSummary"
>
@@ -131,7 +123,7 @@ async function changeState(value) {
-
+
-
- {{ ticket.ticketState?.state?.name }}
+
+ {{ entity.ticketState?.state?.name }}
-
+
- {{ ticket.ticketCollections[0]?.collectionFk }}
+ {{ entity.ticketCollections[0]?.collectionFk }}
-
+
-
- {{ dashIfEmpty(ticket.refFk) }}
+
+ {{ dashIfEmpty(entity.refFk) }}
@@ -199,35 +191,35 @@ async function changeState(value) {
/>
-
-
+
+
{{ t('ticket.summary.consigneePhone') }}
-
+
-
+
{{ t('ticket.summary.consigneeMobile') }}
-
+
-
+
{{ t('ticket.summary.clientPhone') }}
-
+
-
+
{{ t('ticket.summary.clientMobile') }}
-
+
-
+
@@ -279,7 +271,7 @@ async function changeState(value) {
:url="ticketUrl + 'sale'"
:text="t('ticket.summary.saleLines')"
/>
-
+
{{ value }}
@@ -423,10 +415,10 @@ async function changeState(value) {
-
+
{{ t('ticket.summary.created') }}
@@ -446,7 +438,7 @@ async function changeState(value) {
:url="ticketUrl + 'service'"
:text="t('ticket.summary.service')"
/>
-
+
{{ t('ticket.summary.quantity') }}
diff --git a/test/cypress/integration/ticket/ticketDescriptor.spec.js b/test/cypress/integration/ticket/ticketDescriptor.spec.js
index 9bd7c6053..516b0f13d 100644
--- a/test/cypress/integration/ticket/ticketDescriptor.spec.js
+++ b/test/cypress/integration/ticket/ticketDescriptor.spec.js
@@ -1,19 +1,18 @@
///
describe('Ticket descriptor', () => {
const toCloneOpt = '[role="menu"] .q-list > :nth-child(5)';
+ const setWeightOpt = '[role="menu"] .q-list > :nth-child(6)';
const warehouseValue = ':nth-child(1) > :nth-child(6) > .value > span';
const summaryHeader = '.summaryHeader > div';
-
+ const weight = 25;
+ const weightValue = ':nth-child(10) > .value > span';
beforeEach(() => {
- const ticketId = 1;
-
cy.login('developer');
- cy.visit(`/#/ticket/${ticketId}/summary`);
- cy.waitForElement('.q-page', 7000);
+ cy.viewport(1920, 1080);
});
it('should clone the ticket without warehouse', () => {
- cy.openLeftMenu();
+ cy.visit('/#/ticket/1/summary');
cy.openActionsDescriptor();
cy.get(toCloneOpt).click();
cy.clickConfirm();
@@ -25,4 +24,15 @@ describe('Ticket descriptor', () => {
cy.wrap(owner.trim()).should('eq', 'Bruce Wayne (1101)');
});
});
+
+ it('should set the weight of the ticket', () => {
+ cy.visit('/#/ticket/10/summary');
+ cy.openActionsDescriptor();
+ cy.get(setWeightOpt).click();
+ cy.intercept('POST', /\/api\/Tickets\/\d+\/setWeight/).as('weight');
+ cy.get('.q-dialog input').type(weight);
+ cy.clickConfirm();
+ cy.wait('@weight');
+ cy.get(weightValue).contains(weight);
+ });
});