Prechádzať zdrojové kódy

[ADD] Paso 4 - Metodo de Pago

adrielso 7 rokov pred
rodič
commit
bfa3308d2b

+ 1 - 0
__init__.py

@@ -1,2 +1,3 @@
 # -*- coding: utf-8 -*-
+from models import payment_journal
 from models import res_partner

+ 1 - 1
__openerp__.py

@@ -4,7 +4,7 @@
     'author': "Adrielso Kunert",
     'category': 'Uncategorized',
     'version': '0.1',
-    'depends': ['base'],
+    'depends': ['base', 'account'],
     'data': [
         'views/template.xml',
     ]

+ 27 - 0
models/payment_journal.py

@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+from openerp import api, fields, models
+
+class PaymentJournal(models.Model):
+    _inherit = 'account.journal'
+
+    @api.model
+    def get_paymentsJournals(self):
+        domain =[
+            ('active', '=', True),
+            ('type', 'in',['bank', 'cash'])
+        ]
+        paymentsJournals = []
+
+        for journal in self.env['account.journal'].search(domain, order="id"):
+
+            paymentsJournals.append({
+                'id': journal.id,
+                'name': journal.name,
+                'display_name': journal.display_name,
+                'code': journal.code,
+                'cash_control': journal.cash_control,
+                'type': journal.type
+            })
+
+        print(paymentsJournals)
+        return paymentsJournals

+ 8 - 3
models/res_partner.py

@@ -22,8 +22,9 @@ class ResPartner(models.Model):
 
             for invoice in customer.invoice_ids:
                 movelines = []
-                for move in invoice.move_id:
+                currency_symbol = ""
 
+                for move in invoice.move_id:
                     for moveline in move.line_id:
                         if moveline.amount_residual > 0 and moveline.state != "draft":
                             movelines.append({
@@ -33,7 +34,10 @@ class ResPartner(models.Model):
                                 'debit': moveline.debit,
                                 'date_maturity': moveline.date_maturity
                             })
-                            # domain=['&', ('reconcile_id', '=', False), '&', ('account_id.active','=', True), '&', ('account_id.type', '=', 'receivable'), ('state', '!=', 'draft')])
+
+                for currency in invoice.currency_id:
+                    currency_symbol=currency.symbol
+
                 if invoice.state == 'open':
                     invoices.append({
                         'id': invoice.id,
@@ -41,7 +45,8 @@ class ResPartner(models.Model):
                         'date_invoice': invoice.date_invoice,
                         'amount_total': invoice.amount_total,
                         'residual': invoice.residual,
-                        'moveLines': movelines
+                        'moveLines': movelines,
+                        'currency_symbol' : currency_symbol
                     })
 
             partners.append({

+ 3 - 1
src/Payments.vue

@@ -8,7 +8,7 @@
 			tab-content(title="Que cuota es?")
 				move-step
 			tab-content(title="Como quieres pagar?")
-				h6 Metodo de pagos
+				method-payment-step
 		loader
 </template>
 
@@ -19,6 +19,7 @@
 	import PartnerStep from '@/components/partner/PartnerStep'
 	import InvoiceStep from '@/components/invoice/InvoiceStep'
 	import MoveStep from '@/components/move/MoveStep'
+	import MethodPaymentStep from '@/components/payment/MethodPaymentStep'
 	import Loader from '@/components/Loader'
 
 	import {mapActions, mapGetters } from 'vuex'
@@ -31,6 +32,7 @@
 			PartnerStep,
 			InvoiceStep,
 			MoveStep,
+			MethodPaymentStep,
 			Loader
 		},
 		computed: mapGetters([

+ 3 - 2
src/components/invoice/InvoiceCard.vue

@@ -2,8 +2,8 @@
     .invoice-card(@click="selectInvoice(item)" v-bind:class="{ 'selected-invoice': isSelectedInvoice() }")
         h2.invoice-date {{ getDate() }}
         h2.invoice-title {{ item.number }}
-        h2.invoice-total Total  {{ getTotal() }}
-        h2.invoice-saldo  Saldo {{ getResidual() }}
+        h2.invoice-total Total  {{ getTotal() }} {{ item.currency_symbol }}
+        h2.invoice-saldo  Saldo {{ getResidual() }} {{ item.currency_symbol }}
 </template>
 
 <script>
@@ -39,6 +39,7 @@
             getResidual() {
                 return !!this.item.residual ? accounting.format(this.item.residual, 0,'.', ',') : '0'
             },
+
         }
     }
 </script>

+ 18 - 15
src/components/move/MoveContainer/MoveCard.vue

@@ -1,13 +1,13 @@
 <template lang="pug">
-    .move-card-wrapper(@click="selectMoveline(item)" v-bind:class="{ 'selected-Line': isSelectedLine() }")
+    .move-card-wrapper(@click="selectMoveline(item)")
         .move-card
             h2.move-maturity Vencimiento {{ getDate() }}
             .move-debit-wrapper
                 h2.move-debit-label Total
-                h2.move-debit  {{ getDebit() }}
+                h2.move-debit  {{ getDebit() }} {{ getSymbol() }}
             .move-residual-wrapper
                 h2.move-residual-label Saldo
-                h2.move-residual {{ getResidual() }}
+                h2.move-residual {{ getResidual() }} {{ getSymbol() }}
         .move-tag(v-if="isMaturity()")
             h2.move-tag-label Vencida
 </template>
@@ -27,15 +27,13 @@
         computed: mapGetters ([
             'selectedPartner',
             'selectedMoveline',
-            'haSelectedMoveline'
+            'haSelectedMoveline',
+            'selectedInvoices'
         ]),
         methods: {
             ...mapActions([
                 'selectMoveline'
             ]),
-            isSelectedLine() {
-                return this.haSelectedMoveline ? this.item.id === this.selectedMoveline.id : false
-            },
             getDate() {
                 return !!this.item.date_maturity ? moment(this.item.date_maturity).format("DD-MM-YYYY") : ''
             },
@@ -48,6 +46,9 @@
             isMaturity() {
                 return this.selectedPartner.date_server > this.item.date_maturity ? this.item.date_maturity : false
             },
+            getSymbol() {
+                return this.selectedInvoices.currency_symbol
+            }
         }
     }
 </script>
