Browse Source

[ADD] all pos features

robert 6 years ago
parent
commit
657aa07ebc

+ 8 - 1
__openerp__.py

@@ -5,7 +5,14 @@
     'website': "http://www.yourcompany.com",
     'category': 'Uncategorized',
     'version': '0.1',
-    'depends': ['base', 'purchase'],
+    'depends': [
+        'base',
+        'account',
+        'purchase',
+        'eiru_bank_payments_references',
+        'eiru_sidebar_toggler',
+        'eiru_topbar_toggler'
+    ],
     'data': [
         'templates.xml'
     ]

+ 65 - 2
controllers/main.py

@@ -74,6 +74,35 @@ class Purchases(http.Controller):
             'thousandsSeparator': currency.thousands_separator
         } for currency in request.env['res.currency'].search([('active', '=', True)])]
 
+    '''
+        Get currencies from journals
+    '''
+    def get_currencies_from_journal(self):
+        domain = [
+            ('type', 'in', ['bank', 'cash']), 
+            ('default_debit_account_id.currency_id', '=', False), 
+            ('active', '=', True)
+        ]
+
+        currencies = []
+
+        for j in request.env['account.journal'].search(domain):
+            c = j.currency or j.company_id.currency_id
+
+            currencies.append({
+                'id': c.id,
+                'name': c.display_name,
+                'base': c.base,
+                'symbol': c.symbol,
+                'position': c.position,
+                'rateSilent': c.rate_silent,
+                'decimalSeparator': c.decimal_separator,
+                'decimalPlaces': c.decimal_places,
+                'thousandsSeparator': c.thousands_separator
+            })
+        
+        return {c['id']:c for c in currencies}.values()
+
     '''
         Get all active journals
     '''
@@ -198,6 +227,37 @@ class Purchases(http.Controller):
             } for line in payment_term.line_ids]
         } for payment_term in request.env['account.payment.term'].search([('active', '=', True)])]
 
+    '''
+        Get all banks
+    '''
+    def get_banks(self):
+        banks = [
+            {
+                'id': bank.id,
+                'name': bank.display_name
+            } for bank in request.env['res.bank'].search([('active', '=', True)])
+        ]
+
+        return banks
+
+    '''
+    '''
+    def get_cheque_types(self):
+        return [
+            {
+                'id': type.id,
+                'name': type.display_name,
+                'isBank': type.is_bank,
+                'isCash': type.is_cash
+            } for type in request.env['res.bank.cheque.type'].search([])
+        ]
+
+    '''
+        Get bank payment types
+    '''
+    def get_bank_payment_types(self, journal_id=None):
+        return request.env['res.bank.payments.type'].get_bank_payments_type(journal_id)
+
     '''
         Make JSON response to send
     '''
