Kaynağa Gözat

[FIX] Validaciones en selecion de Cuota

adrielso 7 yıl önce
ebeveyn
işleme
b0b58c6cfb

+ 2 - 1
models/res_partner.py

@@ -44,7 +44,8 @@ class ResPartner(models.Model):
                                 'amount_residual': moveline.amount_residual,
                                 'credit': moveline.credit,
                                 'debit': moveline.debit,
-                                'date_maturity': moveline.date_maturity
+                                'date_maturity': moveline.date_maturity,
+                                'invoice': invoice.id
                             })
 
                 for currency in invoice.currency_id:

+ 3 - 2
src/Payments.vue

@@ -5,7 +5,7 @@
 				partner-step
 			tab-content(title="Cual es la factura?" :before-change="checkInvoice")
 				invoice-step
-			tab-content(title="Que cuota es?")
+			tab-content(title="Que cuota es?" :before-change="checkMoveLine")
 				move-step
 			tab-content(title="Como quieres pagar?")
 				method-payment-step
@@ -56,7 +56,8 @@
 			...mapActions([
 			    'initPayment',
 			    'notify',
-			    'completePayment'
+			    'completePayment',
+				'checkMoveLine'
 			])
 		},
 		mounted(){

+ 15 - 0
src/components/partner/PartnerCard.vue

@@ -2,6 +2,7 @@
     .partner-card(@click="selectPartner(item)" v-bind:class="{ 'selected-partner': isSelectedPartner() }")
         h2.partner-name {{ item.name }}
         img.partner-photo(:src="this.item.image_medium ? 'data:image/png;base64,' + this.item.image_medium : '/base/static/src/img/avatar.png'")
+        h2.partner-ruc C.I. {{ getRuc() }}
 </template>
 
 <script>
@@ -24,6 +25,9 @@
             isSelectedPartner() {
                 return this.hasSelectedPartner ? this.item.id === this.selectedPartner.id : false
             },
+            getRuc() {
+                    return this.item.ruc ? this.item.ruc : ''
+            },
             ...mapActions([
                 'selectPartner',
             ])
@@ -66,4 +70,15 @@
             left: 50%
             margin-right: -50%
             transform: translate(-50%, -50%)
+
+        .partner-ruc
+            width: 100%
+            height: 30px
+            font-size: 9pt
+            text-align: center
+            margin: 0px
+            padding-top: 5px
+            position: absolute
+            bottom: 0
+
 </style>

+ 1 - 0
src/components/partner/PartnerSearcher.vue

@@ -26,6 +26,7 @@
                     maxPatternLength: 32,
                     minMatchCharLength: 1,
                     keys: [
+                        'ruc',
                         'name',
                         'phone',
                         'mobile',

+ 3 - 0
src/store/actions.js

@@ -18,6 +18,9 @@ const actions = {
             console.log(error)
         })
     },
+    checkMoveLine({getters, dispatch}) {
+        return getters.moveLinesIsEmpty ||dispatch('notify', 'Necesitas seleccionar la cuota para continuar')
+    },
     completePayment({ dispatch, getters, state}) {
         let newObjet = []
 

+ 12 - 2
src/store/modules/paymentsInvoices.js

@@ -30,26 +30,36 @@ const mutations = {
     },
     applyInvoicesFilter( state, payload){
         state.filteredInvoices = payload
+    },
+    addMovelineInvoice(state, payload) {
+        let finded = state.selectedInvoices.moveLines.find(item => item.id == state.selectedInvoices.moveLines.id)
+        if (finded) return
+
+        state.selectedInvoices.moveLines = [payload.moveLine, ...state.selectedInvoices.moveLines]
     }
 }
 
 const actions = {
     pushInvoices ({commit, dispatch }, payload){
+
         commit('pushInvoices', {
             invoices: payload.invoices
         })
     },
     selectInvoice ({ commit, dispatch}, payload) {
+
         commit('selectInvoice',{
             invoice: payload
         })
 
-        dispatch('pushMovelines', payload)
+        dispatch('pushMovelines',payload)
     },
     filterInvoices ({ commit }, payload){
         commit('applyInvoicesFilter', payload)
+    },
+    addMovelineInvoice({commit}, payload) {
+        commit('addMovelineInvoice',payload)
     }
-
 }
 export default {
     state,

+ 12 - 10
src/store/modules/paymentsMoveLines.js

@@ -21,6 +21,9 @@ const getters = {
     total(state) {
         return state.total
     },
+    moveLinesIsEmpty(state) {
+        return state.movelineSelect.length !== 0
+    }
 }
 
 const mutations = {
@@ -63,40 +66,35 @@ const mutations = {
 
     removeMoveCard(state, payload) {
         let findedMoveCard = state.moveLines.findIndex(item => item.id == payload.moveCardDelet.id)
-
         state.moveLines.splice(findedMoveCard,1)
     },
 
     addMovelineCard(state, payload) {
-        // console.log(payload.moveLine);
-        // console.log(state.moveLines);
+
         let finded = state.moveLines.find(item => item.id == payload.moveLine.id)
-        // console.log(finded);
         if (finded) return
 
         state.moveLines = [payload.moveLine, ...state.moveLines]
-
     }
-
 }
 
 const actions = {
-    pushMovelines({ commit, dispatch }, payload ) {
+    pushMovelines({ commit, dispatch}, payload ) {
         commit('pushMovelines', payload)
     },
     selectMoveline({ commit, dispatch}, payload) {
         commit('selectMoveline',{
             moveline: payload
         })
-
+        // Add nueva lineas
         commit('addMoveline',{
             moveselect: payload
         })
-
+        // Remover los card de la cuotas
         commit('removeMoveCard',{
             moveCardDelet: payload
         })
-
+        // Calcular el total
         commit('calculateTotal')
     },
     removeLine({ commit, dispatch}, payload) {
@@ -108,6 +106,10 @@ const actions = {
             moveLine: payload
         })
 
+        dispatch('addMovelineInvoice', {
+            moveLine: payload
+        })
+
         commit('calculateTotal')
     }
 }