Ver código fonte

[FIX] bank statement creation

robert 5 anos atrás
pai
commit
9da8f89da7

+ 1 - 0
__openerp__.py

@@ -12,6 +12,7 @@
         'eiru_sidebar_toggler',
         'eiru_topbar_toggler',
         'eiru_bank_payments_references',
+        'eiru_payments_invoices',
         'multi_store',
         'multi_store_stock',
         'product_pack'

+ 8 - 5
controllers/main.py

@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 from openerp import http
-from openerp.http import request
+from openerp.http import request as r
 
 from http_response import make_gzip_response
 import logging
@@ -207,7 +207,7 @@ class PosSales(http.Controller):
             currency_id = get_currency(journal_id)
 
             if not currency_id:
-                currency_id = request.env.user.company_id.currency_id.id
+                currency_id = r.env.user.company_id.currency_id.id
 
             self.make_info_log('[OK] Getting journal')
 
@@ -268,7 +268,7 @@ class PosSales(http.Controller):
             self.make_info_log('[OK] Closing invoice')
 
             # Create bank statement
-            create_bank_statement(account_voucher.id, date_now)
+            invoice.create_bank_statement(date_now, r.context.get('uid'), account_voucher, None)
             self.make_info_log('[OK] Creating account bank statement')
             
             # Create bank payment statement
@@ -314,7 +314,7 @@ class PosSales(http.Controller):
             from res_bank_payment import create_bank_payment_statement
 
             # Payment term
-            sale_order = request.env['sale.order'].browse(sale_order_id)
+            sale_order = r.env['sale.order'].browse(sale_order_id)
             sale_order.write({
                 'payment_term': payment_term_id
             })
@@ -344,7 +344,7 @@ class PosSales(http.Controller):
             self.make_info_log('[OK] Closing invoice')
 
             # Create bank statement
-            create_bank_statement(account_voucher.id, date_now)
+            invoice.create_bank_statement(date_now, r.context.get('uid'), account_voucher, None)
             self.make_info_log('[OK] Creating account bank statement')
             
             # Create bank payment statement
@@ -384,6 +384,9 @@ class PosSales(http.Controller):
             payment_method = row.get('paymentMethod', 'Efectivo')
             bank_payment_data = row.get('bankPaymentData', {})
 
+            if warehouse_id is None:
+                warehouse_id = r.env['sale.order']._get_default_warehouse()
+
             if mode == 'budget':
                 finish_budget_pos(journal_id, customer_id, cart_items, date_now, payment_term_id, warehouse_id, customer_pricelist_id, user_id)
 

+ 3 - 3
models/__init__.py

@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
+import account_bank_statement
+import account_invoice_line
 import res_config
-# import account_invoice_line
+import sale_order_line
 import sale_order
-# import sale_order_line
-import account_bank_statement

+ 1 - 2
src/components/steps/Payment.vue

@@ -73,7 +73,7 @@
                     format='DD/MM/YYYY'
                     :clearable='false'
                     :editable='false'
-                    :not-before='firstPaymentAfterDate'
+                    :not-before='firstPaymentDate'
                 )
             //- input para el vuelto del pago en caso de pago en efectivo
             div(v-show="paymentType === 'cash'")
@@ -162,7 +162,6 @@
                 'paymentLines',
                 'firstPaymentDate',
                 'canChangeFirstPaymentDate',
-                'firstPaymentAfterDate',
                 'cartItems',
                 'paymentType',
                 'paymentTerm',

+ 1 - 19
src/store/modules/payment.js

@@ -10,7 +10,6 @@ const state = {
     amountResidual: 0,
     paymentLines: [],
     firstPaymentDate: new Date(),
-    firstPaymentAfterDate: new Date(),
     bankPaymentData: null,
 }
 
@@ -70,14 +69,6 @@ const getters = {
         return state.paymentLines
     },
     firstPaymentDate(state) {
-        if (state.paymentLines && state.paymentLines.length > 1) {
-            const date = new Date(state.paymentLines[0].date)
-
-            if (moment(date).isSameOrAfter(state.firstPaymentDate)) {
-                return date
-            }
-        }
-
         return state.firstPaymentDate
     },
     canChangeFirstPaymentDate(state, getters) {
@@ -87,9 +78,6 @@ const getters = {
 
         return changeDate && paymentType === 'credit' && paymentLines.length > 1
     },
-    firstPaymentAfterDate(state) {
-        return state.firstPaymentAfterDate
-    },
     bankPaymentData(state) {
         return state.bankPaymentData
     }
@@ -210,13 +198,7 @@ const mutations = {
         }
     },
     setFirstPaymentDate(state, paymentDate) {
-        paymentDate = moment(paymentDate).toDate()
-        state.firstPaymentDate = paymentDate
-        
-        if (moment(state.firstPaymentAfterDate).isSameOrBefore(paymentDate)) {   
-            state.firstPaymentAfterDate = moment(paymentDate).toDate()
-        }
-        console.log('ok')
+        state.firstPaymentDate = moment(paymentDate).toDate()
     },
     setBankPaymentData(state, bankPaymentData) {
         state.bankPaymentData = bankPaymentData