refactor(Purchase): move change cash to componet.
This commit is contained in:
parent
acd9bf53c6
commit
c85f0554fb
@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<v-dialog v-model="dialog" max-width="400">
|
||||||
|
<v-card>
|
||||||
|
<v-card-title>Calcular Devuelta</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<v-text-field
|
||||||
|
v-model.number="purchase"
|
||||||
|
label="Total de la compra"
|
||||||
|
type="number"
|
||||||
|
prefix="$"
|
||||||
|
readonly
|
||||||
|
></v-text-field>
|
||||||
|
<v-text-field
|
||||||
|
v-model.number="money"
|
||||||
|
label="Dinero"
|
||||||
|
type="number"
|
||||||
|
prefix="$"
|
||||||
|
></v-text-field>
|
||||||
|
<v-text-field
|
||||||
|
v-model.number="change_cash"
|
||||||
|
label="Devuelta"
|
||||||
|
type="number"
|
||||||
|
prefix="$"
|
||||||
|
readonly
|
||||||
|
></v-text-field>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn text @click="dialog = false">Cerrar</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
total_purchase: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialog: false,
|
||||||
|
money: null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
purchase() {
|
||||||
|
return this.total_purchase
|
||||||
|
},
|
||||||
|
change_cash() {
|
||||||
|
return (this.money || 0) - this.total_purchase
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
@ -124,23 +124,8 @@
|
|||||||
item-value="value"
|
item-value="value"
|
||||||
label="Pago en"
|
label="Pago en"
|
||||||
></v-select>
|
></v-select>
|
||||||
<v-text-field
|
<v-btn @click="openCasherModal" v-if="purchase.payment_method === 'CASH'">Calcular Devuelta</v-btn>
|
||||||
v-if="purchase.payment_method === 'CASH'"
|
<CasherModal :total_purchase="calculateTotal" ref="casherModal"</CasherModal>
|
||||||
v-model="payment_cash"
|
|
||||||
label="Dinero"
|
|
||||||
prefix="$"
|
|
||||||
type="number"
|
|
||||||
:error-messages="isValidPayment ? [] : ['El dinero debe ser mayor o igual al total']"
|
|
||||||
:disable="calculateTotal === 0"
|
|
||||||
></v-text-field>
|
|
||||||
<v-text-field
|
|
||||||
v-if="purchase.payment_method === 'CASH'"
|
|
||||||
:value="calculateChange"
|
|
||||||
label="Devuelta"
|
|
||||||
prefix="$"
|
|
||||||
readonly
|
|
||||||
presistent-placeholder="true"
|
|
||||||
></v-text-field>
|
|
||||||
</v-container>
|
</v-container>
|
||||||
<v-btn @click="submit" color="green">Comprar</v-btn>
|
<v-btn @click="submit" color="green">Comprar</v-btn>
|
||||||
</v-form>
|
</v-form>
|
||||||
@ -149,11 +134,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CustomerForm from './CreateCustomerModal.vue';
|
import CustomerForm from './CreateCustomerModal.vue';
|
||||||
|
import CasherModal from './CasherModal.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DonConfiao',
|
name: 'DonConfiao',
|
||||||
components: {
|
components: {
|
||||||
CustomerForm
|
CustomerForm,
|
||||||
|
CasherModal,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
msg: String
|
msg: String
|
||||||
@ -242,6 +229,9 @@
|
|||||||
openModal() {
|
openModal() {
|
||||||
this.$refs.customerModal.openModal();
|
this.$refs.customerModal.openModal();
|
||||||
},
|
},
|
||||||
|
openCasherModal() {
|
||||||
|
this.$refs.casherModal.dialog = true
|
||||||
|
},
|
||||||
getCurrentDate() {
|
getCurrentDate() {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const yyyy = today.getFullYear();
|
const yyyy = today.getFullYear();
|
||||||
|
Loading…
Reference in New Issue
Block a user