@@ -61,8 +62,10 @@
         display: inline-block
         position: relative
 
-        &.selected-Line
-
+        // &.selected-Line
+        //     transition-duration: 3s
+        //     opacity: 1
+        //     transform: translate3d(1176px, 0px, 0px)
 
         .move-card
             width: 100%
@@ -88,7 +91,7 @@
                 position: absolute
 
                 .move-debit
-                    width: 140px
+                    width: 150px
                     height: 35px
                     margin-top: 4px
                     padding:
@@ -97,12 +100,12 @@
                     float: right
                     text-align: right
                     font:
-                        size: 16pt
+                        size: 12pt
 
                 .move-debit-label
                     width: 90px
                     height: 35px
-                    font-size: 16pt
+                    font-size: 12pt
                     float: left
                     margin-top: 4px
                     padding-top: 5px
@@ -116,7 +119,7 @@
                 position: absolute
 
                 .move-residual
-                    width: 140px
+                    width: 150px
                     height: 35px
                     margin-top: 4px
                     padding:
@@ -125,12 +128,12 @@
                     float: right
                     text-align: right
                     font:
-                        size: 16pt
+                        size: 12pt
 
                 .move-residual-label
                     width: 90px
                     height: 35px
-                    font-size: 16pt
+                    font-size: 12pt
                     float: left
                     margin-top: 4px
                     padding-top: 5px

+ 2 - 1
src/components/move/MoveContainer/MoveGrid.vue

@@ -22,10 +22,11 @@
 <style lang="sass">
     .move-grid-wrapper
         width: 100%
-        height: 470px
+        height: calc(100% - 100px)
         margin-top: 15px
         overflow-y: auto
 
         .move-grid
             width: 100%
+            height: 470px
 </style>

+ 11 - 3
src/components/move/MoveLinesContainer/MoveLinesItem.vue

@@ -1,7 +1,7 @@
 <template lang="pug">
     li.move-lines-item
         h3.move-lines-item-maturity Vencimiento {{ item.date_maturity}} {{ item.id }}
-        span.move-lines-item-subtotal {{ item.amount_residual}}
+        span.move-lines-item-subtotal {{ formatTotal() }} {{ getSymbol() }}
         .move-lines-item-options-wrapper(class="fa fa-trash" @click="remove(item)")
 </template>
 
