Sfoglia il codice sorgente

[FIX] amount total paid

Gogs 7 anni fa
parent
commit
1f90f2176d
2 ha cambiato i file con 38 aggiunte e 8 eliminazioni
  1. 27 7
      src/components/payment/PaymentAmount.vue
  2. 11 1
      src/store/modules/account.js

+ 27 - 7
src/components/payment/PaymentAmount.vue

@@ -8,7 +8,7 @@
             input.payment-input(readonly :value="formatTotal()")
         .payment-amount-item
             label.payment-label Monto recibido
-            input.payment-input
+            input.payment-input(:value="paid" v-model="paid")
         hr.result-separator
         .payment-amount-item
             label.payment-label Monto a devolver
@@ -16,16 +16,36 @@
 </template>
 
 <script>
-    import { mapGetters } from 'vuex'
+    import { mapGetters, mapActions } from 'vuex'
 
     export default {
-        computed: mapGetters([
-            'total'
-        ]),
+        computed: {
+            paid: {
+                get() {
+                    return accounting.formatMoney(this.amountPaid, this.currencySymbol, 0, '.', ',')
+                },
+                set(value) {
+                    value = accounting.unformat(value, ',')
+                    
+                    this.changeAmountPaid(value)
+                }
+            },
+            ...mapGetters([
+                'total',
+                'currencySymbol',
+                'amountPaid'
+            ])
+        },
         methods: {
             formatTotal() {
-                return accounting.formatMoney(this.total, '₲', 0, '.', ',')
-            }
+                return accounting.formatMoney(this.total, this.currencySymbol, 0, '.', ',')
+            },
+            calculateResidual() {
+
+            },
+            ...mapActions([
+                'changeAmountPaid'
+            ])
         }
     }
 </script>

+ 11 - 1
src/store/modules/account.js

@@ -4,7 +4,8 @@ const state = {
     payment: 'cash',
     paymentTerms: [],
     selectedJournal: null,
-    selectedPaymentTerm: null
+    selectedPaymentTerm: null,
+    amountPaid: 0
 }
 
 const getters = {
@@ -25,6 +26,9 @@ const getters = {
     },
     selectedPaymentTerm(state) {
         return state.selectedPaymentTerm
+    },
+    amountPaid(state) {
+        return state.amountPaid
     }
 }
 
@@ -46,6 +50,9 @@ const mutations = {
     },
     togglePayment(state, payload) {
         state.payment = payload
+    },
+    setAmountPaid(state, payload) {
+        state.amountPaid = payload
     }
 }
 
@@ -103,6 +110,9 @@ const actions = {
     },
     togglePayment({ commit }, payload) {
         commit('togglePayment', payload)
+    },
+    changeAmountPaid({ commit }, payload) {
+        commit('setAmountPaid', payload)
     }
 }