浏览代码

[ADD] Selecion de Cuotas

adrielso 7 年之前
父节点
当前提交
bd8e5ae32b

+ 3 - 1
models/res_partner.py

@@ -1,4 +1,5 @@
 from openerp import api, fields, models
+from datetime import  datetime, date, time, timedelta
 
 class ResPartner(models.Model):
     _inherit = 'res.partner'
@@ -55,7 +56,8 @@ class ResPartner(models.Model):
                 'credit': customer.credit,
                 'credit_limit': customer.credit_limit,
                 'categories': categories,
-                'invoices': invoices
+                'invoices': invoices,
+                'date_server': str(datetime.now().date())
             })
 
         return partners

+ 4 - 0
src/Payments.vue

@@ -97,6 +97,10 @@
 						height: calc(100% - 20px)
 						margin: 10px
 
+						.payments-step
+							width: 100%
+							height: 100%
+							background: #fff
 
 			.wizard-card-footer
 				width: 100%

+ 14 - 5
src/components/invoice/InvoiceCard.vue

@@ -1,9 +1,9 @@
 <template lang="pug">
     .invoice-card(@click="selectInvoice(item)" v-bind:class="{ 'selected-invoice': isSelectedInvoice() }")
-        h2.invoice-date {{ item.date_invoice}}
-        h2.invoice-title {{ item.number}}
-        h2.invoice-total Total  {{ item.amount_total }}
-        h2.invoice-saldo  Saldo {{ item.residual}}
+        h2.invoice-date {{ getDate() }}
+        h2.invoice-title {{ item.number }}
+        h2.invoice-total Total  {{ getTotal() }}
+        h2.invoice-saldo  Saldo {{ getResidual() }}
 </template>
 
 <script>
@@ -29,7 +29,16 @@
             },
             ...mapActions([
                 'selectInvoice'
-            ])
+            ]),
+            getDate() {
+                return !!this.item.date_invoice ? moment(this.item.date_invoice).format("DD-MM-YYYY") : ''
+            },
+            getTotal() {
+                return !!this.item.amount_total ? accounting.format(this.item.amount_total, 0,'.', ',') : '0'
+            },
+            getResidual() {
+                return !!this.item.residual ? accounting.format(this.item.residual, 0,'.', ',') : '0'
+            },
         }
     }
 </script>

+ 5 - 3
src/components/invoice/InvoiceStep.vue

@@ -1,7 +1,8 @@
 <template lang="pug">
-    .invoice-step
-        invoice-searcher
-        invoice-grid
+    .payments-step
+        .invoice-step
+            invoice-searcher
+            invoice-grid
 </template>
 
 <script>
@@ -22,4 +23,5 @@
         height: 100%
         padding-right: 5px
         display: inline-block
+        
 </style>

+ 111 - 21
src/components/move/MoveCard.vue

@@ -1,44 +1,134 @@
 <template lang="pug">
-    .move-card
-        h3 Hola 
+    .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() }}
+            .move-residual-wrapper
+                h2.move-residual-label Saldo
+                h2.move-residual {{ getResidual() }}
+        .move-tag(v-if="isMaturity()")
+            h2.move-tag-label Vencida
 </template>
 
 <script>
-export default {
-}
+    import  {mapGetters, mapActions } from 'vuex'
+
+    export default {
+        props: {
+            item: {
+                type: Object,
+                default: () => {
+                    return {}
+                }
+            }
+        },
+        computed: mapGetters ([
+            'selectedPartner'
+        ]),
+        methods: {
+            ...mapActions([
+                'selectMoveline'
+            ]),
+            getDate() {
+                return !!this.item.date_maturity ? moment(this.item.date_maturity).format("DD-MM-YYYY") : ''
+            },
+            getResidual() {
+                return !!this.item.amount_residual ? accounting.format(this.item.amount_residual, 0,'.', ',') : '0'
+            },
+            getDebit() {
+                return !!this.item.debit ? accounting.format(this.item.debit, 0,'.', ',') : '0'
+            },
+            isMaturity() {
+                return this.selectedPartner.date_server > this.item.date_maturity ? this.item.date_maturity : false
+            },
+        }
+    }
 </script>
 
 <style lang="sass">
-    .move-card
+    .move-card-wrapper
         width: calc(100% - 60px)
         height: 100px
         margin: 5px
         border: 1px solid #d3d3d3
         display: inline-block
         position: relative
+        background: rgba(119, 234, 224, 0.2)
 