@@ -18,14 +18,22 @@
                 }
             }
         },
+        computed: mapGetters([
+            'selectedInvoices'
+        ]),
         methods: {
             remove(item) {
-                console.log(item);
                 this.removeLine(item)
             },
             ...mapActions([
                 'removeLine'
-            ])
+            ]),
+            formatTotal() {
+                return accounting.format(this.item.amount_residual,0,'.',',')
+            },
+            getSymbol() {
+                return this.selectedInvoices.currency_symbol
+            }
         }
 
     }

+ 6 - 2
src/components/move/MoveLinesContainer/MoveLinesTotalItem.vue

@@ -1,7 +1,7 @@
 <template lang="pug">
     .move-line-total-item
         h2
-            small G$
+            small {{ getSymbol() }}
             |
             | {{ formatTotal() }}
 </template>
@@ -12,11 +12,15 @@
 
     export default {
         computed: mapGetters([
-            'total'
+            'total',
+            'selectedInvoices'
         ]),
         methods: {
             formatTotal() {
                 return accounting.format(this.total,0,'.',',')
+            },
+            getSymbol() {
+                return !!this.selectedInvoices ? this.selectedInvoices.currency_symbol : ''
             }
         }
     }

+ 28 - 0
src/components/payment/MethodPaymentStep.vue

@@ -0,0 +1,28 @@
+<template lang="pug">
+    .payments-step
+        .method-payment-step
+            voucher-ticket
+            method-payment
+</template>
+
+<script>
+
+    import { mapGetters, mapActions } from 'vuex'
+
+    import VoucherTicket from '@/components/payment/VoucherTicket'
+    import MethodPayment from '@/components/payment/method/MethodPayment'
+
+    export default {
+        components: {
+            VoucherTicket,
+            MethodPayment
+        }
+    }
+</script>
+
+<style lang="sass">
+    .method-payment-step
+        width: 100%
+        height: calc(100% - 50px)
+        display: flex
+</style>

+ 22 - 0
src/components/payment/VoucherTicket.vue

@@ -0,0 +1,22 @@
+<template lang="pug">
+    .voucher-ticket
+        h2 aqui va estar el detalle q va pagar
+</template>
+
+<script>
+    export default {
+    }
+</script>
+
+<style lang="sass">
+    .voucher-ticket
+        width: 500px
+        height: 100%
+        font-size: 8pt
+        display: flex
+        // padding-left: 5px
+        // display: inline-block
+        background: azure
+        border: 1px solid green
+
+</style>

+ 96 - 0
src/components/payment/method/MethodPayment.vue

@@ -0,0 +1,96 @@
+<template lang="pug">
+    form.method-payment
+        .method-form-separator
+            h3 Detalle de Cliente
+            hr
+        .method-form-item
+            label.method-form-label Cliente
+            input.method-form-input(readonly :value="getPartner()")
+        .method-form-separator
+            h3 Detalle de pago
+            hr
+        .method-form-item
+            label.method-form-label Método de pago
+            select.method-form-input(v-model="journal")
+                option(v-for="journal in paymentsJournals" :value="journal") {{ journal.display_name}}
+        .method-form-item
+            label.method-form-label Total
+            input.method-form-input(readonly :value="getTotal()")
+        .method-form-item
+            label.method-form-label Monto a Pagar
+            input.method-form-input(readonly :value="getTotal()")
+        .method-form-item
+            label.method-form-label Monto a Devolver
+            input.method-form-input(readonly :value="0")
+</template>
+<script>
+
+    import { mapGetters, mapActions } from 'vuex'
+
+    export default {
+        computed: {
+            journal: {
+                get() {
+                    return this.paymentsJournals
+                }
+            } ,
+            ...mapGetters([
+                'selectedPartner',
+                'total',
+                'paymentsJournals'
+            ])
+        },
+        methods: {
+            getPartner() {
+                return !!this.selectedPartner ? this.selectedPartner.display_name : ''
+            },
+            getPartnerRuc() {
+                return !!this.selectedPartner ? this.selectedPartner.ruc : ''
+            },
+            getTotal() {
+                return !!this.total ? accounting.format(this.total,0,'.',',') : 0
+            }
+        }
+
+    }
+</script>
+
+<style lang="sass">
+    .method-payment
+        width: calc(100% - 500px)
+        height: 100%
+        display: inline-block
+        background: #f5f5f5
+        vertical-align: top
+        padding: 15px 35px
+        margin-right: 50px
+        border: 1px solid red
+
+        .method-form-separator
+            h3
+                color: #9e9e9e
+                font:
+                    size: 8pt
+            hr
+                margin-top: 5px
+
+        .method-form-item
+            width: 100%
+            height: 45px
+            margin-bottom: 15px
+
+            .method-form-label
+                width: 250px
+                height: 45px
+                font:
+                    size: 14pt
+
+            .method-form-input
+                width: 350px
+                height: 45px
+                font:
+                    size: 14pt
+                border-radius: 0
+
+
+</style>

