Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test
This commit is contained in:
commit
d72e45918a
|
@ -77,7 +77,6 @@ onBeforeMount(() => {
|
|||
function setPaymentType(accounting) {
|
||||
if (!accounting) return;
|
||||
accountingType.value = accounting.accountingType;
|
||||
|
||||
initialData.description = [];
|
||||
initialData.payed = Date.vnNew();
|
||||
isCash.value = accountingType.value.code == 'cash';
|
||||
|
@ -87,14 +86,14 @@ function setPaymentType(accounting) {
|
|||
initialData.payed.getDate() + accountingType.value.daysInFuture,
|
||||
);
|
||||
maxAmount.value = accountingType.value && accountingType.value.maxAmount;
|
||||
|
||||
if (accountingType.value.code == 'compensation')
|
||||
return (initialData.description = '');
|
||||
if (accountingType.value.receiptDescription)
|
||||
initialData.description.push(accountingType.value.receiptDescription);
|
||||
if (initialData.description) initialData.description.push(initialData.description);
|
||||
|
||||
initialData.description = initialData.description.join(', ');
|
||||
let descriptions = [];
|
||||
if (accountingType.value.receiptDescription)
|
||||
descriptions.push(accountingType.value.receiptDescription);
|
||||
if (initialData.description) descriptions.push(initialData.description);
|
||||
initialData.description = descriptions.join(', ');
|
||||
}
|
||||
|
||||
const calculateFromAmount = (event) => {
|
||||
|
|
|
@ -1,32 +1,26 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { toCurrency } from 'src/filters';
|
||||
import VnUsesMana from 'components/ui/VnUsesMana.vue';
|
||||
|
||||
const $props = defineProps({
|
||||
mana: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
newPrice: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
usesMana: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
manaCode: {
|
||||
type: String,
|
||||
default: 'mana',
|
||||
},
|
||||
sale: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const mana = ref(null);
|
||||
const usesMana = ref(false);
|
||||
|
||||
const emit = defineEmits(['save', 'cancel']);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -38,36 +32,47 @@ const save = (sale = $props.sale) => {
|
|||
QPopupProxyRef.value.hide();
|
||||
};
|
||||
|
||||
const getMana = async () => {
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/getSalesPersonMana`);
|
||||
mana.value = data;
|
||||
await getUsesMana();
|
||||
};
|
||||
|
||||
const getUsesMana = async () => {
|
||||
const { data } = await axios.get('Sales/usesMana');
|
||||
usesMana.value = data;
|
||||
};
|
||||
|
||||
const cancel = () => {
|
||||
emit('cancel');
|
||||
QPopupProxyRef.value.hide();
|
||||
};
|
||||
const hasMana = computed(() => typeof mana.value === 'number');
|
||||
defineExpose({ save });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QPopupProxy ref="QPopupProxyRef" data-cy="ticketEditManaProxy">
|
||||
<QPopupProxy
|
||||
ref="QPopupProxyRef"
|
||||
@before-show="getMana"
|
||||
data-cy="ticketEditManaProxy"
|
||||
>
|
||||
<div class="container">
|
||||
<QSpinner
|
||||
v-if="!(typeof mana === 'number' && mana >= 0)"
|
||||
color="primary"
|
||||
size="md"
|
||||
/>
|
||||
<div v-else>
|
||||
<div class="header">Mana: {{ toCurrency(mana) }}</div>
|
||||
<div class="q-pa-md">
|
||||
<slot :popup="QPopupProxyRef" />
|
||||
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
|
||||
<VnUsesMana :mana-code="manaCode" />
|
||||
</div>
|
||||
<div v-if="newPrice" class="column items-center q-mt-lg">
|
||||
<span class="text-primary">{{ t('New price') }}</span>
|
||||
<span class="text-subtitle1">
|
||||
{{ toCurrency($props.newPrice) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="header">Mana: {{ toCurrency(mana) }}</div>
|
||||
<QSpinner v-if="!hasMana" color="primary" size="md" />
|
||||
<div class="q-pa-md" v-else>
|
||||
<slot :popup="QPopupProxyRef" />
|
||||
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
|
||||
<VnUsesMana :mana-code="manaCode" />
|
||||
</div>
|
||||
<div v-if="newPrice" class="column items-center q-mt-lg">
|
||||
<span class="text-primary">{{ t('New price') }}</span>
|
||||
<span class="text-subtitle1">
|
||||
{{ toCurrency($props.newPrice) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<QBtn
|
||||
color="primary"
|
||||
|
|
|
@ -45,7 +45,6 @@ const isTicketEditable = ref(false);
|
|||
const sales = ref([]);
|
||||
const editableStatesOptions = ref([]);
|
||||
const selectedSales = ref([]);
|
||||
const mana = ref(null);
|
||||
const manaCode = ref('mana');
|
||||
const ticketState = computed(() => store.data?.ticketState?.state?.code);
|
||||
const transfer = ref({
|
||||
|
@ -259,18 +258,6 @@ const DEFAULT_EDIT = {
|
|||
oldQuantity: null,
|
||||
};
|
||||
const edit = ref({ ...DEFAULT_EDIT });
|
||||
const usesMana = ref(null);
|
||||
|
||||
const getUsesMana = async () => {
|
||||
const { data } = await axios.get('Sales/usesMana');
|
||||
usesMana.value = data;
|
||||
};
|
||||
|
||||
const getMana = async () => {
|
||||
const { data } = await axios.get(`Tickets/${route.params.id}/getSalesPersonMana`);
|
||||
mana.value = data;
|
||||
await getUsesMana();
|
||||
};
|
||||
|
||||
const selectedValidSales = computed(() => {
|
||||
if (!sales.value) return;
|
||||
|
@ -278,7 +265,6 @@ const selectedValidSales = computed(() => {
|
|||
});
|
||||
|
||||
const onOpenEditPricePopover = async (sale) => {
|
||||
await getMana();
|
||||
edit.value = {
|
||||
sale: JSON.parse(JSON.stringify(sale)),
|
||||
price: sale.price,
|
||||
|
@ -286,7 +272,6 @@ const onOpenEditPricePopover = async (sale) => {
|
|||
};
|
||||
|
||||
const onOpenEditDiscountPopover = async (sale) => {
|
||||
await getMana();
|
||||
if (isLocked.value) return;
|
||||
if (sale) {
|
||||
edit.value = {
|
||||
|
@ -307,7 +292,6 @@ const changePrice = async (sale) => {
|
|||
await confirmUpdate(() => updatePrice(sale, newPrice));
|
||||
} else updatePrice(sale, newPrice);
|
||||
}
|
||||
await getMana();
|
||||
};
|
||||
const updatePrice = async (sale, newPrice) => {
|
||||
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
|
||||
|
@ -600,9 +584,7 @@ watch(
|
|||
:is-ticket-editable="isTicketEditable"
|
||||
:sales="selectedValidSales"
|
||||
:disable="!hasSelectedRows"
|
||||
:mana="mana"
|
||||
:ticket-config="ticketConfig"
|
||||
@get-mana="getMana()"
|
||||
@update-discounts="updateDiscounts"
|
||||
@refresh-table="resetChanges"
|
||||
/>
|
||||
|
@ -785,7 +767,6 @@ watch(
|
|||
</QBtn>
|
||||
<TicketEditManaProxy
|
||||
ref="editPriceProxyRef"
|
||||
:mana="mana"
|
||||
:sale="row"
|
||||
:new-price="getNewPrice"
|
||||
@save="changePrice"
|
||||
|
@ -808,10 +789,8 @@ watch(
|
|||
|
||||
<TicketEditManaProxy
|
||||
ref="editManaProxyRef"
|
||||
:mana="mana"
|
||||
:sale="row"
|
||||
:new-price="getNewPrice"
|
||||
:uses-mana="usesMana"
|
||||
:mana-code="manaCode"
|
||||
@save="changeDiscount"
|
||||
>
|
||||
|
|
|
@ -34,10 +34,6 @@ const props = defineProps({
|
|||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
mana: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
ticketConfig: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
|
@ -220,7 +216,6 @@ const createRefund = async (withWarehouse) => {
|
|||
<TicketEditManaProxy
|
||||
ref="editManaProxyRef"
|
||||
:sale="row"
|
||||
:mana="props.mana"
|
||||
@save="changeMultipleDiscount"
|
||||
>
|
||||
<VnInput
|
||||
|
|
Loading…
Reference in New Issue