-        .move-tag
-            width: 50px
-            height: 50px
+        .move-card
+            width: 100%
+            height: 100%
             position: absolute
-            top: 0
-            right: 0
-            border-radius: 0 0 0 90%
-            transition-duration: 0.3s
-            background: #4caf50
 
-            .move-tag-label,
+            .move-maturity
                 width: 100%
-                height: 22px
-                padding-top: 5px
-                margin: 0px
+                height: 25px
+                font-size: 12pt
                 text-align: center
-                font-size: 10pt
-                font-weight: bold
-                color: #fff
-                position: relative
+                margin: 10px 0px 0px 0px
+                position: absolute
 
+            .move-debit-wrapper
+                width: 45%
+                height: calc(100% - 50px)
+                border: 1px solid #d3d3d3
+                margin: 45px 0px 0px 2%
+                position: absolute
 
+                .move-debit
+                    width: 100%
+                    height: 30px
+                    font-size: 12pt
+                    text-align: center
+                    position: absolute
+                    margin-top: 15px
 
+                .move-debit-label
+                    width: 100%
+                    height: 30px
+                    font-size: 15pt
+                    position: absolute
+                    color: #868282
+                    margin-left: 13px
+                    margin-top: 10px
 
+            .move-residual-wrapper
+                width: 45%
+                height: calc(100% - 50px)
+                border: 1px solid #d3d3d3
+                margin: 45px 0px 0px 53%
+                position: absolute
+
+                .move-residual
+                    width: 100%
+                    height: 30px
+                    font-size: 12pt
+                    text-align: center
+                    position: absolute
+                    margin-top: 15px
+
+                .move-residual-label
+                    width: 100%
+                    height: 30px
+                    font-size: 15pt
+                    position: absolute
+                    color: #868282
+                    margin-left: 13px
+                    margin-top: 10px
+        .move-tag
+            // width: 80px
+            // height: 50px
+            position: absolute
+
+            .move-tag-label
+                width: 100%
+                height: 22px
+                text-align: center
+                margin-top: 15px
+                color: rgba(236, 0, 34, 0.4)
+                transform: rotate(-22deg)
+                font-size: 23pt
+                font-weight: bold
 </style>

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

@@ -16,7 +16,7 @@
 
 <style lang="sass">
     .move-container
-        width: calc(100% - 600px)
+        width: calc(100% - 500px)
         height: 100%
         padding-right: 5px
         display: inline-block

+ 38 - 0
src/components/move/MoveLinesContainer.vue

@@ -0,0 +1,38 @@
+<template lang="pug">
+    .payments-container
+        move-lines-items
+        h3.payments-container-title Total
+        move-lines-total
+</template>
+
+<script>
+
+    import MoveLinesTotal from '@/components/move/MoveLinesTotal'
+    import MoveLinesItems from '@/components/move/MoveLinesItems'
+
+    export default {
+        components: {
+            MoveLinesItems,
+            MoveLinesTotal
+        }
+    }
+</script>
+
+<style lang="sass">
+    .payments-container
+        width: 500px
+        height: calc(100% - 50px)
+        border-left: 1px solid #d3d3d3
+        padding-left: 10px
+        display: inline-block
+        vertical-align: top
+
+        .payments-container-title
+            float: left
+            padding-left: 15px
+            margin-bottom: 0
+            color: #d3d3d3
+            font:
+                size: 14pt
+
+</style>

+ 90 - 0
src/components/move/MoveLinesItem.vue

