diff --git a/tienda_ilusion/don_confiao/frontend/don-confiao/src/components/ReconciliationJar.vue b/tienda_ilusion/don_confiao/frontend/don-confiao/src/components/ReconciliationJar.vue index 92c2d09..201cb97 100644 --- a/tienda_ilusion/don_confiao/frontend/don-confiao/src/components/ReconciliationJar.vue +++ b/tienda_ilusion/don_confiao/frontend/don-confiao/src/components/ReconciliationJar.vue @@ -69,7 +69,7 @@ {{ item.id }} @@ -94,7 +94,7 @@ data () { return { selectedPurchaseId: null, - selectedTab: null, + selectedTab: 'CASH', reconciliation: { datetime: '', total_cash_purchases: 0, @@ -112,14 +112,7 @@ {title: 'Cliente', value: 'customer.name'}, {title: 'Total', value: 'total'}, ], - 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}], - }, + purchases: {}, }, rules: { required: value => !!value || 'Requerido.', @@ -128,7 +121,7 @@ }; }, mounted() { - this.reconciliation.total_cash_purchases = this.totalByMethod('cash'); + this.fetchPurchases(); this.reconciliation.datetime = this.getCurrentDate(); }, watch: { @@ -139,7 +132,7 @@ methods: { totalByMethod(method) { 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; }, @@ -158,6 +151,18 @@ this.selectedPurchaseId = id; 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); + }); + }, }, }