#6696 - mana #1052
|
@ -89,7 +89,7 @@ devDependencies:
|
||||||
specifier: ^9.32.0
|
specifier: ^9.32.0
|
||||||
version: 9.32.0(eslint@9.20.1)
|
version: 9.32.0(eslint@9.20.1)
|
||||||
husky:
|
husky:
|
||||||
specifier: ^8.0.0
|
specifier: ^8.0.3
|
||||||
version: 8.0.3
|
version: 8.0.3
|
||||||
junit-merge:
|
junit-merge:
|
||||||
specifier: ^2.0.0
|
specifier: ^2.0.0
|
||||||
|
@ -4294,6 +4294,11 @@ packages:
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/escalade@3.2.0:
|
||||||
|
resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}
|
||||||
|
engines: {node: '>=6'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/escape-goat@4.0.0:
|
/escape-goat@4.0.0:
|
||||||
resolution: {integrity: sha512-2Sd4ShcWxbx6OY1IHyla/CVNwvg7XwZVoXZHcSu9w9SReNP1EzzD5T8NWKIR38fIqEns9kDWKUQTXXAmlDrdPg==}
|
resolution: {integrity: sha512-2Sd4ShcWxbx6OY1IHyla/CVNwvg7XwZVoXZHcSu9w9SReNP1EzzD5T8NWKIR38fIqEns9kDWKUQTXXAmlDrdPg==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
@ -6535,6 +6540,10 @@ packages:
|
||||||
/picocolors@1.1.1:
|
/picocolors@1.1.1:
|
||||||
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||||
|
|
||||||
|
/picocolors@1.1.1:
|
||||||
|
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/picomatch@2.3.1:
|
/picomatch@2.3.1:
|
||||||
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
|
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
|
||||||
engines: {node: '>=8.6'}
|
engines: {node: '>=8.6'}
|
||||||
|
@ -6602,6 +6611,15 @@ packages:
|
||||||
resolution: {integrity: sha512-0gNmv4qpS9HaN3+40CLBAnKe0ZfyE4ZWo5xKlC1rVrr0ckkEvJvAQqKaHANdFKsGstoxrY4AItZ7kZSGVoVjgg==}
|
resolution: {integrity: sha512-0gNmv4qpS9HaN3+40CLBAnKe0ZfyE4ZWo5xKlC1rVrr0ckkEvJvAQqKaHANdFKsGstoxrY4AItZ7kZSGVoVjgg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/postcss@8.4.49:
|
||||||
|
resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==}
|
||||||
|
engines: {node: ^10 || ^12 || >=14}
|
||||||
|
dependencies:
|
||||||
|
nanoid: 3.3.7
|
||||||
|
picocolors: 1.1.1
|
||||||
|
source-map-js: 1.2.1
|
||||||
|
dev: true
|
||||||
|
|
||||||
/prelude-ls@1.2.1:
|
/prelude-ls@1.2.1:
|
||||||
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
|
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
|
@ -7969,6 +7987,10 @@ packages:
|
||||||
/undici-types@6.20.0:
|
/undici-types@6.20.0:
|
||||||
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
|
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
|
||||||
|
|
||||||
|
/undici-types@6.19.8:
|
||||||
|
resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/unicorn-magic@0.1.0:
|
/unicorn-magic@0.1.0:
|
||||||
resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==}
|
resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const props = defineProps({
|
|
||||||
usesMana: {
|
|
||||||
type: Boolean,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
manaCode: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
manaVal: {
|
|
||||||
type: String,
|
|
||||||
default: 'mana',
|
|
||||||
},
|
|
||||||
manaLabel: {
|
|
||||||
type: String,
|
|
||||||
default: 'Promotion mana',
|
|
||||||
},
|
|
||||||
manaClaimVal: {
|
|
||||||
type: String,
|
|
||||||
default: 'manaClaim',
|
|
||||||
},
|
|
||||||
claimLabel: {
|
|
||||||
type: String,
|
|
||||||
default: 'Claim mana',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const manaCode = ref(props.manaCode);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="column q-gutter-y-sm q-mt-sm">
|
|
||||||
<QRadio
|
|
||||||
v-model="manaCode"
|
|
||||||
dense
|
|
||||||
:val="manaVal"
|
|
||||||
:label="t(manaLabel)"
|
|
||||||
:dark="true"
|
|
||||||
class="q-mb-sm"
|
|
||||||
/>
|
|
||||||
<QRadio
|
|
||||||
v-model="manaCode"
|
|
||||||
dense
|
|
||||||
:val="manaClaimVal"
|
|
||||||
:label="t(claimLabel)"
|
|
||||||
:dark="true"
|
|
||||||
class="q-mb-sm"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<i18n>
|
|
||||||
es:
|
|
||||||
Promotion mana: Maná promoción
|
|
||||||
Claim mana: Maná reclamación
|
|
||||||
</i18n>
|
|
|
@ -123,8 +123,8 @@ async function fetchMana() {
|
||||||
|
|
||||||
async function updateDiscount({ saleFk, discount, canceller }) {
|
async function updateDiscount({ saleFk, discount, canceller }) {
|
||||||
const body = { salesIds: [saleFk], newDiscount: discount };
|
const body = { salesIds: [saleFk], newDiscount: discount };
|
||||||
const claimId = claim.value.ticketFk;
|
const ticketFk = claim.value.ticketFk;
|
||||||
const query = `Tickets/${claimId}/updateDiscount`;
|
const query = `Tickets/${ticketFk}/updateDiscount`;
|
||||||
|
|
||||||
await axios.post(query, body, {
|
await axios.post(query, body, {
|
||||||
signal: canceller.signal,
|
signal: canceller.signal,
|
||||||
|
|
|
@ -4,8 +4,10 @@ import { useI18n } from 'vue-i18n';
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { toCurrency } from 'src/filters';
|
import { toCurrency } from 'src/filters';
|
||||||
import VnUsesMana from 'components/ui/VnUsesMana.vue';
|
import axios from 'axios';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
newPrice: {
|
newPrice: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
@ -17,15 +19,10 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const emit = defineEmits(['save', 'cancel', 'show']);
|
||||||
const mana = ref(null);
|
|
||||||
const usesMana = ref(false);
|
|
||||||
|
|
||||||
const emit = defineEmits(['save', 'cancel']);
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const QPopupProxyRef = ref(null);
|
const QPopupProxyRef = ref(null);
|
||||||
const manaCode = ref($props.manaCode);
|
const componentName = ref('mana');
|
||||||
|
|
||||||
const save = (sale = $props.sale) => {
|
const save = (sale = $props.sale) => {
|
||||||
emit('save', sale);
|
emit('save', sale);
|
||||||
|
@ -71,6 +68,27 @@ defineExpose({ save });
|
||||||
{{ toCurrency($props.newPrice) }}
|
{{ toCurrency($props.newPrice) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<QBtn
|
||||||
|
color="primary"
|
||||||
|
class="no-border-radius"
|
||||||
|
dense
|
||||||
|
style="width: 50%"
|
||||||
|
@click="cancel()"
|
||||||
|
>
|
||||||
|
{{ t('globals.cancel') }}
|
||||||
|
</QBtn>
|
||||||
|
<QBtn
|
||||||
|
color="primary"
|
||||||
|
class="no-border-radius"
|
||||||
|
dense
|
||||||
|
style="width: 50%"
|
||||||
|
data-cy="saveManaBtn"
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
|
{{ t('globals.save') }}
|
||||||
|
</QBtn>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -99,11 +117,6 @@ defineExpose({ save });
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.container {
|
|
||||||
background-color: $dark;
|
|
||||||
width: 230px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
height: 54px;
|
height: 54px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -120,4 +133,5 @@ defineExpose({ save });
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
New price: Nuevo precio
|
New price: Nuevo precio
|
||||||
|
Claim: Reclamación
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -3,19 +3,17 @@ import { onMounted, ref, computed, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter, useRoute } from 'vue-router';
|
import { useRouter, useRoute } from 'vue-router';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import FetchedTags from 'components/ui/FetchedTags.vue';
|
import FetchedTags from 'components/ui/FetchedTags.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
||||||
import TicketEditManaProxy from './TicketEditMana.vue';
|
import TicketEditMana from './TicketEditMana.vue';
|
||||||
import VnImg from 'src/components/ui/VnImg.vue';
|
import VnImg from 'src/components/ui/VnImg.vue';
|
||||||
|
|
||||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||||
import TicketSaleMoreActions from './TicketSaleMoreActions.vue';
|
import TicketSaleMoreActions from './TicketSaleMoreActions.vue';
|
||||||
import TicketTransferProxy from './TicketTransferProxy.vue';
|
import TicketTransferProxy from './TicketTransferProxy.vue';
|
||||||
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { toCurrency, toPercentage } from 'src/filters';
|
import { toCurrency, toPercentage } from 'src/filters';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
|
@ -134,7 +132,7 @@ const columns = computed(() => [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
label: t('ticketSale.packaging'),
|
label: t('ticketSale.pack'),
|
||||||
name: 'itemPackingTypeFk',
|
name: 'itemPackingTypeFk',
|
||||||
format: (row, dashIfEmpty) => dashIfEmpty(row?.item?.itemPackingTypeFk),
|
format: (row, dashIfEmpty) => dashIfEmpty(row?.item?.itemPackingTypeFk),
|
||||||
},
|
},
|
||||||
|
@ -151,7 +149,6 @@ const columns = computed(() => [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const getConfig = async () => {
|
const getConfig = async () => {
|
||||||
let filter = {
|
let filter = {
|
||||||
fields: ['daysForWarningClaim'],
|
fields: ['daysForWarningClaim'],
|
||||||
|
@ -287,21 +284,16 @@ const onOpenEditPricePopover = async (sale) => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOpenEditDiscountPopover = async (sale) => {
|
const onDiscountClick = async (sale) => {
|
||||||
if (isLocked.value) return;
|
if (isLocked.value) return;
|
||||||
if (sale) {
|
if (sale) {
|
||||||
edit.value = {
|
edit.value = {
|
||||||
sale: JSON.parse(JSON.stringify(sale)),
|
sale: JSON.parse(JSON.stringify(sale)),
|
||||||
discount: sale.discount,
|
discount: sale.discount,
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
edit.value = {
|
|
||||||
discount: null,
|
|
||||||
sales: selectedValidSales.value,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const changePrice = async (sale) => {
|
const changePrice = async (sale, componentName) => {
|
||||||
const newPrice = edit.value.price;
|
const newPrice = edit.value.price;
|
||||||
if (newPrice != null && newPrice != sale.price) {
|
if (newPrice != null && newPrice != sale.price) {
|
||||||
if (await isSalePrepared(sale)) {
|
if (await isSalePrepared(sale)) {
|
||||||
|
@ -317,35 +309,19 @@ const updatePrice = async (sale, newPrice) => {
|
||||||
resetChanges();
|
resetChanges();
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeDiscount = async (sale) => {
|
const updateDiscount = async (sales, componentName, newDiscount) => {
|
||||||
const newDiscount = edit.value.discount;
|
const hasChanges = sales.some((sale) => sale.discount != newDiscount);
|
||||||
if (newDiscount != null && newDiscount != sale.discount) {
|
if (!hasChanges || newDiscount == null || newDiscount === '') return;
|
||||||
if (await isSalePrepared(sale))
|
const canProceed = await Promise.all(sales.map((sale) => isSalePrepared(sale)));
|
||||||
await confirmUpdate(() => updateDiscount([sale], newDiscount));
|
if (canProceed.includes(false)) return;
|
||||||
else await updateDiscount([sale], newDiscount);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateDiscounts = async (sales, newDiscount) => {
|
const saleIds = sales.map((sale) => sale.id);
|
||||||
const salesTracking = await fetchSalesTracking();
|
const params = { salesIds: saleIds, newDiscount, componentName };
|
||||||
|
|
||||||
const someSaleIsPrepared = salesTracking.some((sale) =>
|
|
||||||
matchSale(salesTracking, sale),
|
|
||||||
);
|
|
||||||
if (someSaleIsPrepared) await confirmUpdate(() => updateDiscount(sales, newDiscount));
|
|
||||||
else updateDiscount(sales, newDiscount);
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateDiscount = async (sales, newDiscount = 0) => {
|
|
||||||
const salesIds = sales.map(({ id }) => id);
|
|
||||||
const params = {
|
|
||||||
salesIds,
|
|
||||||
newDiscount,
|
|
||||||
manaCode: manaCode.value,
|
|
||||||
};
|
|
||||||
await axios.post(`Tickets/${route.params.id}/updateDiscount`, params);
|
await axios.post(`Tickets/${route.params.id}/updateDiscount`, params);
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
resetChanges();
|
for (let sale of sales) sale.discount = params.newDiscount;
|
||||||
|
edit.value = { ...DEFAULT_EDIT };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getNewPrice = computed(() => {
|
const getNewPrice = computed(() => {
|
||||||
|
@ -392,7 +368,6 @@ const changeTicketState = async (val) => {
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
await resetChanges();
|
await resetChanges();
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeSelectedSales = () => {
|
const removeSelectedSales = () => {
|
||||||
selectedRows.value.forEach((sale) => {
|
selectedRows.value.forEach((sale) => {
|
||||||
const index = sales.value.indexOf(sale);
|
const index = sales.value.indexOf(sale);
|
||||||
|
@ -600,7 +575,7 @@ watch(
|
||||||
:sales="selectedValidSales"
|
:sales="selectedValidSales"
|
||||||
:disable="!hasSelectedRows"
|
:disable="!hasSelectedRows"
|
||||||
:ticket-config="ticketConfig"
|
:ticket-config="ticketConfig"
|
||||||
@update-discounts="updateDiscounts"
|
@update-discounts="updateDiscount"
|
||||||
@refresh-table="resetChanges"
|
@refresh-table="resetChanges"
|
||||||
/>
|
/>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -789,28 +764,26 @@ watch(
|
||||||
</template>
|
</template>
|
||||||
<template #column-price="{ row }">
|
<template #column-price="{ row }">
|
||||||
<template v-if="isTicketEditable && row.id">
|
<template v-if="isTicketEditable && row.id">
|
||||||
<QBtn flat class="link" dense @click="onOpenEditPricePopover(row)">
|
<QBtn flat class="link" dense>
|
||||||
{{ toCurrency(row.price) }}
|
{{ toCurrency(row.price) }}
|
||||||
|
<TicketEditMana
|
||||||
|
:new-price="getNewPrice"
|
||||||
|
@show="onOpenEditPricePopover(row)"
|
||||||
|
@save="(componentName) => updatePrice(row, componentName)"
|
||||||
|
>
|
||||||
|
<VnInput
|
||||||
|
v-model.number="edit.price"
|
||||||
|
:label="t('basicData.price')"
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
</TicketEditMana>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<TicketEditManaProxy
|
|
||||||
ref="editPriceProxyRef"
|
|
||||||
:sale="row"
|
|
||||||
:new-price="getNewPrice"
|
|
||||||
@save="changePrice"
|
|
||||||
>
|
|
||||||
<VnInput
|
|
||||||
@keyup.enter.stop="() => editManaProxyRef.save(row)"
|
|
||||||
v-model.number="edit.price"
|
|
||||||
:label="t('basicData.price')"
|
|
||||||
type="number"
|
|
||||||
/>
|
|
||||||
</TicketEditManaProxy>
|
|
||||||
</template>
|
</template>
|
||||||
<span v-else>{{ toCurrency(row.price) }}</span>
|
<span v-else>{{ toCurrency(row.price) }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #column-discount="{ row }">
|
<template #column-discount="{ row }">
|
||||||
<template v-if="!isLocked && row.id">
|
<template v-if="!isLocked && row.id">
|
||||||
<QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)">
|
<QBtn flat class="link" dense>
|
||||||
{{ toPercentage(row.discount / 100) }}
|
{{ toPercentage(row.discount / 100) }}
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { useQuasar } from 'quasar';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import VnSmsDialog from 'components/common/VnSmsDialog.vue';
|
import VnSmsDialog from 'components/common/VnSmsDialog.vue';
|
||||||
import TicketEditManaProxy from './TicketEditMana.vue';
|
import TicketEditMana from './TicketEditMana.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
@ -14,7 +14,7 @@ import { toDateFormat } from 'src/filters/date';
|
||||||
import { useAcl } from 'src/composables/useAcl';
|
import { useAcl } from 'src/composables/useAcl';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
|
|
||||||
const emit = defineEmits(['updateDiscounts', 'getMana', 'refreshTable']);
|
const emit = defineEmits(['updateDiscounts', 'refreshTable']);
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
disable: {
|
disable: {
|
||||||
|
@ -28,7 +28,6 @@ const props = defineProps({
|
||||||
ticket: {
|
ticket: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
default: () => {},
|
|
||||||
},
|
},
|
||||||
sales: {
|
sales: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
@ -107,13 +106,9 @@ const calculateSalePrice = async () => {
|
||||||
emit('refreshTable', props.sales);
|
emit('refreshTable', props.sales);
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeMultipleDiscount = () => {
|
const changeMultipleDiscount = (componentName, newDiscount) => {
|
||||||
const hasChanges = props.sales.some((sale) => {
|
if (newDiscount != null)
|
||||||
return sale.discount != newDiscount.value;
|
emit('updateDiscounts', props.sales, componentName, newDiscount);
|
||||||
});
|
|
||||||
|
|
||||||
if (newDiscount.value != null && hasChanges)
|
|
||||||
emit('updateDiscounts', props.sales, newDiscount.value);
|
|
||||||
btnDropdownRef.value.hide();
|
btnDropdownRef.value.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -194,19 +189,15 @@ const createRefund = async (withWarehouse) => {
|
||||||
<QItemLabel>{{ t('Recalculate price') }}</QItemLabel>
|
<QItemLabel>{{ t('Recalculate price') }}</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem
|
<QItem clickable v-ripple data-cy="updateDiscountItem">
|
||||||
clickable
|
|
||||||
v-ripple
|
|
||||||
@click="emit('getMana')"
|
|
||||||
data-cy="updateDiscountItem"
|
|
||||||
>
|
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<QItemLabel>{{ t('Update discount') }}</QItemLabel>
|
<QItemLabel>{{ t('Update discount') }}</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<TicketEditManaProxy
|
<TicketEditMana
|
||||||
ref="editManaProxyRef"
|
@save="
|
||||||
:sale="row"
|
(componentName) =>
|
||||||
@save="changeMultipleDiscount"
|
changeMultipleDiscount(componentName, newDiscount)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<VnInput
|
<VnInput
|
||||||
autofocus
|
autofocus
|
||||||
|
@ -216,7 +207,7 @@ const createRefund = async (withWarehouse) => {
|
||||||
type="number"
|
type="number"
|
||||||
data-cy="ticketSaleDiscountInput"
|
data-cy="ticketSaleDiscountInput"
|
||||||
/>
|
/>
|
||||||
</TicketEditManaProxy>
|
</TicketEditMana>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem
|
<QItem
|
||||||
v-if="isClaimable"
|
v-if="isClaimable"
|
||||||
|
|
|
@ -15,6 +15,7 @@ ticketSale:
|
||||||
available: Available
|
available: Available
|
||||||
discount: Disc
|
discount: Disc
|
||||||
packaging: Packaging
|
packaging: Packaging
|
||||||
|
pack: Pack.
|
||||||
subtotal: Subtotal
|
subtotal: Subtotal
|
||||||
tax: VAT
|
tax: VAT
|
||||||
history: History
|
history: History
|
||||||
|
|
|
@ -116,6 +116,7 @@ ticketSale:
|
||||||
available: Disponible
|
available: Disponible
|
||||||
discount: Dto
|
discount: Dto
|
||||||
packaging: Encajado
|
packaging: Encajado
|
||||||
|
pack: Enc.
|
||||||
subtotal: Subtotal
|
subtotal: Subtotal
|
||||||
tax: IVA
|
tax: IVA
|
||||||
history: Historial
|
history: Historial
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
import { vi, describe, it, beforeEach, afterEach, expect } from 'vitest';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
|
import TicketSale from 'pages/Ticket/Card/TicketSale.vue';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
describe('TicketSale ', () => {
|
||||||
|
let wrapper;
|
||||||
|
let vm;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.spyOn(axios, 'post').mockResolvedValue({});
|
||||||
|
vi.spyOn(axios, 'get').mockImplementation(() => ({
|
||||||
|
data: [
|
||||||
|
{ id: 1, discount: 5 },
|
||||||
|
{ id: 2, discount: 7 },
|
||||||
|
],
|
||||||
|
}));
|
||||||
|
wrapper = createWrapper(TicketSale, {
|
||||||
|
props: {
|
||||||
|
ticket: { id: 123, name: 'Sample Ticket' },
|
||||||
|
isTicketEditable: true,
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
mocks: {
|
||||||
|
store: {
|
||||||
|
data: { id: 123, name: 'Sample Ticket' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// wrapper.vm.route = { params: { id: 123 } };
|
||||||
|
vm = wrapper.vm;
|
||||||
|
vi.spyOn(vm, 'isSalePrepared').mockResolvedValue(true);
|
||||||
|
vm.edit = { discount: 10 }; // Set the discount in the edit state
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update discounts for sales when changes exist', async () => {
|
||||||
|
const sales = [
|
||||||
|
{ id: 1, discount: 5 },
|
||||||
|
{ id: 2, discount: 7 },
|
||||||
|
];
|
||||||
|
|
||||||
|
const newDiscount = 10;
|
||||||
|
const componentName = 'TicketSale';
|
||||||
|
|
||||||
|
await vm.updateDiscount(sales, componentName, newDiscount);
|
||||||
|
|
||||||
|
expect(sales[0].discount).toBe(newDiscount);
|
||||||
|
expect(sales[1].discount).toBe(newDiscount);
|
||||||
|
expect(vm.edit).toEqual({
|
||||||
|
price: null,
|
||||||
|
discount: null,
|
||||||
|
sale: null,
|
||||||
|
sales: null,
|
||||||
|
oldQuantity: null,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it.only('should not update discounts if there are no changes', async () => {
|
||||||
|
const newDiscount = 10;
|
||||||
|
const sales = [
|
||||||
|
{ id: 1, itemFk: 123, discount: 10 },
|
||||||
|
{ id: 2, itemFk: 456, discount: 10 },
|
||||||
|
];
|
||||||
|
const componentName = 'TicketSale';
|
||||||
|
|
||||||
|
await vm.updateDiscount(sales, componentName, newDiscount);
|
||||||
|
|
||||||
|
expect(axios.post).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not update discounts if there is no discount', async () => {
|
||||||
|
const sales = [{ id: 1, discount: 10 }];
|
||||||
|
const componentName = 'TicketSale';
|
||||||
|
|
||||||
|
await vm.updateDiscount(sales, componentName, null);
|
||||||
|
|
||||||
|
expect(axios.post).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not update discounts if any sale is not prepared', async () => {
|
||||||
|
vi.spyOn(vm, 'isSalePrepared').mockImplementation((sale) =>
|
||||||
|
Promise.resolve(sale.id !== 1)
|
||||||
|
);
|
||||||
|
const sales = [
|
||||||
|
{ id: 1, discount: 5 },
|
||||||
|
{ id: 2, discount: 7 },
|
||||||
|
];
|
||||||
|
const componentName = 'TicketSale';
|
||||||
|
|
||||||
|
await vm.updateDiscount(sales, componentName);
|
||||||
|
|
||||||
|
expect(axios.post).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
|
@ -97,7 +97,7 @@ export function createWrapper(component, options) {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const mountOptions = Object.assign({}, defaultOptions);
|
const mountOptions = { ...defaultOptions };
|
||||||
|
|
||||||
if (options instanceof Object) {
|
if (options instanceof Object) {
|
||||||
Object.assign(mountOptions, options);
|
Object.assign(mountOptions, options);
|
||||||
|
|
Loading…
Reference in New Issue