@@ -0,0 +1,90 @@
+<template lang="pug">
+    li.move-lines-item
+        h3.move-lines-item-maturity Vencimiento {{ item.date_maturity}}
+        span.move-lines-item-subtotal {{ item.amount_residual}}
+        .move-lines-item-options-wrapper(class="fa fa-trash" @click="remove(item)")
+</template>
+
+<script>
+    import { mapGetters, mapActions } from 'vuex'
+
+    export default {
+        props: {
+            item: {
+                type: Object,
+                required: true,
+                default: () => {
+                    return {}
+                }
+            }
+        },
+        methods: {
+            remove(item) {
+                console.log(item);
+                this.removeLine(item)
+            },
+            ...mapActions([
+                'removeLine'
+            ])
+        }
+
+    }
+</script>
+
+<style lang="sass">
+    .move-lines-item
+        width: 100%
+        height: 50px
+        list-style: none outside none
+        border-bottom: 1px solid #d3d3d3
+        box-sizing: border-box
+        position: relative
+
+        &:nth-child(1)
+            border-top: 1px solid #d3d3d3
+
+        &:hover
+            transition-duration: 1s
+            border-bottom: 2px solid #7c7bad
+
+        .move-lines-item-maturity
+            width: 220px
+            height: 30px
+            margin: 12px 0 5px 0
+            float: left
+            padding-left: 15px
+            font:
+                size: 10pt
+
+        .move-lines-item-subtotal
+            width: 165px
+            height: 30px
+            margin-top: 12px
+            padding-right: 15px
+            text-align: right
+            float: left
+            font:
+                size: 10pt
+                weight: bold
+
+        .move-lines-item-options-wrapper
+            width: 50px
+            height: 30px
+            margin-top: 12px
+            padding-right: 15px
+            float: right
+            display: flex
+            justify-content: center
+
+            &:hover
+                cursor: pointer
+
+            &.fa
+                padding-left: 2px
+                line-height: 20px
+                font-size: 17px
+
+            &.fa-trash:hover
+                color: #f44336
+
+</style>

+ 27 - 0
src/components/move/MoveLinesItems.vue

@@ -0,0 +1,27 @@
+<template lang="pug">
+    .move-lines-items-wrapper
+        move-lines-item(v-for="item in addMove" :key="item" :item="item")
+</template>
+
+<script>
+    import { mapGetters, mapActions } from 'vuex'
+    import MoveLinesItem from '@/components/move/MoveLinesItem'
+
+    export default {
+        components: {
+            MoveLinesItem
+        },
+        computed: mapGetters([
+            'addMove'
+        ])
+    }
+</script>
+
+<style lang="sass">
+    .move-lines-items-wrapper
+        width: 100%
+        height: 230px
+        border: 1px solid #d3d3d3
+        overflow-y: auto
+        overflow-x: hidden
+</style>

+ 32 - 0
src/components/move/MoveLinesTotal.vue

@@ -0,0 +1,32 @@
+<template lang="pug">
+    .move-line-total-wrapper
+        .move-line-total
+            move-lines-total-item
+</template>
+
+<script>
+
+    import MoveLinesTotalItem from '@/components/move/MoveLinesTotalItem'
+
+    export default {
+        components: {
+            MoveLinesTotalItem
+        }
+    }
+</script>
+
+<style lang="sass">
+    .move-line-total-wrapper
+        width: 100%
+        height: 100%
+        margin-top: 10px
+        border: 1px solid #d3d3d3
+        overflow-y: auto
+        overflow-x: hidden
+
+        .move-line-total
+            width: 100%
+            height: 200px
+
+
+</style>

+ 38 - 0
src/components/move/MoveLinesTotalItem.vue

@@ -0,0 +1,38 @@
+<template lang="pug">
+    .move-line-total-item
+        h2
+            small G$
+            |
+            | {{ formatTotal() }}
+</template>
+
+<script>
+
+    import { mapGetters, mapActions } from 'vuex'
+
+    export default {
+        computed: mapGetters([
+            'total'
+        ]),
+        methods: {
+            formatTotal() {
+                return accounting.format(this.total,0,'.',',')
+            }
+        }
+    }
+</script>
+
+<style lang="sass">
+    .move-line-total-item
+        width: 100%
+        height: 50px
+        border-bottom: 1px solid #dedede
+
+        h2
+            width: 100%
+            height: 40px
+            margin: 0
+            font-size: 25pt
+            padding-left: 15px
+
+</style>

+ 6 - 10
src/components/move/MoveStep.vue

@@ -1,26 +1,22 @@
 <template lang="pug">
-    .move-step
-        move-Container
-        payments-container
+    .payments-step
+        .move-step
+            move-Container
+            move-lines-container
 </template>
 
 <script>
 
     import MoveContainer from '@/components/move/MoveContainer'
-    import PaymentsContainer from '@/components/move/PaymentsContainer'
+    import MoveLinesContainer from '@/components/move/MoveLinesContainer'
 
     export default {
         components: {
             MoveContainer,
-            PaymentsContainer
+            MoveLinesContainer
         }
     }
 </script>
 
 <style lang="sass">
-    .move-step
-        width: 100%
-        height: 100%
-        padding-right: 5px
-        display: inline-block
 </style>

+ 0 - 17
src/components/move/PaymentsContainer.vue