+ 2 - 1
src/store/actions.js

@@ -6,7 +6,8 @@ const actions = {
         commit('setPaymentsInstance', payload)
 
         let promises =[
-            dispatch('fetchPartners')
+            dispatch('fetchPartners'),
+            dispatch('fetchPaymentsJournal')
         ]
 
         Promise.all(promises).then(() => {

+ 2 - 0
src/store/index.js

@@ -9,6 +9,7 @@ import mutations from '@/store/mutations'
 import partners from '@/store/modules/partners'
 import invoices from '@/store/modules/invoices'
 import moveLines from '@/store/modules/moveLines'
+import journal from '@/store/modules/journal'
 import loader from '@/store/modules/loader'
 
 Vue.use(Vuex)
@@ -20,6 +21,7 @@ const Store = new Vuex.Store({
     actions,
     modules:{
         partners,
+        journal,
         invoices,
         moveLines,
         loader

+ 46 - 0
src/store/modules/journal.js

@@ -0,0 +1,46 @@
+const state = {
+    paymentsJournals: [],
+}
+
+const getters = {
+    paymentsJournals(state) {
+        return state.paymentsJournals
+    }
+}
+
+const mutations = {
+    pushPaymentsJournal(state, payload) {
+        state.paymentsJournals = [...payload.paymentsJournals]
+    }
+}
+
+const actions = {
+    fetchPaymentsJournal({ commit, dispatch}) {
+        return new Promise((resolve, reject) => {
+            let Accountjournal = new openerp.web.Model('account.journal')
+
+            Accountjournal.call('get_paymentsJournals',{
+                context: new openerp.web.CompoundContext()
+            }).then(response => {
+                commit('pushPaymentsJournal',{
+                    paymentsJournals: response
+                })
+
+                dispatch('loaded', 'paymentsJournals')
+
+                resolve()
+            }).fail(error => {
+                console.error(error)
+                reject(error)
+            })
+        })
+    }
+
+}
+
+export default {
+    state,
+    getters,
+    mutations,
+    actions
+}

+ 7 - 4
src/store/modules/loader.js

@@ -2,7 +2,8 @@ const state = {
     loaded: {
         // company: false,
         // currencies: false,
-        partners: false
+        partners: false,
+        paymentsJournals: false
         // products: false,
         // journals: false,
         // periods: false,
@@ -11,7 +12,8 @@ const state = {
     messages: [
         // 'Cargando compañía',
         // 'Cargando monedas',
-        'Cargando clientes'
+        'Cargando clientes',
+        'Cargando Método de Pago'
         // 'Cargando productos'
     ]
 }
@@ -21,8 +23,9 @@ const getters = {
         return state.messages
     },
     isLoaded(state) {
-        return state.loaded.partners
-                   }
+        return state.loaded.partners &&
+               state.loaded.paymentsJournals
+    }
 }
 
 const mutations = {

+ 2 - 2
src/store/modules/moveLines.js

@@ -20,7 +20,7 @@ const getters = {
     },
     total(state) {
         return state.total
-    }
+    },
 }
 
 const mutations = {
@@ -71,7 +71,7 @@ const mutations = {
         // console.log(payload.moveLine);
         // console.log(state.moveLines);
         let finded = state.moveLines.find(item => item.id == payload.moveLine.id)
-        console.log(finded);
+        // console.log(finded);
         if (finded) return
 
         state.moveLines = [payload.moveLine, ...state.moveLines]