#69 feat(Reconciliation):get purchases from backend.
This commit is contained in:
		| @@ -69,7 +69,7 @@ | ||||
|                 <v-btn @click="openSummaryModal(item.id)">{{ item.id }}</v-btn> | ||||
|               </template> | ||||
|               <template v-slot:item.total="{ item }"> | ||||
|                 <CurrencyText :value="item.total"></CurrencyText> | ||||
|                 <CurrencyText :value="parseFloat(item.total)"></CurrencyText> | ||||
|               </template> | ||||
|             </v-data-table-virtual> | ||||
|           </v-tabs-window-item> | ||||
| @@ -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); | ||||
|           }); | ||||
|       }, | ||||
|     }, | ||||
|   } | ||||
| </script> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user