@@ -1,17 +0,0 @@
-<template lang="pug">
-    .payments-container
-        Aqui va estar loque voy a pagar
-</template>
-
-<script>
-
-    export default {
-    }
-</script>
-
-<style lang="sass">
-    .payments-container
-        width: 100%
-        height: 500px
-        display: inline-block
-</style>

+ 3 - 3
src/components/partner/PartnerDetails.vue

@@ -84,13 +84,13 @@
 
                 .partner-form-label, .form-label-finazas
                     width: 80px
-                    height: 35px
+                    height: 20px
 
                 .partner-form-imput, .form-imput-finazas
                     width: 220px
-                    height: 35px
+                    height: 20px
                     border-radius: 0
-                
+
 
                 .form-label-finazas
                     width: 150px

+ 18 - 19
src/components/partner/PartnerStep.vue

@@ -28,29 +28,28 @@
     }
 </script>
 <style lang="sass">
-    .payments-step
-        .partner-step
-            width: 100%
-            height: 100%
-            display: flex
+    .partner-step
+        width: 100%
+        height: 100%
+        display: flex
 
-            .partner-left, .partner-right
-                height: 100%
+        .partner-left, .partner-right
+            height: 100%
 
-            .partner-left
-                width: 100%
+        .partner-left
+            width: 100%
 
-            .partner-right
-                width: 400px
-                margin: 0 15px
+        .partner-right
+            width: 400px
+            margin: 0 15px
 
-            .slide-fade-enter-active
-                transition: all .3s ease
+        .slide-fade-enter-active
+            transition: all .3s ease
 
-            .slide-fade-leave-active
-                transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0)
+        .slide-fade-leave-active
+            transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0)
 
-            .slide-fade-enter, .slide-fade-leave-to
-                transform: translateX(10px)
-                opacity: 0
+        .slide-fade-enter, .slide-fade-leave-to
+            transform: translateX(10px)
+            opacity: 0
 </style>

+ 6 - 1
src/store/modules/invoices.js

@@ -18,7 +18,12 @@ const getters = {
 
 const mutations = {
     pushInvoices(state, payload) {
-        state.invoices = payload.invoices
+        let invoice = payload.invoices
+        invoice.sort((a, b) => {
+            return a.date_invoice > b.date_invoice
+        })
+
+        state.invoices = invoice
     },
     selectInvoice (state, payload){
         state.selectedInvoices = payload.invoice

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

@@ -1,22 +1,83 @@
 const state = {
-    moveLines: []
+    moveLines: [],
+    movelineSelect: [],
+    selectedMoveline: null,
+    total: 0
 }
 
 const getters = {
     moveLines (state) {
         return state.moveLines
+    },
+    selectedMoveline(state) {
+        return state.selectedMoveline
+    },
+    haSelectedMoveline(state) {
+        return !!state.selectedMoveline
+    },
+    addMove(state) {
+        return state.movelineSelect
+    },
+    total(state) {
+        return state.total
     }
 }
 
 const mutations = {
     pushMovelines (state, payload) {
-        state.moveLines = payload.moveLines
+        let move = payload.moveLines
+        move.sort((a, b) => {
+            return a.date_maturity > b.date_maturity
+        })
+
+        state.moveLines = move
+    },
+    selectMoveline(state, payload) {
+        state.selectedMoveline = payload.moveline
+    },
+    addMoveline(state, payload) {
+        let finded =state.movelineSelect.find(item => item.id ==payload.moveselect.id)
+
+        if (finded) return
+
+        state.movelineSelect =[payload.moveselect, ...state.movelineSelect]
+    },
+    calculateTotal(state) {
+        let  sum = 0
+
+        state.movelineSelect.forEach(item => {
+            sum = sum + item.amount_residual
+        })
+
+        state.total = sum
+    },
+    removeLine(state, payload) {
+        let findedMove = state.movelineSelect.find(item => item.id == payload.movedelet.id)
+        state.movelineSelect.splice(findedMove,1)
     }
 }
 
 const actions = {
     pushMovelines({ commit, dispatch }, payload ) {
         commit('pushMovelines', payload)
+    },
+    selectMoveline({ commit, dispatch}, payload) {
+        commit('selectMoveline',{
+            moveline: payload
+        })
+
+        commit('addMoveline',{
+            moveselect: payload
+        })
+
+        commit('calculateTotal')
+    },
+    removeLine({ commit, dispatch}, payload) {
+        commit('removeLine',{
+            movedelet: payload
+        })
+
+        commit('calculateTotal')
     }
 }