@@ -237,12 +297,15 @@ class Purchases(http.Controller):
         return self.make_gzip_response({
             'date': self.get_server_date(),
             'user': self.get_user(),
-            'currencies': self.get_currencies(),
+            'currencies': self.get_currencies_from_journal(),
             'journals': self.get_journals(),
             'suppliers': self.get_suppliers(),
             'products': self.get_products(kw.get('mode')),
             'pickingTypes': self.get_picking_types(),
-            'paymentTerms': self.get_payment_terms()
+            'paymentTerms': self.get_payment_terms(),
+            'banks': self.get_banks(),
+            'bankPaymentTypes': self.get_bank_payment_types(),
+            'chequeTypes': self.get_cheque_types()
         })
 
     '''

+ 2 - 1
package.json

@@ -24,7 +24,7 @@
 		"vue-loader": "^12.2.2",
 		"vue-template-compiler": "^2.4.1",
 		"webpack": "^3.3.0",
-		"webpack-livereload-plugin": "^0.11.0"
+		"webpack-livereload-plugin": "^1.0.0"
 	},
 	"dependencies": {
 		"axios": "^0.17.1",
@@ -32,6 +32,7 @@
 		"vue": "^2.4.1",
 		"vue-form-wizard": "^0.7.0",
 		"vue-js-modal": "^1.3.1",
+		"vue2-datepicker": "^2.6.1",
 		"vuex": "^2.3.1"
 	}
 }

+ 11 - 10
src/App.vue

@@ -5,10 +5,9 @@
                 supplier-step
             tab-content(:title="mode === 'purchase' ? 'Qué productos comprarás?' : 'En que gastarás?'" :before-change='checkCart')
                 product-step
-            tab-content(title='Cómo quieres pagar?')
-                payment-method-step
-            tab-content(title='Qué monto vas a pagar?' :before-change='checkAmountReceived')
-                payment-amount-step
+            tab-content(title='Cómo quieres pagar?' :before-change='checkAmountReceived')
+                payment-step
+        loading-overlay(:show='isLoading')
 </template>
 
 <script>
@@ -17,10 +16,11 @@
     import { FormWizard, TabContent } from 'vue-form-wizard'
     import 'vue-form-wizard/dist/vue-form-wizard.min.css'
 
-    import SupplierStep from '@/components/steps/Supplier'
-    import ProductStep from '@/components/steps/Product'
-    import PaymentMethodStep from '@/components/steps/PaymentMethod'
-    import PaymentAmountStep from '@/components/steps/PaymentAmount'
+    import SupplierStep from '@/components/steps/SupplierStep'
+    import ProductStep from '@/components/steps/ProductStep'
+    import PaymentStep from '@/components/steps/PaymentStep'
+
+    import { LoadingOverlay } from '@/components/common'
 
     export default {
         components: {
@@ -28,10 +28,11 @@
             TabContent,
             SupplierStep,
             ProductStep,
-            PaymentMethodStep,
-            PaymentAmountStep
+            PaymentStep,
+            LoadingOverlay
         },
         computed: mapGetters([
+            'isLoading',
             'isProcessing',
             'state',
             'mode'

+ 2 - 1
src/components/common/Card.vue

@@ -57,7 +57,8 @@
         position: relative
         &.selected-card
             transition-duration: 300ms
-            border-bottom: 3px solid $app-main-color
+            // border-bottom: 3px solid $app-main-color
+            border: 2px solid $app-main-color
         &:hover
             cursor: pointer
         .card-title

+ 18 - 9
src/components/common/CardGrid.vue

@@ -1,16 +1,15 @@
 <template lang="pug">
     .card-grid-wrapper
-        .card-grid-loading(v-if='loading')
-            spinner(type='wave')
-        .card-grid(v-else)
+        .card-grid
             add-card(v-if='canAdd' @onClickAdd='onClickAdd')
             card(v-for='item in items' :key='item.id' :title='item.name' :image='item.imageMedium' :isSelected='item.id === selectedId' :details='computeDetails(item)' :options='defaultOptions.currency' @onClick='onClickCard(item)')
+        .no-items(v-show='!items || items.length == 0')
+            p No hay items
 </template>
 
 <script>
     import AddCard from '@/components/common/AddCard'
     import Card from '@/components/common/Card'
-    import Spinner from '@/components/common/Spinner'
 
     export default {
         props: {
@@ -37,8 +36,7 @@
         },
         components: {
             AddCard,
-            Card,
-            Spinner
+            Card
         },
         watch: {
             options(value) {
@@ -131,12 +129,23 @@
         height: calc(100% - 50px)
         margin-top: 10px
         overflow-y: auto
-        .card-grid-loading
+        &::-webkit-scrollbar
+            width: 2px
+            background: #f5f5f5
+        &::-webkit-scrollbar-thumb
+            background: #7c7bad
+        &::-webkit-scrollbar-track
+            -webkit-box-shadow: inset 0 0 6px #d3d3d3
+            background: #f5f5f5
+        .card-grid
+            width: 100%
+        .no-items
             width: 100%
             height: 100%
             display: flex
             align-items: center
             justify-content: center
-        .card-grid
-            width: 100%
+            p
+                color: #9e9e9e
+                font-size: 11pt
 </style>

+ 8 - 0
src/components/common/Cart.vue

@@ -118,6 +118,14 @@
             height: calc(100% - 100px)
             overflow-y: auto
             overflow-x: hidden
+            &::-webkit-scrollbar
+                width: 2px
+                background: #f5f5f5
+            &::-webkit-scrollbar-thumb
+                background: #7c7bad
+            &::-webkit-scrollbar-track
+                -webkit-box-shadow: inset 0 0 6px #d3d3d3
+                background: #f5f5f5
             .cart-items
                 width: 100%
                 padding: 0

+ 210 - 0
src/components/common/DropdownSearcher.vue

@@ -0,0 +1,210 @@
+<template lang="pug">
+    .searcher
+        span.input-icon.fa.fa-search(
+            ref='searchSpan'
+            @click='onClickOptions'
+        )
+        input.search-input(
+            autofocus
+            v-model='search'
+            :placeholder='placeholder'
+        )
+        .dropdown-options(
+            ref='dropdownOptions'
+            :class="{'input-show': showOptions }"
+        )
+            ul.input-options
+                li.input-option(
+                    v-for='option in getOptions()'
+                    :key='option.id'
+                    @click='onSelectOption(option)'
+                ) 
+                    h2 {{ option.name }}
+</template>
+
+<script>
+    export default {
+        props: {
+            placeholder: {
+                type: String,
+                default: ''
+            },
+            autofocus: {
+                type: Boolean,
+                default: false
+            },
+            items: {
+                type: Array,
+                default: [],
+                required: true
+            },
+            keys: {
+                type: Array,
+                default: [],
+                required: true
+            }
+        },
+        watch: {
+            search(value, lastValue) {
+                value = value.trim()
+
+                if (!value && value.length != lastValue.length) {
+                    this.selectedOption = null
+                }
+
+                this.showOptions = !!value && !this.selectedOption
+
+                this.performSearch(value)
+            }
+        },
+        methods: {
+            getOptions() {
+                return this.results.length == 0 ? this.items : this.results
+            },
+            performSearch(value) {
+                this.results = []
+
+                if (this.selectedOption) {
+                    return
+                }
+                
+                for (let item of this.items) {
+                    for (let field in item) {
+                        if (typeof item[field] !== 'string') {
+                            continue
+                        }
+
+                        if (this.keys.length !== 0 && this.keys.indexOf(field) === -1) {
+                            continue
+                        }
+
+                        if (item[field].toLowerCase().indexOf(value.toLowerCase()) !== -1) {
+                            this.results.push(item)
+                            break
+                        }
+                    }
+                }
+            },
+            hideOptions() {
+                this.showOptions = false
+            },
+            onClickOptions() {
+                this.showOptions = !this.showOptions || !!this.search
+            },
+            onSelectOption(item) {
+                this.selectedOption = item
+
+                this.search = item.name
+                this.results = []
+                
+                this.$emit('onSelect', item)
+            },
+            onClickOutside(e) {
+                let searchSpan = this.$refs.searchSpan
+
+                if (!searchSpan) {
+                    return
+                }
+
+                let target = e.target
+
+                if (target === searchSpan) {
+                    return
+                }
+
+                let el = this.$refs.dropdownOptions
+
+                if (el !== target && !el.contains(target))  {
+                    this.hideOptions()
+                }
+            },
+            onKeyUp(e) {
+                if (e.code === 'ArrowUp') {
+                    // TODO: move selection up
+                }
+
+                if (e.code === 'ArrowDown') {
+                    // TODO: move selection down
+                }
+            },
+
+        },
+        created() {
+            document.addEventListener('click', this.onClickOutside)
+            document.addEventListener('keyup', this.onKeyUp)
+        },
+        destroyed() {
+            document.removeEventListener('click', this.onClickOutside)
+            document.removeEventListener('keyup', this.onKeyUp)
+        },
+        data() {
+            return {
+                search: '',
+                results: [],
+                selectedOption: null,
+                showOptions: false
+            }
+        }
+    }
+</script>
+
+<style lang="sass">
+    @import '../../assets/variables'
+    .searcher
+        width: 100%
+        height: 35px
+        position: relative
+        .input-icon
+            position: absolute
+            top: 10px
+            right: 10px
+            font-size: 12pt
+            color: $app-dark-color
+            &:hover
+                cursor: pointer
+        .search-input
+            width: 100%
+            height: 100%
+            border-radius: 0
+            font-size: 12pt
+            font-weight: normal
+            padding-right: 35px
+        .dropdown-options
+            width: 100%
+            height: 150px
+            display: none
+            position: absolute
+            background: $app-light-color
+            border: 1px solid $app-separator-color
+            box-shadow: 0 3px 5px $app-separator-color
+            z-index: 10
+            top: 35px
+            left: 0
+            right: 0
+            bottom: -325px
+            padding: 0
+            animation-duration: 500ms
+            overflow-y: auto
+            &.input-show
+                display: block
+            .input-options
+                padding-left: 0
+                .input-option
+                    height: 35px
+                    display: block
+                    text-align: left
+                    margin-top: 5px
+                    padding-top: 5px
+                    font-size: 10pt
+                    font-weight: normal
+                    border-bottom: 1px solid $app-border-color
+                    &:last-child
+                        margin-bottom: 10px
+                    &:hover
+                        border-bottom: 2px solid $app-main-color
+                        cursor: pointer
+                    h2
+                        font-size: 10pt
+                        font-weight: normal
+                        margin: 0 5px
+</style>

+ 279 - 0
src/components/common/InputDropdown.vue

@@ -0,0 +1,279 @@
+<template lang="pug">
+    div
+        .input-group
+            .input-group-button(v-if='hasPrefix()')
+                button(type='button') {{ prefix }}
+            input.input-formatted(
+                v-model='formattedValue'
+                type='text'
+                :disabled='!editable'
+                :autofocus='focus'
+            )
+            .input-group-button(v-if='hasSuffix()')
+                button(
+                    type='button'
+                    @click='onShowOptions()'
+                    ref='suffixButton'
+                ) {{ suffix }}
+                    span.caret(:style="{'display': hasOptions() ? 'inline-block' : 'none'}")
+                ul.dropdown(
+                    :style="{'display': isShowOptions ? 'block' : 'none'}"
+                    ref='suffixDropdown'
+                )
+                    li(
+                        v-for='(option, index) in options'
+                        :key='index'
+                    )
+                        a(@click='onClickOption(option)') {{ option }}
+</template>
+
+<script>
+    export default {
+        props: {
+            value: {
+                type: Number,
+                default: 0
+            },
+            format: {
+                type: String,
+                default: 'text'
+            },
+            editable: {
+                type: Boolean,
+                default: true
+            },
+            focus: {
+                type: Boolean,
+                default: false
+            },
+            prefix: {
+                type: String,
+                default: ''
+            },
+            suffix: {
+                type: String,
+                default: ''
+            },
+            options: {
+                type: Array,
+                default: []
+            }
+        },
+        computed: {
+            formattedValue: {
+                get() {
+                    let value = this.value
+
+                    if (this.format === 'number') {
+                        value = this.formatValue(value)
+                        value = !!this.value ? value : value.replace(/\d/, '')
+                        value = value.length === 0 ? 0 : value
+                    }
+
+                    return value
+                },
+                set(value) {
+                    if (this.format === 'number') {
+                        value = this.unformatValue(value)
+                    }
+
+                    this.value = value
+
+                    this.onChangeValue(value)
+                }
+            }
+        },
+        methods: {
+            formatValue(value, options) {
+                value = value.toString()
+
+                if (!(options instanceof Object)) {
+                    options = {}
+                }
+
+                options.thousandsSeparator = options.thousandsSeparator || '.'
+                options.decimalPlaces = options.decimalPlaces >= 0 || options.decimalPlaces <= 2 ? options.decimalPlaces : 2
+                options.decimalSeparator = options.decimalSeparator || ','
+                options.decimalZeros = !!options.decimalZeros
+
+                if (!!(`${options.thousandsSeparator}${options.decimalSeparator}`).replace(/\.,|,\./g, '')) {
+                    throw new Error('Same thousands and decimal separator is not allowed')
+                }
+
+                value = value.split('.')
+
+                value[0] = value[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, `$1${options.thousandsSeparator}`)
+
+                if (!!value[1]) {
+                    value[1] = Number.parseFloat(`1.${value[1]}e${options.decimalPlaces}`)
+                    value[1] = Math.round(value[1]).toString().replace(/^1/, '')
+                }
+
+                value = value.join(options.decimalSeparator)
+
+                if (!options.decimalZeros) {
+                    value = value.replace(/([\.|,]\d)0$/, '$1')
+                }
+
+                return value
+            },
+            unformatValue(value) {
+                value = value.replace(/[\.|,](\d{0,2}$)/, '?$1').split(/\?/)
+                value[0] = value[0].replace(/[^0-9]/g, '')
+                value = Number.parseFloat(value.join('.')) || 0
+
+                return value
+            },
+            hideOptions() {
+                this.isShowOptions = false
+            },
+            onChangeValue(value) {
+                this.$emit('onChangeValue', value)
+            },
+            hasPrefix() {
+                return !!this.prefix && this.prefix.length !== 0
+            },
+            hasSuffix() {
+                return !!this.suffix && this.suffix.length !== 0
+            },
+            hasOptions() {
+                return this.options.length !== 0
+            },
+            onShowOptions() {
+                if (!this.hasOptions()) {
+                    return
+                }
+                
+                this.isShowOptions = !this.isShowOptions
+            },
+            onClickOutside(e) {
+                let suffixButton = this.$refs.suffixButton
+
+                if (!suffixButton) {
+                    return
+                }
+
+                let target = e.target
+
+                if (target === suffixButton) {
+                    return
+                }
+
+                let el = this.$refs.suffixDropdown
+                
+                if (el !== target && !el.contains(target)) {
+                    this.hideOptions()
+                }
+            },
+            onClickOption(selectedOption) {
+                this.hideOptions()
+                this.$emit('onClickOption', selectedOption)
+            }
+        },
+        created() {
+            document.addEventListener('click', this.onClickOutside)
+        },
+        destroyed() {
+            document.removeEventListener('click', this.onClickOutside)
+        },
+        data() {
+            return {
+                value: '',
+                isShowOptions: false
+            }
+        }
+    }
+</script>
+
+<style lang="sass">
+    @import '../../assets/variables'
+
+    .input-group
+        position: relative
+        width: 100%
+        display: table
+        border-collapse: separate
+        .input-formatted
+            position: relative
+            width: 100%
+            height: 35px
+            float: left
+            z-index: 2
+            display: table-cell
+            margin-bottom: 0
+            border-radius: 0
+            font-size: 12pt
+            padding: 6px 12px
+            &:focus
+                z-index: 3
+        .input-group-button
+            position: relative
+            font-size: 0
+            width: 1%
+            white-space: nowrap
+            vertical-align: middle
+            display: table-cell
+            &:first-child
+                & > button
+                    margin-right: -1px
+            &:last-child
+                & > button
+                    margin-left: -1px
+            button
+                height: 35px
+                display: inline-block
+                margin-bottom: 0
+                text-align: center
+                vertical-align: middle
+                white-space: nowrap
+                border: 1px solid #ccc
+                border-radius: 0
+                box-shadow: none
+                background: $app-main-color
+                color: #fff
+                z-index: 2
+                position: relative
+                user-select: none
+                &:focus
+                    outline: 0 !important
+                    border: 1px solid #ccc
+                    box-shadow: none
+                &:caret
+                    display: inline-block
+                    width: 0
+                    height: 0
+                    margin-left: 0
+                    vertical-align: middle
+                    border-top: 4px dashed
+                    border-right: 4px solid transparent
+                    border-left: 4px solid transparent
+            .dropdown
+                position: absolute
+                top: 100%
+                float: left
+                left: auto
+                right: 0
+                list-style: none
+                text-align: left
+                border: 1px solid #ccc
+                background-color: #fff
+                background-clip: padding-box
+                min-width: 160px
+                padding: 5px 0
+                margin: 2px 0 0
+                z-index: 1000
+                font-size: 10pt
+                & > li > a
+                    height: 35px
+                    display: block
+                    padding: 3px 20px
+                    clear: both
+                    font-weight: normal
+                    line-height: 2.1
+                    white-space: nowrap
+                    color: #333
+                    border-bottom: 1px solid #e5e5e5
+                    &:hover, &:focus
+                        text-decoration: none
+                        border-bottom: 2px solid #7c7bad
+</style>

+ 34 - 0
src/components/common/InputSelect.vue

@@ -0,0 +1,34 @@
+<template lang="pug">
+    div
+        select.input-select(@change='onSelect')
+            option(
+                v-for='o in options'
+                :value='o.id'
+            ) {{ o.name }}
+</template>
+
+<script>
+    export default {
+        props: {
+            selected: {
+                type: Object,
+                default: ''
+            },
+            options: {
+                type: Array,
+                default: []
+            }
+        },
+        methods: {
+            onSelect(e) {
+                this.$emit('onSelect', e.target.value)
+            }
+        }
+    }
+</script>
+
+<style lang="sass">
+    .input-select
+        width: 100%
+        height: 35px
+</style>

+ 48 - 0
src/components/common/LoadingOverlay.vue

@@ -0,0 +1,48 @@
+<template lang="pug">
+    transition(name='fade')
+        .loading-overlay(v-show='show')
+            spinner(type='wave')
+            h2.loading-text Por favor, espere...
+</template>
+
+<script>
+    import Spinner from './Spinner'
+
+    export default {
+        props: {
+            show: {
+                type: Boolean,
+                default: false
+            }
+        },
+        components: {
+            Spinner
+        }
+    }
+</script>
+
+<style lang="sass">
+    .loading-overlay
+        display: flex
+        justify-content: center
+        align-items: center
+        flex-direction: column
+        width: 100%
+        height: 100%
+        background: rgba(0, 0, 0, 0.8)
+        position: fixed
+        top: 0
+        left: 0
+        z-index: 9999
+        .spinner-wave
+            margin: auto !important
+            .spinner-rect
+                background: #fff !important
+        .loading-text
+            color: #fff
+            font-size: 8pt
+    .fade-enter-active, .fade-leave-active
+        transition: opacity .8s
+    .fade-enter, .fade-leave-to
+        opacity: 0
+</style>

+ 71 - 0
src/components/common/SwitchButtonInput.vue

@@ -0,0 +1,71 @@
+<template lang="pug">
+    .switch-button-input
+        button.switch-option(
+            id='primary'
+            :value='primaryValue'
+            :class="{'selected-option': selectedOption}"
+            @click.prevent='onChange'
+        ) {{ primaryValue }}
+        button.switch-option(
+            id='secondary'
+            :value='secondaryValue'
+            :class="{'selected-option': !selectedOption}"
+            @click.prevent='onChange'
+        ) {{ secondaryValue }}
+</template>
+
+<script>
+    export default {
+        props: {
+            primaryValue: {
+                type: String,
+                required: true
+            },
+            secondaryValue: {
+                type: String,
+                required: true
+            },
+            selectedValue: {
+                type: String,
+                default: null
+            }
+        },
+        methods: {
+            onChange(e) {
+                this.selectedOption = e.target.id === 'primary'
+                this.selectedValue = e.target.value
+
+                this.$emit('onChange', this.selectedOption)
+            }
+        },
+        data() {
+            return {
+                selectedOption: true
+            }
+        },
+        mounted() {
+            this.selectedOption = this.selectedValue === this.primaryValue
+        }
+    }
+</script>
+
+<style lang="sass">
+    @import '../../assets/variables'
+
+    .switch-button-input
+        .switch-option
+            width: 50%
+            height: 35px
+            border: 1px solid transparent
+            border-color: #adadad
+            box-shadow: none
+            border-radius: 0
+            background: $app-bg-color
+            &:hover
+                background: $app-light-color
+            &.selected-option
+                background: $app-main-color
+                box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125)
+                border-color: $app-main-color
+                color: $app-bg-color
+</style>

+ 13 - 3
src/components/common/index.js

@@ -1,13 +1,23 @@
 import CardGrid from './CardGrid'
 import Cart from './Cart'
+import DropdownSearcher from './DropdownSearcher'
+import InputDropdown from './InputDropdown'
+import InputSelect from './InputSelect'
+import LoadingOverlay from './LoadingOverlay'
 import Searcher from './Searcher'
-import Ticket from './Ticket'
 import Spinner from './Spinner'
+import SwitchButtonInput from './SwitchButtonInput'
+import Ticket from './Ticket'
 
 export {
     CardGrid,
     Cart,
+    DropdownSearcher,
+    InputDropdown,
+    InputSelect,
+    LoadingOverlay,
     Searcher,
-    Ticket,
-    Spinner
+    Spinner,
+    SwitchButtonInput,
+    Ticket
 }

+ 258 - 0
src/components/modals/BankPaymentModal.vue

@@ -0,0 +1,258 @@
+<template lang="pug">
+    modal(
+        name='payment-bank-modal'
+        adaptive='true'
+        width='800px'
+        height='auto'
+        transition='nice-modal-fade'
+        :classes="['v--modal', 'payment-bank-modal']"
+        @before-close='beforeClose'
+    )
+        form-wizard(
+            title='Pago Bancario'
+            subtitle=''
+            color='#7c7bad'
+            ref='wizard'
+        )
+            tab-content(
+                title='Qué tipo de operación es?'
+                :beforeChange='checkJournalSelectionStep'
+            )
+                card-grid(
+                    :items='journals'
+                    @onSelect='selectBankJournal'
+                )
+            tab-content(title='Qué detalles necesita?')
+                form.payment-details-form(v-if='selectedJournal')
+                    .form-item(v-for='(field, index) in selectedJournal.fieldsAllowed' :key='index')
+                        label.form-label {{ field.label }}
+                        input.form-input(
+                            v-if="field.string.typeField === 'char'"
+                            v-model='values[field.name]'
+                        )
+                        date-picker.form-input(
+                            v-else-if="field.string.typeField === 'date'"
+                            v-model='values[field.name]'
+                            input-class='form-input'
+                            lang='es'
+                            format='DD/MM/YYYY'
+                            :editable='false'
+                            :not-before="new Date()"
+                        )
+                        dropdown-searcher.form-input(
+                            v-else-if="field.string.typeField === 'many2one' && field.name === 'bank_id'"
+                            :items='banks'
+                            @onSelect='selectedItem => onSelectInDropdown(field.name, selectedItem.id)'
+                        )
+                        dropdown-searcher.form-input(
+                            v-else-if="field.string.typeField === 'many2one' && field.name === 'cheque_type_id'"
+                            :items='chequeTypes'
+                            @onSelect='selectedItem => onSelectInDropdown(field.name, selectedItem.id)'
+                        )
+            tab-content(title='De qué monto es la operación?')
+                form.payment-details-form
+                    .form-item
+                        label.form-label Monto del Pago
+                        //- input.form-input(v-model='amount')
+                        input-dropdown.form-input(
+                            format='number'
+                            :value='values.amount'
+                            @onChangeValue='onChangeAmount'
+                        )
+            template(
+                slot='footer'
+                slot-scope='props'
+            )
+                div(class='wizard-footer-left')
+                    wizard-button(
+                        v-if='!!props && props.activeTabIndex > 0'
+                        @click.native='props.prevTab()'
+                        :style='props.fillButtonStyle'
+                    ) Volver
+                    wizard-button(
+                        v-else
+                        @click.native='onCancel'
+                        :style='props.fillButtonStyle'
+                    ) Cancelar
+                div(class='wizard-footer-right')
+                    wizard-button(
+                        v-if='!props.isLastStep'
+                        class='wizard-footer-right'
+                        :style='props.fillButtonStyle'
+                        @click.native='goNext'
+                    ) Siguiente
+                    wizard-button(
+                        v-else
+                        class='wizard-footer-right finish-button'
+                        :style='props.fillButtonStyle'
+                        @click.native='onDone'
+                    ) {{ props.isLastStep ? 'Hecho' : 'Siguiente' }}
+</template>
+
+<script>
+    import { FormWizard, TabContent, WizardButton } from 'vue-form-wizard'
+    import DatePicker from 'vue2-datepicker'
+    import { CardGrid, DropdownSearcher, InputDropdown } from '../common'
+
+    export default {
+        props: {
+            initialAmount: {
+                type: Number,
+                required: true
+            },
+            journals: {
+                type: Array,
+                required: true
+            },
+            hasSelectedJournal: {
+                type: Boolean,
+                required: true
+            },
+            selectedJournal: {
+                type: Boolean,
+                required: true
+            },
+            banks: {
+                type: Array,
+                required: true
+            },
+            chequeTypes: {
+                type: Array,
+                required: true
+            },
+            show: {
+                type: Boolean,
+                required: true
+            }
+        },
+        computed: {
+            amount: {
+                get() {
+                    return this.values.amount
+                },
+                set(value) {
+                    this.values.amount = value
+                }
+            }
+        },
+        components: {
+            FormWizard,
+            TabContent,
+            WizardButton,
+            DropdownSearcher,
+            CardGrid,
+            DatePicker,
+            InputDropdown
+        },
+        watch: {
+            show(value) {
+                this.values = {}
+                this.values.amount = this.initialAmount
+
+                if (!value) {
+                    this.$modal.hide('payment-bank-modal')
+                    return
+                }
+
+                this.$modal.show('payment-bank-modal')
+            },
+            initialAmount(value) {
+                this.values.amount = value
+            }
+        },
+        methods: {
+            beforeClose(e) {
+                if (this.show) {
+                    e.stop()
+                }
+            },
+            goNext() {
+                if (this.journalStepIncomplete()) {
+                    this.$emit('onNotify', 'El tipo de operación seleccionado no está configurado')
+                    return
+                }
+
+                if (this.fieldsStepIncomplete()) {
+                    this.$emit('onNotify', 'Algunos campos requeridos están incompletos')
+                    return
+                }
+
+                if (this.amountStepIncomplete()) {
+                    this.$emit('onNotify', 'El monto no es válido')
+                    return
+                }
+
+                this.$refs.wizard.nextTab()
+            },
+            journalStepIncomplete() {
+                if (!this.$refs.wizard) {
+                    return
+                }
+
+                return this.$refs.wizard.activeTabIndex == 0 && !this.selectedJournal || !this.selectedJournal.fieldsAllowed.length
+            },
+            fieldsStepIncomplete() {
+                let completed = false;
+
+                for (let field of this.selectedJournal.fieldsAllowed) {
+                    if (field.string.required) {
+                        completed = !!this.values[field.name]
+                    }
+                }
+
+                if (!this.$refs.wizard) {
+                    return
+                }
+
+                return this.$refs.wizard.activeTabIndex == 1 && !completed
+            },
+            amountStepIncomplete() {
+                return false
+            },
+            selectBankJournal(journal) {
+                this.$emit('onSelectBankJounal', journal.id)
+            },
+            onSelectInDropdown(fieldName, selectedId) {
+                this.values[fieldName] = selectedId
+            },
+            onChangeAmount(value) {
+                this.values.amount = value
+            },
+            onDone() {
+                this.$emit('onDone', this.values)
+            },
+            onCancel() {
+                this.$emit('onCancel')
+            }
+        },
+        mounted() {
+            console.log(this.$refs)
+        },
+        data() {
+            return {
+                values: {}
+            }
+        }
+    }
+</script>
+
+<style lang="sass">
+    .payment-bank-modal
+        padding: 0 !important
+        &::before
+            content: ''
+            display: block
+            position: absolute
+            background-size: cover
+            filter: blur(3px)
+            z-index: -1
+        .wizard-tab-content
+            padding-bottom: 50px !important
+            .wizard-tab-container
+                justify-content: center !important
+                align-items: center !important
+                .payment-details-form
+                    width: 100%
+                    .form-input
+                        color: #4c4c4c
+</style>

+ 303 - 0
src/components/steps/PaymentStep.vue

@@ -0,0 +1,303 @@
+<template lang="pug">
+    .purchase-step
+        ticket(
+            :companyName='companyName' 
+            :items='cartItems'
+            :total='amountToPay'
+            :defaultCurrency='selectedCurrency'
+            :customerName='selectedSupplierName'
+        )
+        form
+            //- input para forma de pago
+            .form-item
+                label.form-label Forma de Pago
+                switch-button-input.form-input(
+                    primary-value='Contado'
+                    secondary-value='Crédito'
+                    :selected-value="paymentType === 'cash' ? 'Contado' : 'Crédito'"
+                    @onChange="changePaymentType($event ? 'cash' : 'credit')"
+                )
+            //- input para condiciones de pago en caso de pago a crédito
+            .form-item(v-show="paymentType === 'credit'")
+                select.form-input.input-only(v-model='paymentTermId')
+                    option(
+                        :value='term.id' 
+                        v-for='term in paymentTerms'
+                        v-if="term.lines.length > 0 && (term.lines[0].days !== 0 || term.lines[0].value !==  'balance')"
+                    ) {{ term.name }}
+            //- input para monto de pago
+            .form-item
+                label.form-label Monto a Pagar
+                input-dropdown.form-input(
+                    format='number'
+                    :value='amountToPay'
+                    :editable='false'
+                    :suffix='selectedCurrencySymbol'
+                    :options='currencySymbols'
+                    @onChangeValue='onChangeValue'
+                    @onClickOption='changeCurrency'
+                )
+                //- .other_exchanges
+                //-     h2 En otras monedas
+                //-     ul
+                //-         li(v-for='value in amountToPayInOtherCurrencies') {{ value.amount | currency(value.currency) }}
+            //- input para el monto recibido
+            .form-item
+                label.form-label Monto Entregado
+                input-dropdown.form-input(
+                    ref='initialAmount'
+                    format='number'
+                    :value='initialPayment'
+                    :suffix='paymentMethod'
+                    :options='paymentMethods'
+                    :focus='true'
+                    @onClickOption='changePaymentMethod'
+                    @onChangeValue='changeAmountReceived($event)'
+                )
+            //- input para el vuelto del pago en caso de pago en efectivo
+            div(v-show="paymentType === 'cash'")
+                hr
+                .form-item
+                    label.form-label Vuelto
+                    input-dropdown.form-input(
+                        format='number'
+                        :value='amountResidual'
+                        :editable='false'
+                    )
+            //- input para el monto de cuotas calculadas en caso de pago a crédito
+            .form-item-table(v-show="paymentType === 'credit'")
+                table
+                    thead
+                        tr
+                            th Monto a Pagar
+                            th Fecha de Pago
+                    tbody
+                        tr(v-for='line in paymentLines')
+                            td {{ line.total | currency(...selectedCurrency) }}
+                            td {{ line.date }}
+        //- bank-payment-modal(
+        //-     :initialAmount='amountToPay'
+        //-     :journals='bankJournals'
+        //-     :selectedJournal='selectedJournal'
+        //-     :banks='banks'
+        //-     :chequeTypes='chequeTypes'
+        //-     :show='showBankPayment'
+        //-     @onSelectBankJounal='selectJournal'
+        //-     @onNotify='notify'
+        //-     @onDone='endBankPayment'
+        //-     @onCancel='cancelBankPayment'
+        //- )
+</template>
+
+<script>
+    import { mapGetters, mapActions} from 'vuex'
+    import { Ticket, SwitchButtonInput, InputDropdown } from '../common'
+    import BankPaymentModal from '../modals/BankPaymentModal'
+
+    export default {
+        components: {
+            Ticket,
+            SwitchButtonInput,
+            InputDropdown,
+            BankPaymentModal
+        },
+        computed: {
+            paymentTermId: {
+                get() {
+                    return (this.selectedPaymentTerm && this.selectedPaymentTerm.id) || -1
+                },
+                set(value) {
+                    this.selectPaymentTerm(value)
+
+                    if (this.paymentType === 'credit') {
+                        this.computePaymentLines()		
+                    }
+                }
+            },
+            ...mapGetters([
+                'companyName',
+                'amountToPay',
+                // 'amountToPayInOtherCurrencies',
+                'initialPayment',
+                'amountResidual',
+                'paymentLines',
+                'cartItems',
+                'paymentType',
+                'paymentTerms',
+                'paymentMethod',
+                'selectedCurrencySymbol',
+                'showBankPayment',
+                'hasBankJournalSelected',
+                'selectedCustomerName',
+                'selectedCurrency',
+                'selectedJournal',
+                'selectedBankPaymentType',
+                'selectedChequeType',
+                'selectedPaymentTerm',
+                'currencies',
+                'currencySymbols',
+                'journals',
+                'bankJournals',
+                'paymentTerms',
+                'paymentMethods',
+                'banks',
+                'bankPaymentTypes',
+                'chequeTypes'
+            ])
+        },
+        watch: {
+            paymentType() {
+                this.focusInitialPayment()
+            },
+            paymentTerms() {
+                this.focusInitialPayment()
+            },
+            selectedCurrency() {
+                this.focusInitialPayment()
+            },
+            paymentMethod() {
+                this.focusInitialPayment()
+            }
+        },
+        methods: {
+            focusInitialPayment() {
+                this.$nextTick(() => this.$refs.initialAmount.$el.children[0].children[0].focus())
+            },
+            endBankPayment(data) {
+                this.changeBankPaymentData(data)
+                this.toggleBankPayment()
+            },
+            cancelBankPayment() {
+                this.toggleBankPayment()
+                this.changePaymentMethod('Efectivo')
+                this.autoSelectJournal()
+            },
+            changeAmountReceived(amount) {
+                this.changeInitialPayment(amount)
+            },
+            ...mapActions([
+                'autoSelectJournal',
+                'changeCurrency',
+                'selectPaymentTerm',
+                'selectJournal',
+                'changePaymentType',
+                'changePaymentMethod',
+                'changeBankPaymentType',
+                'changeChequeType',
+                'changeBank',
+                'changeInitialPayment',
+                'changeBankPaymentData',
+                'computePaymentLines',
+                'toggleBankPayment',
+                'notify'
+            ])
+        }
+    }
+</script>
+
+<style lang="sass">
+    @import '../../assets/variables'
+
+    .purchase-step
+        width: 100%
+        height: calc(100% - 50px)
+        padding-bottom: 50px
+        display: flex
+        form
+            width: calc(100% - 450px)
+            height: 100%
+            margin-right: 50px
+            padding: 25px
+            background: $app-bg-color
+            .form-item
+                width: 100%
+                height: 35px
+                margin-bottom: 15px
+                & > .form-label, > .form-input
+                    display: inline-block
+                    vertical-align: top
+                .form-label
+                    width: 200px
+                    height: 35px
+                    font-size: 12pt
+                    line-height: 30px
+                    color: $app-dark-color
+                .form-input
+                    width: 400px
+                    height: 35px
+                    font-size: 12pt
+                    border-radius: 0
+                    &.input-only
+                        margin-left: 200px
+                        margin-bottom: 15px
+                .form-item-option
+                    display: inline-block
+                    input
+                        width: 20px
+                        height: 20px
+                    label
+                        font-size: 12pt
+                        margin: 0 35px 15px 5px
+                .other_exchanges
+                    width: 145px
+                    height: 150px
+                    border: 1px solid #e0e0e0
+                    display: inline-block
+                    position: relative
+                    bottom: calc(50% + 40px)
+                    margin-left: 25px
+                    &:after
+                        content: ''
+                        position: absolute
+                        left: 0
+                        top: 50%
+                        width: 0
+                        height: 0
+                        border: 16px solid transparent
+                        border-right-color: #e0e0e0
+                        border-left: 0
+                        margin-top: -16px
+                        margin-left: -16px
+                    h2
+                        font-size: 8pt
+                        margin: 10px 0 0
+                        color: #d3d3d3
+                        text-align: center
+                    ul
+                        list-style: none
+                        margin: 0
+                        padding: 10px
+                        font-size: 12pt
+                        text-align: center
+                        li
+                            margin-bottom: 10px
+                            border-bottom: 1px solid #eeeeee
+            .form-item-table
+                width: 100%
+                height: 200px
+                border: 1px solid #e0e0e0
+                overflow-y: auto
+                table
+                    width: 100%
+                    thead
+                        background-color: #7c7bad
+                        color: #fff
+                        th
+                            line-height: 35px
+                            padding-left: 10px
+                        th:nth-child(1)
+                            width: 200px
+                        th:nth-child(2)
+                            width: 200px
+                    tbody
+                        td
+                            height: 35px
+                            padding-left: 10px
+                            line-height: 30px
+                            font-size: 11pt
+
+                        td:nth-child(1)
+                            width: 200px
+                        td:nth-child(2)
+                            width: 200px
+</style>

+ 1 - 1
src/components/steps/Product.vue → src/components/steps/ProductStep.vue

@@ -2,7 +2,7 @@
     .purchase-step
         .products-selector
             searcher(:items='products' :keys="['name', 'displayName', 'ean13']" @onSearch='filterProducts')
-            card-grid(:items='visibleProducts' :loading='loadingProducts' :details="['price:c']" :options='selectedCurrency' @onSelect='selectProduct')
+            card-grid(:items='visibleProducts' :details="['price:c']" :options='selectedCurrency' @onSelect='selectProduct')
             variant-modal(:items='productWithVariant && productWithVariant.variants' :show='!!productWithVariant' @onSelect='selectProduct' @onClose='selectProduct')
             price-modal(:item='itemPriced' :options='selectedCurrency' :show='!!itemPriced' @onAccept='changePrice' @onCancel='changePrice')
         cart(:items='cartItems' @onIncrementQty='addToCart' @onChangePrice='changePrice' @onUndoPrice='undoPrice' @onDecrementQty='decreaseFromCart' @onDeleteItem='removeFromCart' @onTotalComputed='updateCartTotal' :options='selectedCurrency')

+ 2 - 3
src/components/steps/Supplier.vue → src/components/steps/SupplierStep.vue

@@ -3,7 +3,7 @@
         .supplier-selection-step
             .supplier-selector
                 searcher(:items='suppliers' :keys="['name', 'displayName', 'phone', 'mobile', 'email']" @onSearch='filterSuppliers')
-                card-grid(:items='visibleSuppliers' :loading='loadingSuppliers' @onSelect='selectSupplier')
+                card-grid(:items='visibleSuppliers' @onSelect='selectSupplier')
             transition(name='slide-fade')
                 customer-form
 </template>
@@ -22,8 +22,7 @@
         },
         computed: mapGetters([
             'suppliers',
-            'visibleSuppliers',
-            'loadingSuppliers'
+            'visibleSuppliers'
         ]),
         methods: mapActions([
             'selectSupplier',

+ 17 - 75
src/store/app.js

@@ -5,97 +5,66 @@ import * as Urls from '../constants/resourcePaths'
 const state = {
     currentMode: Modes.PURCHASE,
     currentState: States.NONE,
+    footerButtonsVisibility: false,
+    loading: true
 }
 
 const getters = {
-    /**
-     * 
-     */
     mode() {
         return state.currentMode
     },
-    /**
-     * 
-     */
     isProcessing() {
         return state.currentState === States.PROCESSING
     },
-    /**
-     * 
-     */
     isDone() {
         return state.currentState === States.DONE
     },
-    /**
-     * 
-     */
     hasError() {
         return state.currentState === States.ERROR
     },
-    /**
-     * 
-     */
     state() {
         return state.currentState
+    },
+    isLoading() {
+        return state.loading
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setMode(state, payload) {
         state.currentMode = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setState(state, payload) {
         state.currentState = payload
+    },
+    toggleFooterButtonsVisibility(state) {
+        state.footerButtonsVisibility = !state.footerButtonsVisibility
+    },
+    setLoading(state, loading) {
+        state.loading = loading
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     initPurchase({ getters, commit, dispatch }, payload) {
         commit('setMode', payload || getters.mode)
 
-        const timeStarted = Date.now()
+        commit('setLoading', true)
+        
         return axios.get(Urls.INIT_PURCHASE_URL, {
             params: {
                 mode: getters.mode
             }
         }).then(response => {
-            commit('setState', States.NONE)
+            commit('setLoading', false)
             dispatch('explodeData', response.data)
-
-            const timeElapsed = Date.now() - timeStarted
-            dispatch('notify', 'Datos cargados en ' + (timeElapsed / 1000) + ' segundos')
         }).catch(error => console.log(error))
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     explodeData({ dispatch }, payload) {
         for (let key in payload) {
             dispatch(`init${key[0].toUpperCase()}${key.slice(1)}`, payload[key])
         }
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     createObject({ dispatch }, payload) {
         const data = {
             jsonrpc: '2.0',
@@ -110,17 +79,9 @@ const actions = {
             console.log(response)
         }).catch(error => console.log(error))
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     checkSupplier({ getters, dispatch}) {
         return !!getters.selectedSupplier || dispatch('notify', 'Necesitas seleccionar un proveedor para continuar')
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     checkCart({ getters, dispatch}) {
         for (let cartItem of getters.cartItems) {
             if (cartItem.price == 0) {
@@ -130,10 +91,6 @@ const actions = {
 
         return !!getters.cartItems.length || dispatch('notify', 'Necesitar agregar producto al carrito para continuar')
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     checkAmountReceived({ getters, dispatch }) {
         if (getters.paymentType == 'cash') {
             return getters.initialPayment >= getters.cartTotal || dispatch('notify', 'El monto recibido no puede ser menor al monto a pagar')
@@ -141,12 +98,8 @@ const actions = {
             return getters.initialPayment < getters.cartTotal || dispatch('notify', 'El monto recibido no puede ser igual o mayor al monto a pagar')
         }
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     createPurchase({ getters, commit, dispatch }) {
-        commit('setState', States.PROCESSING)
+        commit('setLoading', true)
 
         const data = {
             jsonrpc: '2.0',
@@ -169,17 +122,11 @@ const actions = {
         }
 
         return axios.post(Urls.PROCESS_PURCHASE_URL, data).then(response => {
-            commit('setState', States.DONE)
-
             dispatch('resetPurchase')
         }).catch(error => {
-            commit('setState', States.ERROR)
+            console.log(error)
         })
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     resetPurchase({ rootState, dispatch }) {
         for (let key in rootState) {
             if (!(rootState[key] instanceof Object)) {
@@ -191,15 +138,10 @@ const actions = {
 
         dispatch('initPurchase')
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     notify({ commit }, payload) {
         openerp.web.notification.do_warn('Atención', payload)
         return false
-    },
+    }
 }
 
 export default {

+ 18 - 12
src/store/index.js

@@ -3,15 +3,18 @@ import Vuex from 'vuex'
 
 import app from './app'
 
-import date from '@/store/modules/date'
-import user from '@/store/modules/user'
+import bank from '@/store/modules/bank'
+import bankPaymentType from '@/store/modules/bankPaymentType'
+import cart from '@/store/modules/cart'
+import chequeType from '@/store/modules/chequeType'
 import currency from '@/store/modules/currency'
+import date from '@/store/modules/date'
 import journal from '@/store/modules/journal'
-import supplier from '@/store/modules/supplier'
-import product from '@/store/modules/product'
-import cart from '@/store/modules/cart'
-import picking from '@/store/modules/picking'
 import payment from '@/store/modules/payment'
+import picking from '@/store/modules/picking'
+import product from '@/store/modules/product'
+import supplier from '@/store/modules/supplier'
+import user from '@/store/modules/user'
 
 Vue.use(Vuex)
 
@@ -19,15 +22,18 @@ const store = new Vuex.Store({
     ...app,
     strict: false,
     modules: {
-        date,
-        user,
+        bank,
+        bankPaymentType,
+        cart,
+        chequeType,
         currency,
+        date,
         journal,
-        supplier,
-        product,
-        cart,
+        payment,
         picking,
-        payment
+        product,
+        supplier,
+        user
     }
 })
 

+ 69 - 0
src/store/modules/bank.js

@@ -0,0 +1,69 @@
+const state = {
+    loadingBanks: false,
+    banks: [],
+    selectedBank: null,
+    showBankPayment: false
+}
+
+const getters = {
+    loadingBanks(state) {
+        return state.loadingBanks
+    },
+    banks(state) {
+        return state.banks
+    },
+    selectedBank(state) {
+        return state.selectedBank
+    },
+    showBankPayment(state) {
+        return state.showBankPayment
+    }
+}
+
+const mutations = {
+    setLoadingBanks(state, loading) {    
+        state.loadingBanks = !!loading
+    },
+    setBanks (state, payload) {
+        state.banks = payload
+    },
+    setSelectedBank(state, bankId) {
+        if (!bankId) {
+            return
+        }
+
+        state.selectedBank = state.banks.find(b => b.id === bankId)
+    },
+    toggleBankPayment(state) {
+        state.showBankPayment = !state.showBankPayment
+    }
+}
+
+const actions = {
+    initBanks ({ commit}, payload) {
+        commit('setBanks', payload)
+        commit('setLoadingBanks')
+    },
+    toggleBankPayment({ commit }) {
+        commit('toggleFooterButtonsVisibility')
+        commit('toggleBankPayment')
+    },
+    changeBank({ commit }, bankId) {
+        commit('setSelectedBank', bankId)
+    },
+    resetBank ({ getters, commit }) {
+        if (getters.isWired) {
+            commit('setLoadingBanks', true)
+            commit('setBanks', [])
+        }
+        
+        commit('setSelectedBank', null)
+    }
+}
+
+export default {
+    state,
+    getters,
+    actions,
+    mutations
+}

+ 69 - 0
src/store/modules/bankPaymentType.js

@@ -0,0 +1,69 @@
+const state = {
+    loadingBankPaymentTypes: false,
+    bankPaymentTypes: [],
+    selectedBankPaymentType: null
+}
+
+const getters = {
+    loadingBankPaymentTypes(state) {
+        return state.loadingBankPaymentTypes
+    },
+    bankPaymentTypes(state, getters) {
+        if (getters.selectedJournal && getters.selectedJournal.subtype) {
+            return state.bankPaymentTypes.filter(b => b.subtype === getters.selectedJournal.subtype)
+        }
+
+        return state.bankPaymentTypes
+    },
+    selectedBankPaymentType (state) {
+        return state.selectedBankPaymentType
+    }
+}
+
+const mutations = {
+    setLoadingBankPaymentTypes(state, loading) {
+        state.loadingBankPaymentTypes = !!loading
+    },
+    setBankPaymentTypes (state, bankPaymentTypes) {
+        state.bankPaymentTypes = bankPaymentTypes
+    },
+    setSelectedBankPaymentType (state, id) {
+        if (id) {
+            state.selectedBankPaymentType = this.getters.bankPaymentTypes.find(b => b.journalIds.indexOf(id) != -1)
+            return
+        }
+
+        if (state.bankPaymentTypes.length > 0) {
+            state.selectedBankPaymentType = this.getters.bankPaymentTypes[0]
+            return
+        }
+
+        state.selectedBankPaymentType = null
+    }
+}
+
+const actions = {
+    initBankPaymentTypes ({ commit }, payload) {
+        commit('setBankPaymentTypes', payload)
+        commit('setSelectedBankPaymentType')
+        commit('setLoadingBankPaymentTypes')
+    },
+    changeBankPaymentType({ commit }, id) {
+        commit('setSelectedBankPaymentType', id)
+    },
+    resetBankPaymentType ({ getters, commit }) {
+        if (getters.isWired) {
+            commit('setLoadingBankPaymentTypes', true)
+            commit('setBankPaymentTypes', [])
+        }
+        
+        commit('setSelectedBankPaymentType')
+    }
+}
+
+export default {
+    state,
+    getters,
+    actions,
+    mutations
+}

+ 6 - 82
src/store/modules/cart.js

@@ -5,43 +5,21 @@ const state = {
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     */
     cartItems(state) {
         return state.cartItems
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     cartTotal(state) {
         return state.cartTotal
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     itemPriced(state) {
         return state.itemPriced
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setCartItems(state, payload) {
         state.cartItems= [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     pushToCart(state, payload) {
         let productFound = state.cartItems.find(item => item.id === payload.id)
 
@@ -60,11 +38,6 @@ const mutations = {
 
         state.cartItems = [payload, ...state.cartItems]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     pullFromCart(state, payload) {
         let foundIndex = state.cartItems.findIndex(item => item.id === payload.item.id)
 
@@ -82,36 +55,16 @@ const mutations = {
             state.cartItems.splice(foundIndex, 1)
         }
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setCartTotal(state, payload) {
         state.cartTotal = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setItemPriced(state, payload) {
         state.itemPriced = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     applyPrice(state, payload) {
         let foundProduct = state.cartItems.find(item => item.id === state.itemPriced.id)
         foundProduct.price = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     undoPrice(state, payload) {
         let foundProduct = state.cartItems.find(item => item.id === payload.id)
         foundProduct.price = foundProduct.standardPrice
@@ -119,41 +72,25 @@ const mutations = {
 }
 
 const actions = {
-    /**
-     * Add item to cart or increment item quantity if exist
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     addToCart({ commit }, payload) {
         commit('pushToCart', payload)
     },
-    /**
-     * Remove item from cart
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     removeFromCart({ commit }, payload) {
         commit('pullFromCart', {
             item: payload,
             mode: 'full'
         })
     },
-    /**
-     * Decrement item quantity from cart
-     * @param {*} param0 
-     * @param {*} payload 
-     */
+    changeCartTotal ({ commit, dispatch }, payload) {
+        commit('setCartTotal', payload)
+        dispatch('changeAmountToPay', payload)
+    },
     decreaseFromCart({ commit }, payload) {
         commit('pullFromCart', {
             item: payload,
             mode: 'partial'
         })
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     changePrice({ commit }, payload) {
         if (typeof payload === 'number') {
            commit('applyPrice', payload)
@@ -167,26 +104,13 @@ const actions = {
         commit('setItemPriced', null)
 
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     undoPrice({ commit }, payload) {
         commit('undoPrice', payload)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
-    updateCartTotal({ commit }, payload) {
+    updateCartTotal({ commit, dispatch }, payload) {
         commit('setCartTotal', payload)
+        dispatch('changeAmountToPay', payload)
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     resetCart({ commit }) {
         commit('setCartItems', [])
         commit('setCartTotal', 0)

+ 65 - 0
src/store/modules/chequeType.js

@@ -0,0 +1,65 @@
+const state = {
+    loadingChequeTypes: false,
+    chequeTypes: [],
+    selectedChequeType: 0
+}
+
+const getters = {
+    loadingChequeTypes(state) {
+        return state.loadingChequeTypes
+    },
+    chequeTypes(state) {
+        return state.chequeTypes
+    },
+    selectedChequeType(state) {
+        return state.selectedChequeType
+    }
+}
+
+const mutations = {
+    setLoadingChequeTypes(state, loading) {
+        state.loadingChequeTypes = !!loading
+    },
+    setChequeTypes(state, chequeTypes) {
+        state.chequeTypes = chequeTypes
+    },
+    setSelectedChequeType(state, id) {
+        if (id) {
+            state.selectedChequeType = state.chequeTypes.find(c => c.id === id)
+            return
+        }
+
+        if (state.chequeTypes.length > 0) {
+            state.selectedChequeType = state.chequeTypes[0]
+            return
+        }
+
+        state.selectedChequeType = null
+    }
+}
+
+const actions = {
+    initChequeTypes({ commit}, chequeTypes) {
+        commit('setChequeTypes', chequeTypes)
+        commit('setSelectedChequeType')
+        commit('setLoadingChequeTypes')
+    },
+    changeChequeType({ commit }, id) {
+        commit('setSelectedChequeType', id)
+    },
+    resetChequeType({ getters, commit }) {
+        if (!getters.isWired) {
+            commit('setLoadingChequeTypes')
+            commit('setChequeTypes', [])
+        }
+
+        commit('setSelectedChequeType')
+    }
+}
+
+export default {
+    state,
+    getters,
+    actions,
+    mutations
+}

+ 13 - 34
src/store/modules/currency.js

@@ -5,69 +5,48 @@ const state = {
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     */
     currencies(state) {
         return state.currencies
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     loadingCurrencies(state) {
         return state.loadingCurrencies
     },
-    /**
-     * 
-     */
+    currencySymbols(state) {
+        if (!state.currencies || !state.selectedCurrency) {
+            return []
+        }
+
+        return state.currencies.filter(c => state.selectedCurrency.id !== c.id).map(c => c.symbol)
+    },
+    baseCurrency(state) {
+        return state.currencies.find(c => c.base === true)
+    },
     selectedCurrency(state) {
         return state.selectedCurrency
+    },
+    selectedCurrencySymbol(state) {
+        return state.selectedCurrency && state.selectedCurrency.symbol
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setCurrencies(state, payload) {
         state.currencies = [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setLoadingCurrencies(state, payload) {
         state.loadingCurrencies = !!payload
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     autoSelectCurrency(state) {
         state.selectedCurrency = state.currencies.find(item => item.base == true)
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     initCurrencies({ commit }, payload) {
         commit('setCurrencies', payload)
         commit('autoSelectCurrency')
         commit('setLoadingCurrencies', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     resetCurrency({ commit }, payload) {
         commit('setLoadingCurrencies', true)
         commit('setCurrencies', [])

+ 0 - 28
src/store/modules/date.js

@@ -4,56 +4,28 @@ const state = {
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     */
     date(state) {
         return state.date
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     loadingDate(state) {
         return state.loadingDate
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setDate(state, payload) {
         state.date = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setLoadingDate(state, payload) {
         state.loadingDate = !!payload
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     initDate({ commit }, payload) {
         commit('setDate', payload)
         commit('setLoadingDate', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     resetDate({ commit }, payload) {
         commit('setLoadingDate', true)
         commit('setDate', [])

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

@@ -5,52 +5,36 @@ const state = {
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     */
     journals(state) {
         return state.journals
     },
-    /**
-     * 
-     * @param {*} state 
-     */
+    bankJournals(state, getters) {
+        return state.journals.filter(j => j.type === 'bank' && j.currencyId === getters.selectedCurrency.id)
+    },
     selectedJournal(state) {
         return state.selectedJournal
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setLoadingJournals(state, payload) {
         return state.loadingJournals
+    },
+    hasJournalSelected(state) {
+        return !!state.selectedJournal
+    },
+    hasCashJournalSelected(state) {
+        return !!state.selectedJournal && state.selectedJournal.type === 'cash'
+    },
+    hasBankJournalSelected(state) {
+        return !!state.selectedJournal && state.selectedJournal.type === 'bank'
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setJournals(state, payload) {
         state.journals = [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     autoSelectJournal(state) {
         state.selectedJournal = state.journals.find(j => j.type === 'cash')
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setSelectedJournal(state, payload) {
         if (!payload) {
             state.selectedJournal = payload
@@ -59,38 +43,20 @@ const mutations = {
 
         state.selectedJournal = state.journals.find(item => item.id === payload)
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setLoadingJournals(state, payload) {
         state.loadingJournals = !!payload
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     initJournals({ commit }, payload) {
         commit('setJournals', payload)
         commit('autoSelectJournal')
         commit('setLoadingJournals', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     selectJournal({ commit }, payload) {
         commit('setSelectedJournal', payload)
     },
-    /**
-     * 
-     */
     resetJournal({ commit }, payload) {
         commit('setLoadingJournals', false)
         commit('setJournals', [])

+ 128 - 99
src/store/modules/payment.js

@@ -1,80 +1,88 @@
 const state = {
-    paymentTerms: [],
     loadingPaymentTerms: true,
+    paymentTerms: [],
+    paymentMethods: ['Efectivo', 'Banco'],
     selectedPaymentTerm: null,
     paymentType: 'cash',
+    paymentMethod: 'Efectivo',
+    amountToPay: 0,
     initialPayment: 0,
-    paymentLines: []
+    amountResidual: 0,
+    paymentLines: [],
+    bankPaymentData: null
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     paymentTerms(state) {
         return state.paymentTerms
     },
-    /**
-     * 
-     * @param {*} state 
-     */
+    paymentMethods(state) {
+        return state.paymentMethods.filter(p => p !== state.paymentMethod)
+    },
     selectedPaymentTerm(state) {
         return state.selectedPaymentTerm
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     paymentType(state) {
         return state.paymentType
     },
-    /**
-     * 
-     * @param {*} state 
-     */
+    paymentMethod(state) {
+        return state.paymentMethod
+    },
+    amountToPay(state) {
+        return state.amountToPay
+    },
+    // amountToPayInOtherCurrencies(state, { settings, currencies, user, selectedCurrency, cartTotal }) {
+    //     console.log(settings)
+    //     console.log(currencies)
+    //     console.log(user)
+    //     console.log(selectedCurrency)
+    //     console.log(cartTotal)
+
+
+    //     let values = []
+
+    //     if (!user || !selectedCurrency || cartTotal === 0) {
+    //         return values
+    //     }
+
+    //     const base = currencies.find(c => c.id === user.company.currencyId)
+
+    //     for (let currency of settings.currencies) {
+    //         if (currency.id === selectedCurrency.id) {
+    //             continue
+    //         }
+
+    //         const rate = base.rateSilent / currency.rateSilent
+
+    //         values.push({
+    //             currency,
+    //             amount: cartTotal / rate,
+    //         })
+    //     }
+
+    //     return values
+    // },
     initialPayment(state) {
         return state.initialPayment
     },
-    /**
-     * 
-     * @param {*} state 
-     */
+    amountResidual(state) {
+        return state.amountResidual
+    },
     paymentLines(state) {
         return state.paymentLines
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     loadingPaymentTerms(state) {
         return state.loadingPaymentTerms
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setPaymentTerms(state, payload) {
         state.paymentTerms = [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setLoadingPaymentTerms(state, payload) {
         state.loadingPaymentTerms = !!payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     autoSelectPaymentTerm(state, payload) {
         if (!payload || payload === 'cash') {
             state.selectedPaymentTerm = state.paymentTerms.find(t => t.lines.length === 1 && t.lines[0].days === 0) || state.paymentTerms.find(t => t.lines.length === 1 && t.lines[0].days >= 0)
@@ -82,40 +90,55 @@ const mutations = {
             state.selectedPaymentTerm = state.paymentTerms.find(t => t.lines[0].days > 0)
         }
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
-    setSelectedPaymentTerm(state, payload) {
-        if (!payload) {
-            state.selectedPaymentTerm = payload
+    setSelectedPaymentTerm(state, termId) {
+        if (!termId) {
+            state.selectedPaymentTerm = null
             return
         }
 
-        state.selectedPaymentTerm = state.paymentTerms.find(item => item.id === payload)
+        state.selectedPaymentTerm = state.paymentTerms.find(item => item.id === termId)
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setPaymentType(state, payload) {
         state.paymentType = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
+    setPaymentMethod(state, payload) {
+        state.paymentMethod = payload
+    },
+    setAmountToPay(state, amount) {
+        if (!this.getters.baseCurrency) {
+            this.amountToPay = amount
+
+            return
+        }
+
+        let rate = 1
+
+        if (this.getters.baseCurrency.id !== this.getters.selectedCurrency.id) {
+            rate = this.getters.baseCurrency.rateSilent / this.getters.selectedCurrency.rateSilent
+        }
+
+        state.amountToPay = amount / rate
+    },
+    setAmountResidual(state) {
+        state.amountResidual = state.initialPayment < state.amountToPay ? 0 : state.initialPayment - state.amountToPay
+    },
+    computePaymentInCurrency(state, { fromSymbol, toSymbol }) {
+        const fromCurrency = this.getters.currencies.find(c => c.symbol === fromSymbol)
+        const toCurrency = this.getters.currencies.find(c => c.symbol === toSymbol)
+
+        if (!fromCurrency || !toCurrency) {
+            return
+        }
+
+        const rate = fromCurrency.rateSilent / toCurrency.rateSilent
+
+        state.amountToPay = state.amountToPay / rate
+        state.initialPayment = state.initialPayment / rate
+        state.amountResidual = state.amountResidual / rate
+    },
     setInitialPayment(state, payload) {
         state.initialPayment = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setPaymentLines(state, payload) {
         state.paymentLines = []
     
@@ -166,25 +189,25 @@ const mutations = {
     
             totals = []
         }    
+    },
+    setBankPaymentData(state, bankPaymentData) {
+        state.bankPaymentData = bankPaymentData
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     initPaymentTerms({ commit }, payload) {
         commit('setPaymentTerms', payload)
         commit('autoSelectPaymentTerm')
         commit('setLoadingPaymentTerms', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
+    autoSelectPaymentTerm(state, payload) {
+        if (!payload || payload === 'cash') {
+            state.paymentTerm = state.paymentTerms.find(t => t.lines.length === 1 && t.lines[0].days === 0) || state.paymentTerms.find(t => t.lines.length === 1 && t.lines[0].days >= 0)
+        } else {
+            state.paymentTerm = state.paymentTerms.find(t => t.lines[0].days > 0)
+        }
+    },
     selectPaymentTerm({ commit }, payload) {
         if (!payload) {
             return
@@ -192,46 +215,52 @@ const actions = {
 
         commit('setSelectedPaymentTerm', payload)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
-    changePaymentType({ commit }, payload) {
+    changePaymentType({ getters, commit, dispatch }, payload) {
         commit('setPaymentType', payload),
         commit('autoSelectPaymentTerm', payload)
         commit('setInitialPayment', 0)
         commit('setPaymentLines')
+
+        if (getters.paymentType === 'credit') {
+            dispatch('computePaymentLines')
+        }
+    },
+    changePaymentMethod({ commit, dispatch }, methodName) {
+        if (methodName === 'Banco') {
+            dispatch('toggleBankPayment')
+        }
+
+        commit('setPaymentMethod', methodName)
+        dispatch('changeInitialPayment', 0)
+    },
+    changeAmountToPay({ commit }, amount) {
+        commit('setAmountToPay', amount)
+    },
+    changeInitialPayment({ commit, dispatch, getters }, initialPayment) {
+        commit('setInitialPayment', initialPayment)
+        commit('setAmountResidual')
+
+        if (getters.paymentType === 'credit') {
+            dispatch('computePaymentLines')
+        }
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
-    changeInitialPayment({ commit }, payload) {
-        commit('setInitialPayment', payload)
-    },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     computePaymentLines({ commit, getters }) {
         commit('setPaymentLines', {
             date: getters.date,
             total: getters.cartTotal
         })
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     resetPayment({ commit }) {
         commit('setLoadingPaymentTerms', true)
         commit('setPaymentTerms', [])
         commit('setSelectedPaymentTerm', null)
         commit('setPaymentType', 'cash')
+        commit('setPaymentMethod', 'Efectivo')
+        commit('setAmountToPay', 0)
         commit('setInitialPayment', 0)
+        commit('setAmountResidual')
+
+        commit('autoSelectPaymentTerm')
     }
 }
 

+ 0 - 27
src/store/modules/picking.js

@@ -4,55 +4,28 @@ const state = {
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     */
     pickingTypes(state) {
         return state.pickingTypes
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     loadingPickingTypes(state) {
         return state.loadingPickingTypes
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setPickingTypes(state, payload) {
         state.pickingTypes = [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setLoadingPickingTypes(state, payload) {
         state.loadingPickingTypes = !!payload
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     */
     initPickingTypes({ commit }, payload) {
         commit('setPickingTypes', payload)
         commit('setLoadingPickingTypes', false)
     },
-   /**
-    * 
-    * @param {*} param0 
-    * @param {*} payload 
-    */
     resetPicking({ commit }, payload) {
         commit('setLoadingPickingTypes', true)
         commit('setPickingTypes', [])

+ 0 - 84
src/store/modules/product.js

@@ -6,93 +6,43 @@ const state = {
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     */
     products(state) {
         return state.products
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     visibleProducts(state) {
         return state.filteredProducts.length === 0 ? state.products : state.filteredProducts
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     productWithVariant(state) {
         return state.productWithVariant
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     showProductForm(state) {
         return !!state.productWithVariant
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     loadingProducts(state) {
         return state.loadingProducts
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setProducts(state, payload) {
         state.products = [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setProductWithVariant(state, payload) {
         state.productWithVariant = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setFilteredProducts(state, payload) {
         state.filteredProducts = [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setLoadingProducts(state, payload) {
         state.loadingProducts = !!payload
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     initProducts({ commit }, payload) {
         commit('setProducts', payload)
         commit('setLoadingProducts', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     selectProduct({ commit, dispatch }, payload) {
         if(!payload) {
             commit('setProductWithVariant', null)
@@ -111,19 +61,9 @@ const actions = {
             dispatch('addToCart', payload.variants[0])
         }
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     filterProducts({ commit }, payload) {
         commit('setFilteredProducts', payload)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     selectProductVariant({ commit, dispatch }, payload) {
         commit('setProductVariant', null)
 
@@ -131,27 +71,12 @@ const actions = {
 
         dispatch('addToCart', payload)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     showProductForm({ commit }) {
         commit('setShowProductForm', true)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     hideProductForm({ commit }) {
         commit('setShowProductForm', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     submitProduct({ commit, dispatch }, payload) {
         if (payload) {
             if (!payload.name || !payload.price) {
@@ -165,19 +90,10 @@ const actions = {
 
         dispatch('hideProductForm')
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     addProduct({ commit }, payload) {
         commit('addProduct', payload)
         commit('setLoadingProducts', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     resetProduct({ commit }) {
         commit('setLoadingProducts', true)
         commit('setProducts', [])

+ 3 - 69
src/store/modules/supplier.js

@@ -6,109 +6,52 @@ const state = {
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     */
     suppliers(state) {
         return state.suppliers
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     loadingSuppliers(state) {
         return state.loadingSuppliers
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     visibleSuppliers(state) {
         return state.filteredSuppliers.length === 0 ? state.suppliers : state.filteredSuppliers
     },
-    /**
-     * 
-     * @param {*} state 
-     */
     selectedSupplier(state) {
         return state.selectedSupplier
+    },
+    selectedSupplierName(state) {
+        return state.selectedSupplier && state.selectedSupplier.name
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setSuppliers(state, payload) {
         state.suppliers = [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */ 
     setLoadingSuppliers(state, payload) {
         state.loadingSuppliers = !!payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setSelectedSupplier(state, payload) {
         state.selectedSupplier = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setFilteredSuppliers(state, payload) {
         state.filteredSuppliers = [...payload]
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     addSupplier(state, payload) {
         state.suppliers = [payload, ...state.suppliers]
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     initSuppliers({ commit }, payload) {
         commit('setSuppliers', payload)
         commit('setLoadingSuppliers', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     selectSupplier({ commit }, payload) {
         commit('setSelectedSupplier', payload)
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     filterSuppliers({ commit }, payload) {
         commit('setFilteredSuppliers', payload)
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     submitSupplier({ commit, dispatch }, payload) {
         if (payload) {
             if (!payload.name || !payload.ruc || !payload.phone) {
@@ -122,19 +65,10 @@ const actions = {
 
         dispatch('hideSupplierForm')
     },
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     addSupplier({ commit }, payload) {
         commit('addSupplier', payload)
         commit('setLoadingSuppliers', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     resetSupplier({ commit }) {
         commit('setLoadingSuppliers', true)
         commit('setSuppliers', [])

+ 3 - 27
src/store/modules/user.js

@@ -4,55 +4,31 @@ const state = {
 }
 
 const getters = {
-    /**
-     * 
-     * @param {*} state 
-     */
     user(state) {
         return state.user
     },
-    /**
-     * 
-     * @param {*} state 
-     */
+    companyName(state) {
+        return state.user && state.user.companyName
+    },
     loadingUser(state) {
         return state.loadingUser
     }
 }
 
 const mutations = {
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setUser(state, payload) {
         state.user = payload
     },
-    /**
-     * 
-     * @param {*} state 
-     * @param {*} payload 
-     */
     setLoadingUser(state, payload) {
         state.loadingUser = !!payload
     }
 }
 
 const actions = {
-    /**
-     * 
-     * @param {*} param0 
-     * @param {*} payload 
-     */
     initUser({ commit }, payload) {
         commit('setUser', payload)
         commit('setLoadingUser', false)
     },
-    /**
-     * 
-     * @param {*} param0 
-     */
     resetUser({ commit }) {
         commit('setLoadingUser', true)
         commit('setUser', null)

+ 2 - 2
templates.xml

@@ -19,7 +19,7 @@
             <field name="params">{'mode': 'expense'}</field>
         </record>
 
-        <menuitem id="eiru_purchases.new_purchase" name="Nueva compra" parent="eiru_dashboard.eiru_dashboard_main" action="eiru_purchases.purchases_action" sequence="4" />
-        <menuitem id="eiru_purchases.new_expense" name="Nuevo gasto" parent="eiru_dashboard.eiru_dashboard_main" action="eiru_purchases.expenses_action" sequence="5" />
+        <!-- <menuitem id="eiru_purchases.new_purchase" name="Nueva compra" parent="eiru_dashboard.eiru_dashboard_main" action="eiru_purchases.purchases_action" sequence="4" />
+        <menuitem id="eiru_purchases.new_expense" name="Nuevo gasto" parent="eiru_dashboard.eiru_dashboard_main" action="eiru_purchases.expenses_action" sequence="5" /> -->
     </data>
 </openerp>

File diff suppressed because it is too large
+ 156 - 21
yarn.lock


Some files were not shown because too many files changed in this diff