#90 feat(Frontend): add Purchases in cuadres_de_tarro.
This commit is contained in:
parent
2fcf884cce
commit
77a0c4ac0d
@ -37,6 +37,42 @@
|
|||||||
prefix="$"
|
prefix="$"
|
||||||
type="number"
|
type="number"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
<v-tabs v-model="tab">
|
||||||
|
<v-tab
|
||||||
|
v-for="(elements, paymentMethod) in purchases"
|
||||||
|
:key="paymentMethod"
|
||||||
|
>
|
||||||
|
{{ paymentMethod }} <CurrencyText :value="elements.total"</CurrencyText>
|
||||||
|
</v-tab>
|
||||||
|
</v-tabs>
|
||||||
|
<v-tabs-window v-model="tab">
|
||||||
|
<v-tabs-window-item
|
||||||
|
v-for="(elements, paymentMethod) in purchases"
|
||||||
|
:key="paymentMethod"
|
||||||
|
>
|
||||||
|
<v-table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<th>Fecha</th>
|
||||||
|
<th>Cliente</th>
|
||||||
|
<th>Total</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="purchase in elements.purchases" :key="purchase.id">
|
||||||
|
<td><v-btn @click="openSummaryModal(purchase.id)">{{ purchase.id }}</v-btn></td>
|
||||||
|
<td>{{ purchase.date }}</td>
|
||||||
|
<td>{{ purchase.customer }}</td>
|
||||||
|
<td><CurrencyText :value="purchase.total"</CurrencyText></td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</v-table>
|
||||||
|
|
||||||
|
</v-tabs-window-item>
|
||||||
|
</v-tabs-window>
|
||||||
|
<SummaryPurchaseModal :id="selectedPurchaseId" ref="summaryModal" />
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-container>
|
</v-container>
|
||||||
@ -55,10 +91,13 @@
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
tab: null,
|
||||||
|
selectedPurchaseId: null,
|
||||||
api: inject('api'),
|
api: inject('api'),
|
||||||
valid: null,
|
valid: null,
|
||||||
reconciliation: {
|
reconciliation: {
|
||||||
},
|
},
|
||||||
|
purchases: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -71,9 +110,32 @@
|
|||||||
methods: {
|
methods: {
|
||||||
fetchReconciliation(reconciliationId) {
|
fetchReconciliation(reconciliationId) {
|
||||||
this.api.getReconciliation(reconciliationId)
|
this.api.getReconciliation(reconciliationId)
|
||||||
.then(data => this.reconciliation = data)
|
.then(data => {
|
||||||
|
this.reconciliation = data;
|
||||||
|
this.groupPurchases();
|
||||||
|
})
|
||||||
.catch(error => console.error(error));
|
.catch(error => console.error(error));
|
||||||
},
|
},
|
||||||
|
groupPurchases() {
|
||||||
|
if (this.reconciliation.Sales) {
|
||||||
|
this.purchases = this.reconciliation.Sales.reduce((grouped, sale) => {
|
||||||
|
const paymentMethod = sale.payment_method;
|
||||||
|
if (!grouped[paymentMethod]) {
|
||||||
|
grouped[paymentMethod] = {
|
||||||
|
purchases: [],
|
||||||
|
total: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
grouped[paymentMethod].purchases.push(sale);
|
||||||
|
grouped[paymentMethod].total += sale.total;
|
||||||
|
return grouped;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
openSummaryModal(id) {
|
||||||
|
this.selectedPurchaseId = id;
|
||||||
|
this.$refs.summaryModal.dialog = true;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
name: 'SummaryPurchase',
|
name: 'SummaryPurchase',
|
||||||
props: {
|
props: {
|
||||||
msg: String,
|
msg: String,
|
||||||
id: String
|
id: Number
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user