8627-devToTest #1421
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, onBeforeMount } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -12,6 +12,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||||
|
import { toCurrency } from 'filters/index';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
@ -26,7 +27,7 @@ const invoiceInFormRef = ref();
|
||||||
const invoiceId = +route.params.id;
|
const invoiceId = +route.params.id;
|
||||||
const filter = { where: { invoiceInFk: invoiceId } };
|
const filter = { where: { invoiceInFk: invoiceId } };
|
||||||
const areRows = ref(false);
|
const areRows = ref(false);
|
||||||
|
const totals = ref();
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
name: 'duedate',
|
name: 'duedate',
|
||||||
|
@ -66,6 +67,8 @@ const columns = computed(() => [
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const totalAmount = computed(() => getTotal(invoiceInFormRef.value.formData, 'amount'));
|
||||||
|
|
||||||
const isNotEuro = (code) => code != 'EUR';
|
const isNotEuro = (code) => code != 'EUR';
|
||||||
|
|
||||||
async function insert() {
|
async function insert() {
|
||||||
|
@ -73,6 +76,10 @@ async function insert() {
|
||||||
await invoiceInFormRef.value.reload();
|
await invoiceInFormRef.value.reload();
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onBeforeMount(async () => {
|
||||||
|
totals.value = (await axios.get(`InvoiceIns/${invoiceId}/getTotals`)).data;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -153,7 +160,7 @@ async function insert() {
|
||||||
<QTd />
|
<QTd />
|
||||||
<QTd />
|
<QTd />
|
||||||
<QTd>
|
<QTd>
|
||||||
{{ getTotal(rows, 'amount', { currency: 'default' }) }}
|
{{ toCurrency(totalAmount) }}
|
||||||
</QTd>
|
</QTd>
|
||||||
<QTd>
|
<QTd>
|
||||||
<template v-if="isNotEuro(invoiceIn.currency.code)">
|
<template v-if="isNotEuro(invoiceIn.currency.code)">
|
||||||
|
@ -235,7 +242,16 @@ async function insert() {
|
||||||
shortcut="+"
|
shortcut="+"
|
||||||
size="lg"
|
size="lg"
|
||||||
round
|
round
|
||||||
@click="!areRows ? insert() : invoiceInFormRef.insert()"
|
@click="
|
||||||
|
() => {
|
||||||
|
if (!areRows) insert();
|
||||||
|
else
|
||||||
|
invoiceInFormRef.insert({
|
||||||
|
amount: (totals.totalTaxableBase - totalAmount).toFixed(2),
|
||||||
|
invoiceInFk: invoiceId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
</QPageSticky>
|
</QPageSticky>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue