Sfoglia il codice sorgente

[ADD] Pagos de compra/gasto finalizado

adrielso 7 anni fa
parent
commit
c916a1208d

+ 31 - 0
README.md

@@ -0,0 +1,31 @@
+# Eiru payments purchases
+
+* Modulo de pagos para compra/ gastos
+
+## Requisitos para la instalación
+
+1. [Node.js](https://nodejs.org/es/) en su última versión
+2. [Yarn](https://yarnpkg.com/lang/en/) en su última versión
+
+### Instalación del módulo
+
+1. Clone el proyecto en la raíz de su carpeta de custom-addons
+2. Ejecute `yarn install` desde su terminal para instalar las dependencias
+3. Ejecute `yarn build` desde su terminal para construir el proyecto
+4. Actualice su lista de módulos y luego instale
+
+### Para actualizarlo
+1. Ejecute `git pull` desde su terminal estando en la raíz del módulo
+2. Ejecute los pasos 2 y 3 del proceso de instalación
+
+### Qué necesitas?
+
+1. Primeramente -> [Mucho brío](https://www.youtube.com/watch?v=CVFTC5B895A)
+2. [Vue.js](https://vuejs.org/)
+3. [Vuex](https://vuex.vuejs.org/en/intro.html)
+4. [Sass](http://sass-lang.com/)
+5. [Pugjs](https://pugjs.org/api/getting-started.html)
+6. [ECMAScript6](http://es6-features.org/)
+7. [Babeljs](https://babeljs.io/)
+8. [Webpack](https://webpack.github.io/)
+9. [Node.js](https://nodejs.org/)

+ 176 - 1
controllers/main.py

@@ -89,6 +89,17 @@ class PaymentsSales(http.Controller):
                     'dateMaturity': line.date_maturity,
                     'amountCurrency': (line.amount_currency * -1) if (line.amount_currency != 0) else line.credit,
                     'amountResidualCurrency': line.amount_residual_currency,
+                    'currencyInvoice': {
+                        'id': invoice.currency_id.id,
+                        'displayName': invoice.currency_id.display_name,
+                        'symbol': invoice.currency_id.symbol,
+                        'rateSilent': invoice.currency_id.rate_silent,
+                        'rate': invoice.currency_id.rate,
+                        'thousandsSeparator': invoice.currency_id.thousands_separator,
+                        'decimalSeparator': invoice.currency_id.decimal_separator,
+                        'decimalPlaces': invoice.currency_id.decimal_places,
+                        'position': invoice.currency_id.position
+                    },
                     'currencyAmount': [{
                         'id': currency.id,
                         'displayName': currency.display_name,
@@ -112,7 +123,6 @@ class PaymentsSales(http.Controller):
         Get Journal
     '''
     def get_journals(self):
-        # domain =[('active', '=', True),('type', 'in',['bank', 'cash']), ('default_credit_account_id.currency_id', '=', False)]
         domain =[('active', '=', True),('type', 'in',['bank', 'cash'])]
         paymentsJournals = []
 
@@ -231,3 +241,168 @@ class PaymentsSales(http.Controller):
             'journals': self.get_journals(),
             'currencies': self.get_currency()
         })
+
+    '''
+          ____   _ __   ____  __ _____ _   _ _____ ____    ____  ____   ___   ____ _____ ____ ____
+         |  _ \ / \\ \ / /  \/  | ____| \ | |_   _/ ___|  |  _ \|  _ \ / _ \ / ___| ____/ ___/ ___|
+         | |_) / _ \\ V /| |\/| |  _| |  \| | | | \___ \  | |_) | |_) | | | | |   |  _| \___ \___ \
+         |  __/ ___ \| | | |  | | |___| |\  | | |  ___) | |  __/|  _ <| |_| | |___| |___ ___) |__) |
+         |_| /_/   \_\_| |_|  |_|_____|_| \_| |_| |____/  |_|   |_| \_\\___/ \____|_____|____/____/
+    '''
+    '''
+        Get the current period
+    '''
+    def get_period(self, date_server):
+        return request.env['account.period'].search([('date_start','<=', date_server), ('date_stop', '>=', datetime.now().strftime(DATE_FORMAT))])
+
+    '''
+        Get Invoice
+    '''
+    def get_invoice(self, invoice_id):
+        return request.env['account.invoice'].search([('id', '=', invoice_id)])
+
+    '''
+        Create Voucher
+    '''
+    def create_voucher(self, period, invoice, company_id, amountPayments, date_server, journalId, move_line_Ids, customerId):
+        # Get Journal
+        journal_id = request.env['account.journal'].browse(int(journalId))
+        currency_id = journal_id.default_credit_account_id.currency_id.id or journal_id.default_credit_account_id.company_currency_id.id
+        # Get Move Lines
+        move_line = request.env['account.move.line'].browse(move_line_Ids).sorted(key=lambda r: r.id)
+        # get customer
+        customerId = request.env['res.partner'].browse(customerId)
+        decimal_precision = request.env['decimal.precision'].precision_get('Account')
+        # Create Line  Voucher
+        company_currency = request.env.user.company_id.currency_id
+        currencyVocuher = request.env['res.currency'].browse(currency_id)
+
+        line_dr_ids = []
+        amount = round(float(amountPayments), decimal_precision)
+
+        for line in move_line:
+            amount_residual = line.amount_residual
+
+            if (company_currency.id != currencyVocuher.id):
+                amount_residual = round((amount_residual * ( currencyVocuher.rate / company_currency.rate)), decimal_precision)
+
+            line_dr_ids.append([0, False, {
+                'date_due': line.date_maturity,
+                'account_id': line.account_id.id,
+                'date_original': line.move_id.date,
+                'move_line_id': line.id,
+                'amount_original': abs(line.credit or line.debit or 0.0),
+                'amount_unreconciled': abs(line.amount_residual),
+                'amount': min(abs(amount), abs(amount_residual)),
+                'reconcile': True if abs(amount_residual) == min(abs(amount), abs(amount_residual)) else False,
+                'currency_id': currency_id
+            }])
+            amount -= min(abs(amount), amount_residual)
+
+        values = {
+            'reference': invoice.number,
+            'type': 'payment',
+            'journal_id': journal_id.id,
+            'company_id': company_id,
+            'pre_line': True,
+            'amount': round(float(amountPayments), decimal_precision),
+            'period_id': period.id,
+            'date': date_server,
+            'partner_id': customerId.id,
+            'account_id': journal_id.default_credit_account_id.id,
+            'currency_id': currency_id,
+            'line_dr_ids': line_dr_ids,
+            'payment_rate_currency_id': currency_id
+        }
+
+        account_voucher = request.env['account.voucher'].create(values)
+        account_voucher.action_move_line_create()
+
+        return account_voucher
+
+    '''
+            close invoice
+    '''
+    def close_invoice(self, invoiceid):
+        invoice = request.env['account.invoice'].search([('id', '=', invoiceid)])
+
+        if invoice.residual <= 0:
+            invoice.confirm_paid()
+
+        return invoice
+
+    '''
+        Create bank Statement
+    '''
+    def create_bank_statement(self, date_server, user_id, account_voucher):
+        # Get bank Statamente
+        bank_statement = request.env['account.bank.statement'].search([('journal_id', '=', account_voucher.journal_id.id), ('date', '=', date_server)])
+        amount = account_voucher.amount
+        if account_voucher.type == 'payment':
+            amount = amount * -1
+
+        # Create line bank
+        bank_statement_line = [[0, False, {
+            'name': account_voucher.reference,
+            'partner_id': account_voucher.partner_id.id,
+            'amount': amount,
+            'voucher_id': account_voucher.id,
+            'journal_id': account_voucher.journal_id.id,
+            'account_id': account_voucher.account_id.id,
+            'journal_entry_id': account_voucher.move_id.id,
+            'currency_id': account_voucher.currency_id.id,
+            'ref': 'NP'
+        }]]
+
+        bank = {
+            'journal_id': account_voucher.journal_id.id,
+            'period_id': account_voucher.period_id.id,
+            'date': date_server,
+            'user_id': user_id,
+            'state': 'open' if account_voucher.journal_id.type == 'cash' else 'draft',
+            'line_ids': bank_statement_line
+        }
+
+        if bank_statement:
+            if len(bank_statement) == 1:
+                bank_statement.write(bank)
+            else:
+                bank_statement[len(bank_statement) -1].write(bank)
+        else:
+            bank_statement = bank_statement.create(bank)
+
+        return bank_statement
+
+    '''
+        Payment process
+    '''
+    @http.route('/eiru_payments_purchases/purchases_process', type='json', auth='user', methods=['POST'], cors='*')
+    def purchases_process(self, **kw):
+        self.make_info_log('Processing payments purchases...')
+        # Get Date Server
+        date_server = datetime.now().strftime(DATE_FORMAT)
+        #Get Periodo
+        period = self.get_period(date_server)
+        self.make_info_log('[OK] Getting period')
+        # Get invoice
+        invoice = self.get_invoice(kw.get('invoiceId'))
+        self.make_info_log('[OK] Getting invoice')
+        # Get User - company
+        user_id = request.env.user.id
+        self.make_info_log('[OK] Getting user')
+        # Get Company
+        company_id = request.env.user.company_id.id
+        self.make_info_log('[OK] Getting Company')
+        # create voucher
+        voucher = self.create_voucher(period, invoice, company_id, kw.get('amountPayments', 0), date_server, kw.get('journalId'), kw.get('moveLinesId'), kw.get('supplierId'))
+        self.make_info_log('[OK] creating voucher...')
+        # close invoice
+        close_invoice = self.close_invoice(kw.get('invoiceId'))
+        self.make_info_log('[OK] closing invoice...')
+        #  Create bank statement
+        bank_statement = self.create_bank_statement(date_server, user_id, voucher)
+        self.make_info_log('[OK] creating bank statement')
+
+        return {
+            'process': True
+        }

+ 36 - 8
src/App.vue

@@ -1,19 +1,28 @@
 <template lang="pug">
     .payments-purchase
-        //- form-wizard(title="" subtitle="" finishButtonText="Finalizar" color="#7c7bad" backButtonText="Volver" :hideButtons='processingPayments' nextButtonText="Continuar" transition="fade" @on-complete="paymentProcess()" ref='wizard' @on-change="(prev, next) => removeMovePaymentsAll(prev > next && next < 2)")
-        form-wizard(title="" subtitle="" finishButtonText="Finalizar" color="#7c7bad" backButtonText="Volver" nextButtonText="Continuar" transition="fade" ref='wizard')
-            tab-content(title="Quien es el proveedor ?")
+        form-wizard( title="" subtitle="" finishButtonText="Finalizar" color="#7c7bad" backButtonText="Volver" :hideButtons='processingPaymentsPurchases' nextButtonText="Continuar" transition="fade" ref='wizard' @on-complete="paymentsPurchaseProcess()" @on-change="(prev, next) => setChangeTabSteps({prev,next})")
+            tab-content(title="Quien es el proveedor ?" :beforeChange="checkPaymentsPurchasesSUpplier")
                 supplier
-            tab-content(title="Cual es la factura ?")
+            tab-content(title="Cual es la factura ?" :beforeChange="checkPaymentsPurchasesInvoices")
                 invoices
-            tab-content(title="Que cuota es ?")
+            tab-content(title="Que cuota es ?" :beforeChange="checkPaymentsPurchasesLinesPayments")
                 moves-lines
-            tab-content(title="Como vas a pagar ?")
+            tab-content(title="Como vas a pagar ?" :beforeChange="checkPaymentsPurchasesJournals")
                 payments
 </template>
 
 <script>
-    import { INIT_PAYMENTS_PURCHASES } from '@/constants/actionTypes'
+    import {
+        INIT_PAYMENTS_PURCHASES,
+        PAYMENTS_PURCHASE_PROCESS,
+        CHECK_PAYMENTS_PURCHASES_SUPPLIER,
+        CHECK_PAYMENTS_PURCHASES_INVOICES,
+        CHECK_PAYMENTS_PURCHASES_LINES_PAYMENTS,
+        CHECK_PAYMENTS_PURCHASES_JOURNALS,
+        RESET_PAYMENTS_PURCHASES,
+        SET_CHANGE_TAB_STEPS
+    } from '@/constants/actionTypes'
+
     import { mapActions, mapGetters } from 'vuex'
     import { FormWizard, TabContent} from 'vue-form-wizard'
     import 'vue-form-wizard/dist/vue-form-wizard.min.css'
@@ -32,9 +41,28 @@
             MovesLines,
             Payments
         },
+        computed: mapGetters([
+            'processingPaymentsPurchases',
+            'completedPaymentsPurchases'
+        ]),
         methods: mapActions([
-            INIT_PAYMENTS_PURCHASES
+            INIT_PAYMENTS_PURCHASES,
+            PAYMENTS_PURCHASE_PROCESS,
+            CHECK_PAYMENTS_PURCHASES_SUPPLIER,
+            CHECK_PAYMENTS_PURCHASES_INVOICES,
+            CHECK_PAYMENTS_PURCHASES_LINES_PAYMENTS,
+            CHECK_PAYMENTS_PURCHASES_JOURNALS,
+            RESET_PAYMENTS_PURCHASES,
+            SET_CHANGE_TAB_STEPS
         ]),
+        watch: {
+			completedPaymentsPurchases(value) {
+				if ( value ){
+					this.$refs.wizard.changeTab(3, 0, false)
+					this.resetPaymentsPurchases()
+				}
+			}
+		},
         mounted() {
             this.initPaymentsPurchases()
         }

+ 1 - 1
src/assets/_variables.sass

@@ -4,4 +4,4 @@ $app-light-color: #f5f5f5
 $app-bg-color: #fff
 $app-border-color: #d3d3d3
 $app-title-color: #d3d3d3
-$app-separator-color: #9e9e9e
+$app-separator-color: #9e9e9e

+ 1 - 5
src/components/payments/VoucherTicket.vue

@@ -14,7 +14,7 @@
                 .voucher-ticket-from-grid
                     .voucher-ticket-from-grid-item(v-for="line in items")
                         label.voucher-ticket-from-grid-item-left {{ line.invoiceNumber }}
-                        label.voucher-ticket-from-grid-item-right {{ line.amountResidualCurrency | currency(...invoice.currency) }}
+                        label.voucher-ticket-from-grid-item-right {{ line.amountResidualCurrency | currency(...line.currencyInvoice) }}
                 .voucher-ticket-from-item-total
                     label.voucher-ticket-from-label-total Total
                     .ticket-currency-total-wrapper
@@ -30,10 +30,6 @@
                 type: String,
                 default: ''
             },
-            invoice: {
-                type: String,
-                default: ''
-            },
             currencyAmount :{
                 type: Array,
                 default: [],

+ 0 - 2
src/components/steps/Invoices.vue

@@ -9,11 +9,9 @@
 
     import { mapGetters, mapActions } from 'vuex'
     import { SELECT_SUPPLIER_INVOICES, FILTER_SUPPLIER_INVOICES } from '@/constants/actionTypes'
-
     import { Searcher } from '@@/common'
     import Grid from '@@/fromsInvoices/Grid'
 
-
     export default {
         components: {
             Searcher,

+ 0 - 1
src/components/steps/MovesLines.vue

@@ -9,7 +9,6 @@
 
     import { mapActions, mapGetters } from 'vuex'
     import { SELECT_SUPPLIER_MOVE_LINES, ACTION_REMOVE_SUPPLIER_LINES_PAYMENTS } from '@/constants/actionTypes'
-
     import GridMoves from '@@/fromsMoveLine/GridMoves'
     import GridPayments from '@@/fromsMoveLine/GridMovesPayments'
 

+ 14 - 10
src/components/steps/payments.vue

@@ -1,11 +1,11 @@
 <template lang="pug">
     .payments-purchase-step
         .payments-step
-            .from-loading-payments(v-show='processingPayments')
+            .from-loading-payments(v-show='processingPaymentsPurchases')
                 .form-overlay-payments
                 .form-spinner-payments
                     spinner(type='wave')
-            voucher-ticket(v-if="paymentsMoveLines.length" :items="paymentsMoveLines" :customer='selectedSupplier' :invoice='selectedInvoices' :currencyAmount="paymentsCurrencyAmount")
+            voucher-ticket(v-if="paymentsMoveLines.length" :items="paymentsMoveLines" :customer='selectedSupplier' :currencyAmount="paymentsCurrencyAmount")
             form.method-payment
                 .method-form-separator
                     h3 Detalle de Cliente
@@ -22,44 +22,48 @@
                         option(v-for="journal in paymentsJournals" :value="journal") {{ journal.displayName }}
                 .method-form-item
                     label.method-form-label Total
-                    input.method-form-input-number(readonly :value="paymentsTotal | currency(...currency)")
+                    input.method-form-input-number(readonly :value="paymentsTotal | currency(...paymentsCurrencyJournal)")
                 .method-form-item
                     label.method-form-label  Monto a Pagar
                     input.method-form-input-number(v-model='paid' autofocus)
                 .method-form-item
                     label.method-form-label Monto a Devolver
-                    input.method-form-input-number(readonly :value='paymentsReturned | currency(...currency)')
+                    input.method-form-input-number(readonly :value='paymentsReturned | currency(...paymentsCurrencyJournal)')
 </template>
 
 <script>
     import { mapGetters, mapActions } from 'vuex'
     import { SELECT_PAYMENTS_JOURNALS, CHANGE_INITIAL_PAID } from '@/constants/actionTypes'
     import  VoucherTicket from '@@/payments/VoucherTicket'
+    import Spinner from '@@/common/Spinner'
 
     export default {
         components: {
-            VoucherTicket
+            VoucherTicket,
+            Spinner
         },
         computed: {
             SelectedJournal: {
                 get() {
+                    this.paymentsReturned = 0
                     return (this.paymentsSelectedJournal) || -1
                 },
                 set(value) {
+
                     if (value)
                         this.selectPaymentsJournals(value)
                 }
             },
             paid: {
                 get() {
-                    let formatted = this.$options.filters.currency(this.paidTotal, {...this.currency})
+                    let formatted = this.$options.filters.currency(this.paidTotal, {...this.paymentsCurrencyJournal})
                     return !!this.paidTotal ? formatted : formatted.replace(/\d/, '')
                 },
                 set(value) {
                     value = value.replace(/[\.|,](\d{0,2}$)/, '?$1').split(/\?/)
                     value[0] = value[0].replace(/[^0-9]/g, '')
                     value = Number.parseFloat(value.join('.')) || 0
-                    
+
                     this.changeInitialPaid(value)
                     this.computePayment(value)
                 }
@@ -73,13 +77,14 @@
                 'paymentsSelectedJournal',
                 'paymentsTotal',
                 'paidTotal',
-                'paymentsReturned'
+                'paymentsReturned',
+                'paymentsCurrencyJournal',
+                'processingPaymentsPurchases'
             ])
         },
         methods: {
             computePayment(value) {
                 this.paymentsReturned = value < this.paymentsTotal ? 0 : value - this.paymentsTotal
-                // this.paymentsResidual = value > this.movesPaymentsTotal ? 0 : this.movesPaymentsTotal - value
             },
             ...mapActions([
                 CHANGE_INITIAL_PAID,
@@ -103,7 +108,6 @@
             height: calc(100% - 50px)
             padding-bottom: 50px
             display: flex
-            // position: relative
             .method-payment
                 width: calc(100% - 450px)
                 height: 100%

+ 70 - 10
src/constants/actionTypes.js

@@ -1,9 +1,12 @@
 /**
- * [Initial]
+ * [Initial] [Porcess] [Reset]
  */
 const INIT_PAYMENTS_PURCHASES = 'initPaymentsPurchases'
 const PAYMENTS_PURCHASES_NOTIFY = 'paymentsPurchasesNotify'
 const EXPLODE_DATA = 'explodeData'
+const PAYMENTS_PURCHASE_PROCESS = 'paymentsPurchaseProcess'
+const RESET_PAYMENTS_PURCHASES = 'resetPaymentsPurchases'
+const SET_CHANGE_TAB_STEPS = 'setChangeTabSteps'
 /**
  * [ Date]
  */
@@ -29,6 +32,7 @@ const ADD_MOVE_IN_INVOICE = 'addMoveInInvoice'
 const INIT_SUPPLIER_MOVE_LINES = 'initSupplierMoveLines'
 const SELECT_SUPPLIER_MOVE_LINES = 'selectSuppierMoveLines'
 const ACTION_REMOVE_SUPPLIER_LINES_PAYMENTS = 'actionRemoveSupplierLinesPayments'
+const ACTION_REMOVE_ALL_SUPPLIER_LINES_PAYMENTS = 'actionRemoveAllSupplierLinesPayments'
 /**
  * [ Journal]
  */
@@ -38,31 +42,87 @@ const REMOVE_PAYMENTS_MOVE_LINES = 'removePaymentsMovelines'
 const INIT_PAYMENTS_JOURNALS = 'initPaymentsJournals'
 const SELECT_PAYMENTS_JOURNALS = 'selectPaymentsJournals'
 const CHANGE_INITIAL_PAID = 'changeInitialPaid'
+const RESET_SELECTED_JOURNAL_PAYMENTS = 'resetSelectedJournalPayments'
 /**
  * [ Currency ]
  */
 const INIT_PAYMENTS_PURCHASES_CURRENCIES = 'initPaymentsPurchasesCurrencies'
-
+/**
+ * [Finish Payments]
+ */
+const COMPLETED_PAYMENTS_PURCHASES = 'completedPaymentsPurchases'
+/**
+ * [CHECK STEPS]
+ */
+const CHECK_PAYMENTS_PURCHASES_SUPPLIER = 'checkPaymentsPurchasesSUpplier'
+const CHECK_PAYMENTS_PURCHASES_INVOICES = 'checkPaymentsPurchasesInvoices'
+const CHECK_PAYMENTS_PURCHASES_LINES_PAYMENTS = "checkPaymentsPurchasesLinesPayments"
+const CHECK_PAYMENTS_PURCHASES_JOURNALS = 'checkPaymentsPurchasesJournals'
+/**
+ *  RESET
+ */
+const RESET_PAYMENTS_PURCHASES_DATE = 'resetPaymentsPurchasesDate'
+const RESET_PAYMENTS_PURCHASES_USER = 'resetPaymentsPurchasesUser'
+const RESET_PAYMENTS_PURCHASES_COMPANY = 'resetPaymentsPurchasesCompany'
+const RESET_PAYMENTS_PURCHASES_SUPPLIER = 'resetPaymentsPurchasesSupplier'
+const RESET_PAYMENTS_PURCHASES_JOURNALS = 'resetPaymentsPurchasesJournals'
+const RESET_PAYMENTS_PURCHASES_CURRENCIES = 'resetPaymentsPurchasesCurrencies'
+const RESET_SUPPLIER_INVOICES = 'resetSupplierInvoices'
+const RESET_SUPPLIER_MOVE_LINES = 'resetSupplierMoveLines'
+const RESET_SUPPLIER_PAYMENTS = 'resetSupplierPayments'
 
 export {
-    //INIT
+    //INIT - PROCESS - RESET-
     INIT_PAYMENTS_PURCHASES,
-    PAYMENTS_PURCHASES_NOTIFY, EXPLODE_DATA,
+    PAYMENTS_PURCHASES_NOTIFY,
+    EXPLODE_DATA,
+    PAYMENTS_PURCHASE_PROCESS,
+    RESET_PAYMENTS_PURCHASES,
+    SET_CHANGE_TAB_STEPS,
     //DATE
     INIT_PAYMENTS_PURCHASES_DATE,
     //USER
-    INIT_PAYMENTS_PURCHASES_USER, INIT_COMPANY_USER,
+    INIT_PAYMENTS_PURCHASES_USER,
+    INIT_COMPANY_USER,
     //SUPPLIER
     INIT_PAYMENTS_PURCHASES_SUPPLIER,
     FILTER_PAYMENTS_PURCHASES_SUPPLIER,
     SELECT_PAYMENTS_PURCHASES_SUPPLIER,
     //Invoices
-    INIT_SUPPLIER_INVOICES, FILTER_SUPPLIER_INVOICES, SELECT_SUPPLIER_INVOICES, ADD_MOVE_IN_INVOICE,
+    INIT_SUPPLIER_INVOICES,
+    FILTER_SUPPLIER_INVOICES,
+    SELECT_SUPPLIER_INVOICES,
+    ADD_MOVE_IN_INVOICE,
     // Move Lines
-    INIT_SUPPLIER_MOVE_LINES, SELECT_SUPPLIER_MOVE_LINES, ACTION_REMOVE_SUPPLIER_LINES_PAYMENTS,
+    INIT_SUPPLIER_MOVE_LINES,
+    SELECT_SUPPLIER_MOVE_LINES,
+    ACTION_REMOVE_SUPPLIER_LINES_PAYMENTS,
+    ACTION_REMOVE_ALL_SUPPLIER_LINES_PAYMENTS,
     //JOURNAL
-    INIT_PAYMENTS_PURCHASES_JOURNALS, ADD_PAYMENTS_MOVE_LINES, REMOVE_PAYMENTS_MOVE_LINES,
-    INIT_PAYMENTS_JOURNALS, SELECT_PAYMENTS_JOURNALS, CHANGE_INITIAL_PAID,
+    INIT_PAYMENTS_PURCHASES_JOURNALS,
+    ADD_PAYMENTS_MOVE_LINES,
+    REMOVE_PAYMENTS_MOVE_LINES,
+    INIT_PAYMENTS_JOURNALS,
+    SELECT_PAYMENTS_JOURNALS,
+    CHANGE_INITIAL_PAID,
+    RESET_SELECTED_JOURNAL_PAYMENTS,
     //CURRENCIES
-    INIT_PAYMENTS_PURCHASES_CURRENCIES
+    INIT_PAYMENTS_PURCHASES_CURRENCIES,
+    // finish payments
+    COMPLETED_PAYMENTS_PURCHASES,
+    // CHECK STEPS
+    CHECK_PAYMENTS_PURCHASES_SUPPLIER,
+    CHECK_PAYMENTS_PURCHASES_INVOICES,
+    CHECK_PAYMENTS_PURCHASES_LINES_PAYMENTS,
+    CHECK_PAYMENTS_PURCHASES_JOURNALS,
+    // RESET
+    RESET_PAYMENTS_PURCHASES_DATE,
+    RESET_PAYMENTS_PURCHASES_USER,
+    RESET_PAYMENTS_PURCHASES_COMPANY,
+    RESET_PAYMENTS_PURCHASES_SUPPLIER,
+    RESET_PAYMENTS_PURCHASES_JOURNALS,
+    RESET_PAYMENTS_PURCHASES_CURRENCIES,
+    RESET_SUPPLIER_INVOICES,
+    RESET_SUPPLIER_MOVE_LINES,
+    RESET_SUPPLIER_PAYMENTS
 }

+ 45 - 11
src/constants/mutationTypes.js

@@ -33,6 +33,7 @@ const SET_ORDER_SUPPLIER_MOVE_LINES = 'setOrderSupplierMoveLines'
 const SET_ORDER_SUPPLIER_LINES_PAYMENTS = 'setOrderSupplierLinesPayments'
 const SET_CALCULATE_TOTAL = 'setCalculateTotal'
 const REMOVE_SUPPLIER_LINES_PAYMENTS = 'removeSupplierLinesPayments'
+const REMOVE_LINES_PAYMENTS = 'removeLinesPayments'
 /**
  * [ Journal]
  */
@@ -45,30 +46,63 @@ const SET_PAYMENTS_JOURNALS = 'setPaymentsJournals'
 const SELECTED_PAYMENTS_JOURNALS = 'selectedPaymentsJournals'
 const CALCULATE_PAYMENTS_TOTAL = 'calculatePaymentsTotal'
 const SET_PAID_TOTAL = 'setPaidTotal'
-
+const SET_PAYMENTS_CURRENCY_JOURNAL = 'setPaymentsCurrencyJournal'
 /**
  * [ Currency ]
  */
 const SET_CURRENCIES = 'setCurrencies'
 const SET_LOADING_CURRENCIES = 'setLoadingCurrencies'
-
+/**
+ * [ Finish payments]
+ */
+const SET_COMPLETED_PAYMENTS_PURCHASES = 'setCompletedPaymentsPurchases'
+const SET_PROCESSING_PAYMENTS_PURCHASES = ' setProcessingPaymentsPurchases'
 
 export {
     //DATE
-    SET_DATE, SET_LOADING_DATE,
+    SET_DATE,
+    SET_LOADING_DATE,
     //USER
-    SET_USER, SET_LOADING_USER, SET_COMPANY_USER, SET_CURRENCY_COMPANY,
+    SET_USER,
+    SET_LOADING_USER,
+    SET_COMPANY_USER,
+    SET_CURRENCY_COMPANY,
     //SUPPLIER
-    SET_SUPPLIER, SET_LOADING_SUPPLIER, SET_FILTER_PAYMENTS_PURCHASES_SUPPLIER, SET_SELECTED_PAYMENTS_PURCHASES_SUPPLIER,
+    SET_SUPPLIER,
+    SET_LOADING_SUPPLIER,
+    SET_FILTER_PAYMENTS_PURCHASES_SUPPLIER,
+    SET_SELECTED_PAYMENTS_PURCHASES_SUPPLIER,
     //Invoices
-    SET_SUPPLIER_INVOICES, SET_SELECTED_SUPPLIER_INVOICES, SET_FILTER_SUPPLIER_INVOICES, SET_MOVE_IN_INVOICE, SET_CURRENCY_INVOICE,
+    SET_SUPPLIER_INVOICES,
+    SET_SELECTED_SUPPLIER_INVOICES,
+    SET_FILTER_SUPPLIER_INVOICES,
+    SET_MOVE_IN_INVOICE,
+    SET_CURRENCY_INVOICE,
     // Move lines
-    SET_SUPPLIER_MOVE_LINES, SET_SELECTED_SUPPLIER_MOVE_LINES, SET_SUPPLIER_LINES_PAYMENTS,
-    REMOVE_SUPPLIER_MOVE_LINES, SET_ORDER_SUPPLIER_MOVE_LINES, SET_ORDER_SUPPLIER_LINES_PAYMENTS, SET_CALCULATE_TOTAL,
+    SET_SUPPLIER_MOVE_LINES,
+    SET_SELECTED_SUPPLIER_MOVE_LINES,
+    SET_SUPPLIER_LINES_PAYMENTS,
+    REMOVE_SUPPLIER_MOVE_LINES,
+    SET_ORDER_SUPPLIER_MOVE_LINES,
+    SET_ORDER_SUPPLIER_LINES_PAYMENTS,
+    SET_CALCULATE_TOTAL,
     REMOVE_SUPPLIER_LINES_PAYMENTS,
+    REMOVE_LINES_PAYMENTS,
     //JOURNALS
-    SET_JOURNALS, SET_LOADING_JOURNALS,SET_ADD_PAYMENTS_MOVE_LINES, SET_REMOVE_PAYMENTS_MOVE_LINES,
-    SET_PAYMENTS_JOURNALS, SELECTED_PAYMENTS_JOURNALS, CALCULATE_PAYMENTS_TOTAL, CALCULATE_CURRENCY_AMOUNT, SET_PAID_TOTAL,
+    SET_JOURNALS,
+    SET_LOADING_JOURNALS,
+    SET_ADD_PAYMENTS_MOVE_LINES,
+    SET_REMOVE_PAYMENTS_MOVE_LINES,
+    SET_PAYMENTS_JOURNALS,
+    SELECTED_PAYMENTS_JOURNALS,
+    CALCULATE_PAYMENTS_TOTAL,
+    CALCULATE_CURRENCY_AMOUNT,
+    SET_PAID_TOTAL,
+    SET_PAYMENTS_CURRENCY_JOURNAL,
     //CURRENCIES
-    SET_CURRENCIES, SET_LOADING_CURRENCIES
+    SET_CURRENCIES,
+    SET_LOADING_CURRENCIES,
+    // finish payments
+    SET_COMPLETED_PAYMENTS_PURCHASES,
+    SET_PROCESSING_PAYMENTS_PURCHASES
 }

+ 3 - 2
src/constants/resourcePaths.js

@@ -1,7 +1,8 @@
 const BASE_URL = '/eiru_payments_purchases'
 const INIT_PAYMENTS_PURCHASES_URL = `${BASE_URL}/init`
-// const PAYMENTS_PURCHASES_PROCESS_URL = `${BASE_URL}/purchases_process`
+const PAYMENTS_PURCHASES_PROCESS_URL = `${BASE_URL}/purchases_process`
 
 export {
-    INIT_PAYMENTS_PURCHASES_URL
+    INIT_PAYMENTS_PURCHASES_URL,
+    PAYMENTS_PURCHASES_PROCESS_URL
 }

+ 1 - 2
src/index.js

@@ -10,7 +10,7 @@ Vue.filter('dateFormat', dateFormat)
 /*config*/
 Vue.config.productionTip = false
 Vue.config.silent = true
-Vue.config.devTools = false
+Vue.config.devTools = true
 
 
 openerp.eiru_payments_purchases = (instance, local) => {
@@ -41,7 +41,6 @@ openerp.eiru_payments_purchases = (instance, local) => {
             if(!instance.eiru_sidebar_toggler) return
             instance.eiru_sidebar_toggler.sidebar_unfold()
         }
-
     })
     instance.web.client_actions.add('eiru_payments_purchases.action_launch', 'instance.eiru_payments_purchases.PaymentsPurchasesWidget')
 }

+ 114 - 5
src/store/actions.js

@@ -1,19 +1,37 @@
 import axios from 'axios'
+/* resourcePaths*/
 import {
-    INIT_PAYMENTS_PURCHASES_URL
+    INIT_PAYMENTS_PURCHASES_URL,
+    PAYMENTS_PURCHASES_PROCESS_URL
 } from '@/constants/resourcePaths'
-
+/* Actions */
 import {
     INIT_PAYMENTS_PURCHASES,
     PAYMENTS_PURCHASES_NOTIFY,
-    EXPLODE_DATA
+    EXPLODE_DATA,
+    PAYMENTS_PURCHASE_PROCESS,
+    COMPLETED_PAYMENTS_PURCHASES,
+    RESET_PAYMENTS_PURCHASES,
+    CHECK_PAYMENTS_PURCHASES_SUPPLIER,
+    CHECK_PAYMENTS_PURCHASES_INVOICES,
+    CHECK_PAYMENTS_PURCHASES_LINES_PAYMENTS,
+    CHECK_PAYMENTS_PURCHASES_JOURNALS,
+    SET_CHANGE_TAB_STEPS,
+    CHANGE_INITIAL_PAID,
+    ACTION_REMOVE_ALL_SUPPLIER_LINES_PAYMENTS
 } from '@/constants/actionTypes'
+/* Mutations */
+import {
+    SET_COMPLETED_PAYMENTS_PURCHASES,
+    SET_PROCESSING_PAYMENTS_PURCHASES
+} from '@/constants/mutationTypes'
+
 const actions = {
     /**
      * [PAYMENTS_PURCHASES_NOTIFY]
      */
     [PAYMENTS_PURCHASES_NOTIFY] ({ commit }, paylod) {
-        opererp.web.notification.do_warn('Atencion', paylod)
+        openerp.web.notification.do_warn('Atencion', paylod)
         return false
     },
     /**
@@ -22,6 +40,7 @@ const actions = {
      */
     [INIT_PAYMENTS_PURCHASES] ({ dispatch }) {
         return axios.get(INIT_PAYMENTS_PURCHASES_URL).then(response => {
+            dispatch(COMPLETED_PAYMENTS_PURCHASES, false)
             dispatch(EXPLODE_DATA, response.data)
         }).catch(error => {
             console.log(error);
@@ -34,7 +53,97 @@ const actions = {
         for (let value in paylod) {
             dispatch(`initPaymentsPurchases${value[0].toUpperCase()}${value.slice(1)}`, paylod[value])
         }
-    }
+    },
+    /**
+     * [PAYMENTS_PURCHASE_PROCESS]
+     */
+    [PAYMENTS_PURCHASE_PROCESS] ({ commit, dispatch, getters }){
+        commit(SET_PROCESSING_PAYMENTS_PURCHASES, true)
+        const data = {
+            jsonrpc: '2.0',
+            method: 'call',
+            params: {
+                journalId: getters.paymentsSelectedJournal.id,
+                amountPayments: getters.paidTotal <= getters.paymentsTotal ? getters.paidTotal : getters.paymentsTotal,
+                supplierId: getters.selectedSupplier.id,
+                invoiceId: getters.selectedInvoices.id,
+                moveLinesId: getters.paymentsMoveLines.map( item => {
+                    return item.id
+                })
+            }
+        }
+
+        return axios.post(PAYMENTS_PURCHASES_PROCESS_URL, data).then(response => {
+            commit(SET_PROCESSING_PAYMENTS_PURCHASES, !response)
+            dispatch(COMPLETED_PAYMENTS_PURCHASES, response.data.result)
+        }).catch(error => {
+            commit(SET_PROCESSING_PAYMENTS_PURCHASES, !false)
+        })
+    },
+    /**
+     * [COMPLETED_PAYMENTS_PURCHASES] [Cambiar el estado cunado se completa el pago]
+     */
+    [COMPLETED_PAYMENTS_PURCHASES] ({ commit }, payload ) {
+        commit(SET_COMPLETED_PAYMENTS_PURCHASES, !!payload)
+    },
+    /**
+     *  [RESET_PAYMENTS_PURCHASES]
+     */
+    [RESET_PAYMENTS_PURCHASES] ({ rootState, commit, dispatch }) {
+        for (let key in rootState ) {
+            if (!(rootState[key] instanceof Object)){
+                continue
+            }
+            dispatch(`reset${key[0].toUpperCase()}${key.slice(1)}`)
+        }
+        dispatch(INIT_PAYMENTS_PURCHASES)
+    },
+    /* CHECH STEPS*/
+    /**
+     * [CHECK_PAYMENTS_PURCHASES_SUPPLIER] [Validar que seleccione un proveedor]
+     */
+     [CHECK_PAYMENTS_PURCHASES_SUPPLIER] ({ dispatch, getters }) {
+         return !!getters.selectedSupplier || dispatch(PAYMENTS_PURCHASES_NOTIFY, 'Necesitas seleccionar un proveedor para continuar.')
+     },
+     /**
+      * [CHECK_PAYMENTS_PURCHASES_INVOICES] [validar que selecciones una factura]
+      */
+     [CHECK_PAYMENTS_PURCHASES_INVOICES] ({ dispatch, getters}) {
+         return !!getters.selectedInvoices || dispatch(PAYMENTS_PURCHASES_NOTIFY, 'Necesitas seleccionar una factura para continuar.')
+     },
+     /**
+      * [CHECK_PAYMENTS_PURCHASES_LINES_PAYMENTS] [validar que seleccione al menos una cuota a apagar]
+      */
+     [CHECK_PAYMENTS_PURCHASES_LINES_PAYMENTS] ({ dispatch, getters }) {
+         return !!getters.supplierLinesPayments.length || dispatch(PAYMENTS_PURCHASES_NOTIFY, 'Necesitas seleccionar al menos una cuota para continuar.')
+     },
+     /**
+      * [CHECK_PAYMENTS_PURCHASES_JOURNALS] [validar que seleccione el método de pago, ingrese el monto a pagar]
+      */
+     [CHECK_PAYMENTS_PURCHASES_JOURNALS] ({ dispatch, getters }) {
+         if (!getters.paymentsSelectedJournal) {
+              return dispatch(PAYMENTS_PURCHASES_NOTIFY, 'Necesitas seleccionar el método para continuar.')
+         }
+         if (getters.paidTotal <= 0){
+             return dispatch(PAYMENTS_PURCHASES_NOTIFY, 'El monto no puede ser cero(0), ingrese un monto para continuar.')
+         }
+         return true
+     },
+     /**
+      * [prev description] [Cuando pasa de un Estado Superior a inferior u cuando abandona el modulo restaura los datos]
+      * @type {[type]}
+      */
+     [SET_CHANGE_TAB_STEPS] ({ commit, dispatch, getters }, paylod) {
+         /* Si abandona el modulo */
+         if (paylod.prev === 0 && paylod.next === -1){
+            dispatch(RESET_PAYMENTS_PURCHASES)
+         }
+         
+         if (paylod.prev >= 2 && paylod.next<= 1) {
+             dispatch(CHANGE_INITIAL_PAID, 0)
+             dispatch(ACTION_REMOVE_ALL_SUPPLIER_LINES_PAYMENTS)
+         }
+     }
 }
 
 export default actions

+ 20 - 0
src/store/getters.js

@@ -0,0 +1,20 @@
+const getters = {
+    /**
+     * [processingPaymentsPurchases description]
+     * @param  {[type]} state [description]
+     * @return {[type]}       [description]
+     */
+    processingPaymentsPurchases ( state ) {
+        return state.processingPaymentsPurchases
+    },
+    /**
+     * [completedPaymentsPurchases description]
+     * @param  {[type]} state [description]
+     * @return {[type]}       [description]
+     */
+    completedPaymentsPurchases ( state ) {
+        return state.completedPaymentsPurchases
+    }
+}
+
+export default getters

+ 8 - 7
src/store/index.js

@@ -4,10 +4,9 @@ import Vuex from 'vuex'
  * [ Store ]
  */
 import actions from '@/store/actions'
-// import getters from '@/store/getters'
-// import mutations from '@/store/mutations'
-// import state from '@/store/state'
-
+import getters from '@/store/getters'
+import mutations from '@/store/mutations'
+import state from '@/store/state'
 /**
  * [ Modules]
  */
@@ -18,14 +17,16 @@ import paymentsPurchasesSupplier from '@/store/modules/PaymentsPurchasesSupplier
 import paymentsPurchasesJournals from '@/store/modules/PaymentsPurchasesJournals'
 import paymentsPurchasesCurrencies from '@/store/modules/PaymentsPurchasesCurrencies'
 import supplierInvoices from '@/store/modules/SupplierInvoices'
-import SupplierMoveLines from '@/store/modules/SupplierMoveLines'
+import supplierMoveLines from '@/store/modules/SupplierMoveLines'
 import supplierPayments from '@/store/modules/supplierPayments'
 
-
 Vue.use(Vuex)
 
 const store = new Vuex.Store({
     actions,
+    getters,
+    mutations,
+    state,
     modules: {
         paymentsPurchasesDate,
         paymentsPurchasesUser,
@@ -34,7 +35,7 @@ const store = new Vuex.Store({
         paymentsPurchasesJournals,
         paymentsPurchasesCurrencies,
         supplierInvoices,
-        SupplierMoveLines,
+        supplierMoveLines,
         supplierPayments
     }
 })

+ 15 - 2
src/store/modules/PaymentsPurchasesCompany.js

@@ -1,7 +1,13 @@
 /* Actions*/
-import { INIT_COMPANY_USER } from '@/constants/actionTypes'
+import {
+    INIT_COMPANY_USER,
+    RESET_PAYMENTS_PURCHASES_COMPANY
+} from '@/constants/actionTypes'
 /* Mutations*/
-import { SET_COMPANY_USER, SET_CURRENCY_COMPANY } from '@/constants/mutationTypes'
+import {
+    SET_COMPANY_USER,
+    SET_CURRENCY_COMPANY
+} from '@/constants/mutationTypes'
 
 const initialState = {
     company: [],
@@ -56,6 +62,13 @@ const actions = {
     [INIT_COMPANY_USER] ({ commit }, payload ) {
         commit(SET_COMPANY_USER, payload.company)
         commit(SET_CURRENCY_COMPANY, payload.currency)
+    },
+    /**
+     *
+     */
+    [RESET_PAYMENTS_PURCHASES_COMPANY] ({ commit }) {
+        commit(SET_COMPANY_USER, [])
+        commit(SET_CURRENCY_COMPANY, [])
     }
 }
 

+ 17 - 2
src/store/modules/PaymentsPurchasesCurrencies.js

@@ -1,5 +1,13 @@
-import { INIT_PAYMENTS_PURCHASES_CURRENCIES } from '@/constants/actionTypes'
-import { SET_CURRENCIES,  SET_LOADING_CURRENCIES }from '@/constants/mutationTypes'
+/* Actions */
+import {
+    INIT_PAYMENTS_PURCHASES_CURRENCIES,
+    RESET_PAYMENTS_PURCHASES_CURRENCIES
+} from '@/constants/actionTypes'
+/* Mutations */
+import {
+    SET_CURRENCIES,
+    SET_LOADING_CURRENCIES
+}from '@/constants/mutationTypes'
 
 const initialState = {
     currency: [],
@@ -43,6 +51,13 @@ const actions = {
     [INIT_PAYMENTS_PURCHASES_CURRENCIES] ({ commit }, payload) {
         commit(SET_CURRENCIES, payload)
         commit(SET_LOADING_CURRENCIES, payload)
+    },
+    /**
+     * [RESET_PAYMENTS_PURCHASES_CURRENCIES]
+     */
+    [RESET_PAYMENTS_PURCHASES_CURRENCIES] ({ commit }) {
+        commit(SET_CURRENCIES, [])
+        commit(SET_LOADING_CURRENCIES, false)
     }
 }
 

+ 11 - 1
src/store/modules/PaymentsPurchasesDate.js

@@ -1,4 +1,7 @@
-import { INIT_PAYMENTS_PURCHASES_DATE } from '@/constants/actionTypes'
+import {
+    INIT_PAYMENTS_PURCHASES_DATE,
+    RESET_PAYMENTS_PURCHASES_DATE
+} from '@/constants/actionTypes'
 import { SET_DATE, SET_LOADING_DATE } from '@/constants/mutationTypes'
 
 const initialState = {
@@ -54,6 +57,13 @@ const actions = {
     [INIT_PAYMENTS_PURCHASES_DATE] ({ commit }, payload) {
         commit(SET_DATE, payload)
         commit(SET_LOADING_DATE, payload)
+    },
+    /**
+     * [RESET_PAYMENTS_PURCHASES_DATE] 
+     */
+    [RESET_PAYMENTS_PURCHASES_DATE] ({ commit }) {
+        commit(SET_DATE, [] )
+        commit(SET_LOADING_DATE, false)
     }
 }
 

+ 18 - 2
src/store/modules/PaymentsPurchasesJournals.js

@@ -1,5 +1,14 @@
-import { INIT_PAYMENTS_PURCHASES_JOURNALS, INIT_PAYMENTS_JOURNALS } from '@/constants/actionTypes'
-import { SET_JOURNALS ,SET_LOADING_JOURNALS } from '@/constants/mutationTypes'
+/* Actions */
+import {
+    INIT_PAYMENTS_PURCHASES_JOURNALS,
+    INIT_PAYMENTS_JOURNALS,
+    RESET_PAYMENTS_PURCHASES_JOURNALS
+ } from '@/constants/actionTypes'
+/* Mutations*/
+import {
+    SET_JOURNALS,
+    SET_LOADING_JOURNALS
+} from '@/constants/mutationTypes'
 
 const initialState = {
     journals : null,
@@ -56,6 +65,13 @@ const mutations = {
          commit(SET_LOADING_JOURNALS, payload)
 
          dispatch(INIT_PAYMENTS_JOURNALS, payload)
+     },
+     /**
+      * [RESET_PAYMENTS_PURCHASES_JOURNALS]
+      */
+     [RESET_PAYMENTS_PURCHASES_JOURNALS] ({ commit }) {
+        commit(SET_JOURNALS, [])
+        commit(SET_LOADING_JOURNALS, false)
      }
  }
 

+ 12 - 1
src/store/modules/PaymentsPurchasesSupplier.js

@@ -3,7 +3,8 @@ import {
     INIT_PAYMENTS_PURCHASES_SUPPLIER,
     FILTER_PAYMENTS_PURCHASES_SUPPLIER,
     SELECT_PAYMENTS_PURCHASES_SUPPLIER,
-    INIT_SUPPLIER_INVOICES
+    INIT_SUPPLIER_INVOICES,
+    RESET_PAYMENTS_PURCHASES_SUPPLIER
 } from '@/constants/actionTypes'
 // Mutations
 import {
@@ -114,9 +115,19 @@ const actions = {
         commit(SET_SELECTED_PAYMENTS_PURCHASES_SUPPLIER, payload)
 
         dispatch(INIT_SUPPLIER_INVOICES, payload.invoices)
+    },
+    /**
+     * [RESET_PAYMENTS_PURCHASES_SUPPLIER]
+     */
+    [RESET_PAYMENTS_PURCHASES_SUPPLIER] ({ commit}) {
+        commit(SET_SUPPLIER, [])
+        commit(SET_LOADING_SUPPLIER, true)
+        commit(SET_FILTER_PAYMENTS_PURCHASES_SUPPLIER, [])
+        commit(SET_SELECTED_PAYMENTS_PURCHASES_SUPPLIER, null)
     }
 }
 
+
 export default {
     state,
     getters,

+ 20 - 2
src/store/modules/PaymentsPurchasesUser.js

@@ -1,5 +1,14 @@
-import { INIT_PAYMENTS_PURCHASES_USER, INIT_COMPANY_USER } from '@/constants/actionTypes'
-import { SET_USER, SET_LOADING_USER } from '@/constants/mutationTypes'
+
+import {
+    INIT_PAYMENTS_PURCHASES_USER,
+    INIT_COMPANY_USER,
+    RESET_PAYMENTS_PURCHASES_USER
+} from '@/constants/actionTypes'
+
+import {
+    SET_USER,
+    SET_LOADING_USER
+} from '@/constants/mutationTypes'
 
 const initialState = {
     user: [],
@@ -53,7 +62,16 @@ const actions = {
         commit(SET_LOADING_USER, payload)
 
         dispatch(INIT_COMPANY_USER, payload)
+    },
+    /**
+     *  [RESET_PAYMENTS_PURCHASES_USER]
+     */
+    [RESET_PAYMENTS_PURCHASES_USER] ({ commit }) {
+        commit(SET_USER, [])
+        commit(SET_LOADING_USER, false)
     }
+
+
 }
 
 export default {

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

@@ -4,7 +4,8 @@ import {
     FILTER_SUPPLIER_INVOICES,
     SELECT_SUPPLIER_INVOICES,
     INIT_SUPPLIER_MOVE_LINES,
-    ADD_MOVE_IN_INVOICE
+    ADD_MOVE_IN_INVOICE,
+    RESET_SUPPLIER_INVOICES
 } from '@/constants/actionTypes'
 /* Mutations */
 import {
@@ -124,7 +125,7 @@ const actions = {
     [SELECT_SUPPLIER_INVOICES] ({commit, dispatch}, payload) {
         commit(SET_SELECTED_SUPPLIER_INVOICES, payload)
         commit(SET_CURRENCY_INVOICE, payload.currencyInvoice)
-        
+
         dispatch(INIT_SUPPLIER_MOVE_LINES, payload.moveLines)
     },
     /**
@@ -132,6 +133,15 @@ const actions = {
      */
     [ADD_MOVE_IN_INVOICE] ({ commit },payload ) {
         commit(SET_MOVE_IN_INVOICE, payload)
+    },
+    /**
+     * [RESET_SUPPLIER_INVOICES]
+     */
+    [RESET_SUPPLIER_INVOICES] ({ commit }) {
+        commit(SET_SUPPLIER_INVOICES, [])
+        commit(SET_SELECTED_SUPPLIER_INVOICES, null)
+        commit(SET_FILTER_SUPPLIER_INVOICES, [])
+        commit(SET_CURRENCY_INVOICE, [])
     }
 }
 

+ 69 - 8
src/store/modules/SupplierMoveLines.js

@@ -5,7 +5,10 @@ import {
     ACTION_REMOVE_SUPPLIER_LINES_PAYMENTS,
     ADD_MOVE_IN_INVOICE,
     ADD_PAYMENTS_MOVE_LINES,
-    REMOVE_PAYMENTS_MOVE_LINES
+    REMOVE_PAYMENTS_MOVE_LINES,
+    RESET_SUPPLIER_MOVE_LINES,
+    ACTION_REMOVE_ALL_SUPPLIER_LINES_PAYMENTS,
+    RESET_SELECTED_JOURNAL_PAYMENTS
 } from '@/constants/actionTypes'
 /* Mutations */
 import {
@@ -16,7 +19,8 @@ import {
     SET_ORDER_SUPPLIER_MOVE_LINES,
     SET_ORDER_SUPPLIER_LINES_PAYMENTS,
     SET_CALCULATE_TOTAL,
-    REMOVE_SUPPLIER_LINES_PAYMENTS
+    REMOVE_SUPPLIER_LINES_PAYMENTS,
+    REMOVE_LINES_PAYMENTS
 } from '@/constants/mutationTypes'
 
 const intialState = {
@@ -75,7 +79,10 @@ const mutations = {
     [SET_SELECTED_SUPPLIER_MOVE_LINES] ( state, payload) {
         state.selectdLines = payload
     },
-
+    /**
+     * [supplierLinesPayments description]
+     * @type {Array}
+     */
     [SET_SUPPLIER_LINES_PAYMENTS] (state, payload) {
         state.supplierLinesPayments = [payload, ...state.supplierLinesPayments]
     },
@@ -97,7 +104,7 @@ const mutations = {
                 //ADD supplierMoveLines
                 let movesFound = state.supplierMoveLines.find(item => item.id === moves.id)
                 if (movesFound) return
-                state.supplierMoveLines = [move, ...state.supplierMoveLines]
+                state.supplierMoveLines = [moves, ...state.supplierMoveLines]
                 // Remove Payments
                 let movesPaymentsIndex = state.supplierLinesPayments.findIndex(item => item.id === moves.id)
                 state.supplierLinesPayments.splice(movesPaymentsIndex)
@@ -112,6 +119,23 @@ const mutations = {
             state.supplierLinesPayments.splice(movesPaymentsIndex, 1)
         }
     },
+    /**
+     * [mode description]
+     * @type {[type]}
+     */
+    [REMOVE_LINES_PAYMENTS] (state, payload ) {
+        if (payload.mode === 'full') {
+            payload.moveLines.forEach(moves => {
+                // Remove Payments
+                let movesPaymentsIndex = state.supplierLinesPayments.findIndex(item => item.id === moves.id)
+                state.supplierLinesPayments.splice(movesPaymentsIndex)
+            })
+        } else {
+            // Remove Payments
+            let movesPaymentsIndex = state.supplierLinesPayments.findIndex(item => item.id === payload.moveLines.id)
+            state.supplierLinesPayments.splice(movesPaymentsIndex, 1)
+        }
+    },
     /**
      * [amountTot description]
      * @type {[type]}
@@ -160,12 +184,9 @@ const actions = {
         // payments
         commit(SET_SUPPLIER_LINES_PAYMENTS, payload)
         commit(SET_ORDER_SUPPLIER_LINES_PAYMENTS)
-        // Move  Lines
         commit(SET_SELECTED_SUPPLIER_MOVE_LINES, payload)
         commit(REMOVE_SUPPLIER_MOVE_LINES, payload)
-        // Total
         commit(SET_CALCULATE_TOTAL)
-
         dispatch(ADD_PAYMENTS_MOVE_LINES, payload)
     },
     /**
@@ -181,13 +202,53 @@ const actions = {
             mode: 'partial',
             moveLines: payload
         })
-
         dispatch(REMOVE_PAYMENTS_MOVE_LINES, {
             mode: 'partial',
             moveLines: payload
         })
+        // Total
+        commit(SET_CALCULATE_TOTAL)
+        commit(SET_ORDER_SUPPLIER_MOVE_LINES)
+    },
+    /**
+     * [mode description]
+     * @type {String}
+     */
+    [ACTION_REMOVE_ALL_SUPPLIER_LINES_PAYMENTS] ({ commit, dispatch, getters }) {
 
+        dispatch(ADD_MOVE_IN_INVOICE, {
+            mode: 'full',
+            moveLines: getters.supplierLinesPayments.map(item => {
+                return item
+            })
+        })
+        dispatch(REMOVE_PAYMENTS_MOVE_LINES, {
+            mode: 'full',
+            moveLines: getters.supplierLinesPayments.map(item => {
+                return item
+            })
+        })
+        dispatch(RESET_SELECTED_JOURNAL_PAYMENTS)
+        commit(REMOVE_SUPPLIER_LINES_PAYMENTS, {
+            mode: 'full',
+            moveLines: getters.supplierLinesPayments.map(item => {
+                return item
+            })
+        })
+        commit(SET_CALCULATE_TOTAL)
         commit(SET_ORDER_SUPPLIER_MOVE_LINES)
+    },
+    /**
+     * [RESET_SUPPLIER_MOVE_LINES]
+     */
+    [RESET_SUPPLIER_MOVE_LINES] ({ commit, getters }){
+        commit(SET_SUPPLIER_MOVE_LINES, [])
+        commit(SET_SELECTED_SUPPLIER_MOVE_LINES, [])
+        commit(REMOVE_LINES_PAYMENTS, {
+                mode: 'full',
+                moveLines:getters.supplierLinesPayments
+        })
+        commit(SET_CALCULATE_TOTAL)
     }
 }
 

+ 67 - 9
src/store/modules/supplierPayments.js

@@ -4,7 +4,9 @@ import {
     SELECT_PAYMENTS_JOURNALS,
     ADD_PAYMENTS_MOVE_LINES,
     REMOVE_PAYMENTS_MOVE_LINES,
-    CHANGE_INITIAL_PAID
+    CHANGE_INITIAL_PAID,
+    RESET_SUPPLIER_PAYMENTS,
+    RESET_SELECTED_JOURNAL_PAYMENTS
 } from '@/constants/actionTypes'
 /* Mutations */
 import {
@@ -14,7 +16,8 @@ import {
     CALCULATE_CURRENCY_AMOUNT,
     SET_ADD_PAYMENTS_MOVE_LINES,
     SET_REMOVE_PAYMENTS_MOVE_LINES,
-    SET_PAID_TOTAL
+    SET_PAID_TOTAL,
+    SET_PAYMENTS_CURRENCY_JOURNAL
 } from '@/constants/mutationTypes'
 
 const initialState = {
@@ -22,6 +25,7 @@ const initialState = {
     paymentsSelectedJournal: null,
     paymentsMoveLines: [],
     paymentsCurrencyAmount: [],
+    paymentsCurrencyJournal: null,
     paymentsTotal: 0,
     paidTotal: 0,
     paymentsReturned: 0
@@ -31,6 +35,7 @@ const state = {
     paymentsSelectedJournal: initialState.paymentsSelectedJournal,
     paymentsMoveLines: initialState.paymentsMoveLines,
     paymentsCurrencyAmount : initialState.paymentsCurrencyAmount,
+    paymentsCurrencyJournal: initialState.paymentsCurrencyJournal,
     paymentsTotal: initialState.paymentsTotal,
     paidTotal: initialState.paidTotal,
     paymentsReturned: initialState.paymentsReturned
@@ -87,6 +92,14 @@ const getters = {
     },
     paidTotal ( state ) {
         return state.paidTotal
+    },
+    /**
+     * [paymentsCurrencyJournal description]
+     * @param  {[type]} state [description]
+     * @return {[type]}       [description]
+     */
+    paymentsCurrencyJournal ( state ) {
+        return state.paymentsCurrencyJournal
     }
 }
 
@@ -164,9 +177,9 @@ const mutations = {
      */
     [CALCULATE_PAYMENTS_TOTAL] ( state, payload){
         let currencyJournal = payload.paymentsCurrencyAmount.find(item => item.id ===payload.currency.id)
-        let total = currencyJournal.amount
-        if (!currencyJournal)
-            total = 0
+        let total = 0
+        if (currencyJournal)
+            total = currencyJournal.amount
         state.paymentsTotal = total
     },
     /**
@@ -176,6 +189,13 @@ const mutations = {
     [SET_PAID_TOTAL] (state, payload) {
         state.paidTotal = payload
     },
+    /**
+     * [paymentsCurrencyJournal description]
+     * @type {[type]}
+     */
+    [SET_PAYMENTS_CURRENCY_JOURNAL] ( state, payload ){
+        state.paymentsCurrencyJournal = payload
+    }
 }
 
 const actions = {
@@ -200,34 +220,72 @@ const actions = {
         commit(CALCULATE_PAYMENTS_TOTAL, {
             paymentsCurrencyAmount: getters.paymentsCurrencyAmount,
             currency: currency
-        } )
+        })
+
+        commit(SET_PAYMENTS_CURRENCY_JOURNAL, currency)
+    },
+    /**
+     * [paymentsCurrencyAmount description]
+     * @type {Array}
+     */
+    [RESET_SELECTED_JOURNAL_PAYMENTS] ({ commit }) {
+        commit(SELECTED_PAYMENTS_JOURNALS, [])
+        commit(CALCULATE_PAYMENTS_TOTAL, {
+            paymentsCurrencyAmount: [],
+            currency: []
+        })
+        commit(SET_PAYMENTS_CURRENCY_JOURNAL, [])
     },
     /**
      * [ADD_PAYMENTS_MOVE_LINES]
      */
-    [ADD_PAYMENTS_MOVE_LINES] ({ commit, getters }, payload ) {
+    [ADD_PAYMENTS_MOVE_LINES] ({ commit, getters, dispatch }, payload ) {
         commit(SET_ADD_PAYMENTS_MOVE_LINES, payload)
         commit(CALCULATE_CURRENCY_AMOUNT, {
             paymentsMoveLines: getters.paymentsMoveLines,
             currency: getters.currency
         })
+        dispatch(RESET_SELECTED_JOURNAL_PAYMENTS, [])
     },
     /**
      * [REMOVE_PAYMENTS_MOVE_LINES]
      */
-    [REMOVE_PAYMENTS_MOVE_LINES] ({ commit, getters }, payload ) {
+    [REMOVE_PAYMENTS_MOVE_LINES] ({ commit, getters, dispatch }, payload ) {
         commit(SET_REMOVE_PAYMENTS_MOVE_LINES, payload)
         commit(CALCULATE_CURRENCY_AMOUNT, {
             paymentsMoveLines: getters.paymentsMoveLines,
             currency: getters.currency
         })
+        dispatch(RESET_SELECTED_JOURNAL_PAYMENTS, [])
+
     },
     /**
-     * 
+     * [CHANGE_INITIAL_PAID]
      */
     [CHANGE_INITIAL_PAID] ({ commit },payload) {
         commit(SET_PAID_TOTAL, payload)
     },
+    /**
+     * [RESET_SUPPLIER_PAYMENTS]
+     */
+    [RESET_SUPPLIER_PAYMENTS] ({ commit, getters }) {
+        commit(SET_PAYMENTS_JOURNALS, [])
+        commit(SELECTED_PAYMENTS_JOURNALS, [])
+        commit(SET_REMOVE_PAYMENTS_MOVE_LINES, {
+            mode: 'full',
+            moveLines: getters.paymentsMoveLines
+        })
+        commit(CALCULATE_CURRENCY_AMOUNT, {
+            currency: [],
+            paymentsMoveLines: []
+        })
+        commit(SET_PAYMENTS_CURRENCY_JOURNAL, [])
+        commit(CALCULATE_PAYMENTS_TOTAL, {
+            paymentsCurrencyAmount: [],
+            currency: []
+        })
+        commit(SET_PAID_TOTAL , 0)
+    }
 }
 
 export default {

+ 23 - 0
src/store/mutations.js

@@ -0,0 +1,23 @@
+import {
+    SET_COMPLETED_PAYMENTS_PURCHASES,
+    SET_PROCESSING_PAYMENTS_PURCHASES
+} from '@/constants/mutationTypes'
+
+const mutations = {
+    /**
+     * [completedPaymentsPurchases description]
+     * @type {[type]}
+     */
+    [SET_PROCESSING_PAYMENTS_PURCHASES] (state, payload ) {
+        state.processingPaymentsPurchases = payload
+    },
+    /**
+     * [completedPaymentsPurchases description]
+     * @type {[type]}
+     */
+    [SET_COMPLETED_PAYMENTS_PURCHASES] ( state, payload ) {
+        state.completedPaymentsPurchases = payload
+    }
+}
+
+export default mutations

+ 6 - 0
src/store/state.js

@@ -0,0 +1,6 @@
+const state = {
+    processingPaymentsPurchases: false,
+    completedPaymentsPurchases: false
+}
+
+export default state

+ 0 - 1
views/templates.xml

@@ -4,7 +4,6 @@
         <template id="eiru_payments_purchases.assets" name="Eiru Payment Purchases Assets" inherit_id="eiru_assets.assets">
             <xpath expr="." position="inside">
                 <link rel="stylesheet" href="/eiru_payments_purchases/static/src/main.css" />
-                <script src="http://192.168.88.130:8075/livereload.js"></script>
                 <script type="text/javascript" src="/eiru_payments_purchases/static/src/main.js"></script>
             </xpath>
         </template>