This commit is contained in:
parent
473d4b1239
commit
cfda06380a
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, onMounted } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { toDate, toCurrency } from 'src/filters';
|
import { toDate, toCurrency } from 'src/filters';
|
||||||
|
@ -48,24 +48,31 @@ const claimDmsFilter = ref({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
function onFetch(rows, newRows) {
|
async function totalClaim(rows, newRows) {
|
||||||
console.log('rows: ', rows);
|
|
||||||
console.log('newRows: ', newRows);
|
|
||||||
if (newRows) rows = newRows;
|
if (newRows) rows = newRows;
|
||||||
amount.value = 0;
|
const { data } = await axios.get(`Claims/${entityId.value}/getSummary`);
|
||||||
console.log('amount.value: ', amount.value);
|
|
||||||
amountClaimed.value = 0;
|
|
||||||
console.log('amountClaimed.value: ', amountClaimed.value);
|
|
||||||
if (!rows || !rows.length) return;
|
|
||||||
|
|
||||||
for (const row of rows) {
|
const lines = data.salesClaimed;
|
||||||
const { sale } = row;
|
|
||||||
|
totalRow(lines);
|
||||||
|
amount.value = 0;
|
||||||
|
amountClaimed.value = 0;
|
||||||
|
for (const line of lines) {
|
||||||
|
const { sale } = line;
|
||||||
|
console.log('sale: ', sale);
|
||||||
amount.value = amount.value + totalRow(sale);
|
amount.value = amount.value + totalRow(sale);
|
||||||
const price = row.quantity * sale.price;
|
console.log('amount: ', amount.value);
|
||||||
|
const price = line.quantity * sale.price;
|
||||||
const discount = (sale.discount * price) / 100;
|
const discount = (sale.discount * price) / 100;
|
||||||
amountClaimed.value = amountClaimed.value + (price - discount);
|
amountClaimed.value = amountClaimed.value + (price - discount);
|
||||||
|
console.log('amountClaimed: ', amountClaimed.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function totalRow(lines) {
|
||||||
|
const amount = lines.price * lines.quantity;
|
||||||
|
const appliedDiscount = (lines.discount * amount) / 100;
|
||||||
|
return amount - appliedDiscount;
|
||||||
|
}
|
||||||
const detailsColumns = ref([
|
const detailsColumns = ref([
|
||||||
{
|
{
|
||||||
name: 'item',
|
name: 'item',
|
||||||
|
@ -118,11 +125,7 @@ const detailsColumns = ref([
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
function totalRow({ price, quantity, discount }) {
|
|
||||||
const amount = price * quantity;
|
|
||||||
const appliedDiscount = (discount * amount) / 100;
|
|
||||||
return amount - appliedDiscount;
|
|
||||||
}
|
|
||||||
const markerLabels = [
|
const markerLabels = [
|
||||||
{ value: 1, label: t('claim.company') },
|
{ value: 1, label: t('claim.company') },
|
||||||
{ value: 5, label: t('claim.person') },
|
{ value: 5, label: t('claim.person') },
|
||||||
|
@ -201,6 +204,10 @@ async function changeState(value) {
|
||||||
function claimUrl(section) {
|
function claimUrl(section) {
|
||||||
return '#/claim/' + entityId.value + '/' + section;
|
return '#/claim/' + entityId.value + '/' + section;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
totalClaim();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -255,7 +262,7 @@ function claimUrl(section) {
|
||||||
<ClaimDescriptorMenu :claim="entity.claim" />
|
<ClaimDescriptorMenu :claim="entity.claim" />
|
||||||
</template>
|
</template>
|
||||||
<template #body="{ entity: { claim, salesClaimed, developments } }">
|
<template #body="{ entity: { claim, salesClaimed, developments } }">
|
||||||
<QCard class="vn-one" v-if="$route.name != 'ClaimSummary'">
|
<QCard class="vn-two" v-if="$route.name != 'ClaimSummary'">
|
||||||
<VnTitle
|
<VnTitle
|
||||||
:url="claimUrl('basic-data')"
|
:url="claimUrl('basic-data')"
|
||||||
:text="t('globals.pageTitles.basicData')"
|
:text="t('globals.pageTitles.basicData')"
|
||||||
|
@ -306,7 +313,7 @@ function claimUrl(section) {
|
||||||
order="created ASC"
|
order="created ASC"
|
||||||
/>
|
/>
|
||||||
</QCard>
|
</QCard>
|
||||||
<QCard class="vn-two" v-if="claimDms?.length">
|
<QCard class="vn-one" v-if="claimDms?.length">
|
||||||
<VnTitle :url="claimUrl('photos')" :text="t('claim.photos')" />
|
<VnTitle :url="claimUrl('photos')" :text="t('claim.photos')" />
|
||||||
<div class="container max-container-height" style="overflow: auto">
|
<div class="container max-container-height" style="overflow: auto">
|
||||||
<div
|
<div
|
||||||
|
@ -348,10 +355,21 @@ function claimUrl(section) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</QCard>
|
</QCard>
|
||||||
|
<QCard class="vn-one">
|
||||||
|
<VnTitle :text="t('claim.resume')" />
|
||||||
|
<div class="container max-container-height">
|
||||||
|
<VnLv :label="t('Amount')" :value="toCurrency(amount)" />
|
||||||
|
<VnLv :label="t('Amount Claimed')">
|
||||||
|
<template #value>
|
||||||
|
<QChip color="positive">
|
||||||
|
{{ toCurrency(amountClaimed) }}
|
||||||
|
</QChip>
|
||||||
|
</template>
|
||||||
|
</VnLv>
|
||||||
|
</div>
|
||||||
|
</QCard>
|
||||||
<QCard class="vn-max" v-if="salesClaimed.length > 0" @on-fetch="onFetch">
|
<QCard class="vn-max" v-if="salesClaimed.length > 0" @on-fetch="onFetch">
|
||||||
<VnTitle :url="claimUrl('lines')" :text="t('claim.details')" />
|
<VnTitle :url="claimUrl('lines')" :text="t('claim.details')" />
|
||||||
{{ salesClaimed }}
|
|
||||||
|
|
||||||
<QTable
|
<QTable
|
||||||
:columns="detailsColumns"
|
:columns="detailsColumns"
|
||||||
:rows="salesClaimed"
|
:rows="salesClaimed"
|
||||||
|
|
|
@ -46,3 +46,4 @@ claim:
|
||||||
dragDrop: Drag and drop it here
|
dragDrop: Drag and drop it here
|
||||||
search: Search claims
|
search: Search claims
|
||||||
searchInfo: You can search by claim id or customer name
|
searchInfo: You can search by claim id or customer name
|
||||||
|
resume: Resume
|
||||||
|
|
|
@ -46,3 +46,4 @@ claim:
|
||||||
dragDrop: Arrastra y suelta aquí
|
dragDrop: Arrastra y suelta aquí
|
||||||
search: Buscar reclamación
|
search: Buscar reclamación
|
||||||
searchInfo: Puedes buscar por ID de la reclamación o nombre del cliente
|
searchInfo: Puedes buscar por ID de la reclamación o nombre del cliente
|
||||||
|
resume: Resumen
|
||||||
|
|
Loading…
Reference in New Issue