#69 feat(Reconciliation):get purchases from backend.

This commit is contained in:
Mono Mono 2024-11-17 23:55:54 -05:00
parent a6b4c1c5b6
commit 9a20212b27

View File

@ -69,7 +69,7 @@
<v-btn @click="openSummaryModal(item.id)">{{ item.id }}</v-btn> <v-btn @click="openSummaryModal(item.id)">{{ item.id }}</v-btn>
</template> </template>
<template v-slot:item.total="{ item }"> <template v-slot:item.total="{ item }">
<CurrencyText :value="item.total"></CurrencyText> <CurrencyText :value="parseFloat(item.total)"></CurrencyText>
</template> </template>
</v-data-table-virtual> </v-data-table-virtual>
</v-tabs-window-item> </v-tabs-window-item>
@ -94,7 +94,7 @@
data () { data () {
return { return {
selectedPurchaseId: null, selectedPurchaseId: null,
selectedTab: null, selectedTab: 'CASH',
reconciliation: { reconciliation: {
datetime: '', datetime: '',
total_cash_purchases: 0, total_cash_purchases: 0,
@ -112,14 +112,7 @@
{title: 'Cliente', value: 'customer.name'}, {title: 'Cliente', value: 'customer.name'},
{title: 'Total', value: 'total'}, {title: 'Total', value: 'total'},
], ],
purchases: { purchases: {},
cash: [
{id: 1, date: '2024-02-01', customer:{name: 'camilocash'}, total: 12000},
{id: 1, date: '2024-02-01', customer:{name: 'camilocash'}, total: 12000}
],
confiar: [{id: 1, date: '2024-02-01', customer:{name: 'camiloconfiar'}, total: 12000}],
bancolombia: [{id: 1, date: '2024-02-01', customer:{name: 'camilobancolobia'}, total: 12000}],
},
}, },
rules: { rules: {
required: value => !!value || 'Requerido.', required: value => !!value || 'Requerido.',
@ -128,7 +121,7 @@
}; };
}, },
mounted() { mounted() {
this.reconciliation.total_cash_purchases = this.totalByMethod('cash'); this.fetchPurchases();
this.reconciliation.datetime = this.getCurrentDate(); this.reconciliation.datetime = this.getCurrentDate();
}, },
watch: { watch: {
@ -139,7 +132,7 @@
methods: { methods: {
totalByMethod(method) { totalByMethod(method) {
if (method in this.summary.purchases) { if (method in this.summary.purchases) {
return this.summary.purchases[method].reduce((a, b) => a + b.total, 0); return this.summary.purchases[method].reduce((a, b) => a + parseFloat(b.total), 0);
} }
return 0; return 0;
}, },
@ -158,6 +151,18 @@
this.selectedPurchaseId = id; this.selectedPurchaseId = id;
this.$refs.summaryModal.dialog = true; this.$refs.summaryModal.dialog = true;
}, },
fetchPurchases() {
const endpoint = '/don_confiao/purchases/for_reconciliation';
fetch(endpoint)
.then(response => response.json())
.then(data => {
this.summary.purchases = data;
this.reconciliation.total_cash_purchases = this.totalByMethod('CASH');
})
.catch(error => {
console.error(error);
});
},
}, },
} }
</script> </script>