Prechádzať zdrojové kódy

[ADD] amount paid check

Gogs 7 rokov pred
rodič
commit
3b7298d83a

+ 2 - 1
src/components/payment/credit/PaymentCreditAmount.vue

@@ -34,7 +34,8 @@
                     value = accounting.unformat(value, ',')
 
                     this.changeAmountPaid(value)
-                    this.computeAmounts(value)
+
+                    this.computeAmounts(this.amountPaid)
                 }
             },
             ...mapGetters([

+ 1 - 1
src/store/actions.js

@@ -28,7 +28,7 @@ const actions = {
         return getters.hasSelectedCustomer || dispatch('notify', 'Necesitas seleccionar un cliente para continuar')
     },
     checkAmountPaid({ getters, dispatch }) {
-        return (getters.payment === 'cash' && getters.amountPaid >= getters.total) || dispatch('notify', 'Necesitar entregar un monto igual o mayor al total')
+        return (getters.payment === 'cash' && getters.amountPaid >= getters.total) || dispatch('notify', 'El monto recibido no puede ser menor al monto a pagar')
     },
     completeSale({ getters, dispatch }) {
         // return new Promise((resolve, reject) => {

+ 7 - 3
src/store/modules/account.js

@@ -82,7 +82,6 @@ const actions = {
             AccountPaymentTerm.call('get_account_payment_terms', {
                 context: new openerp.web.CompoundContext()
             }).then(response => {
-                console.table(response)
                 commit('setPaymentTerms', response)
 
                 dispatch('autoSelectPaymentTerm', response)
@@ -105,8 +104,13 @@ const actions = {
         dispatch('autoSelectPaymentTerm', payload === 'cash' ? getters.paymentTerms : getters.paymentTerms.filter(t => t.id !== getters.selectedPaymentTerm.id))
         commit('togglePayment', payload)
     },
-    changeAmountPaid({ commit }, payload) {
-        commit('setAmountPaid', payload)
+    changeAmountPaid({ commit, getters, dispatch }, payload) {
+        if (payload <= getters.total) {
+            commit('setAmountPaid', payload)
+        } else {
+            commit('setAmountPaid', getters.total)
+            dispatch('notify', 'El monto entregado no puede mayor al total')
+        }
     }
 }