← Back to team overview

banking-addons-team team mailing list archive

lp:~akretion-team/banking-addons/bank-statement-reconcile-70-improve-import into lp:banking-addons/bank-statement-reconcile-7.0

 

Sébastien BEAU - http://www.akretion.com has proposed merging lp:~akretion-team/banking-addons/bank-statement-reconcile-70-improve-import into lp:banking-addons/bank-statement-reconcile-7.0.

Requested reviews:
  Banking Addons Core Editors (banking-addons-team)

For more details, see:
https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-70-improve-import/+merge/197759
-- 
https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-70-improve-import/+merge/197759
Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~akretion-team/banking-addons/bank-statement-reconcile-70-improve-import into lp:banking-addons/bank-statement-reconcile-7.0.
=== modified file 'account_statement_base_import/parser/parser.py'
--- account_statement_base_import/parser/parser.py	2013-05-03 19:57:26 +0000
+++ account_statement_base_import/parser/parser.py	2013-12-04 17:27:05 +0000
@@ -20,6 +20,7 @@
 ##############################################################################
 import base64
 import csv
+from datetime import datetime
 
 
 def UnicodeDictReader(utf8_data, **kwargs):
@@ -49,6 +50,10 @@
         self.result_row_list = None
         # The file buffer on which to work on
         self.filebuffer = None
+        self.balance_start = None
+        self.balance_end = None
+        self.statement_name = None
+        self.statement_date = None
 
     @classmethod
     def parser_for(cls, parser_name):
@@ -150,6 +155,37 @@
         self._post(*args, **kwargs)
         return self.result_row_list
 
+    def get_start_balance(self, *args, **kwargs):
+        """
+        This is called by the importation method to set the balance start
+        amount in the bank statement.
+            return: float of the balance start (self.balance_start)
+        """
+        return self.balance_start
+
+    def get_end_balance(self, *args, **kwargs):
+        """
+        This is called by the importation method to set the balance end
+        amount in the bank statement.
+            return: float of the balance end (self.balance_end)
+        """
+        return self.balance_end
+
+    def get_statement_name(self, *args, **kwargs):
+        """
+        This is called by the importation method to set the statement
+        date in the bank statement.
+            return: float of the balance start (self.balance_start)
+        """
+        return self.statement_name or '/'
+
+    def get_statement_date(self, *args, **kwargs):
+        """
+        This is called by the importation method to set the statement
+        date in the bank statement.
+            return: float of the balance start (self.balance_start)
+        """
+        return self.statement_date or datetime.now()
 
 def itersubclasses(cls, _seen=None):
     """

=== modified file 'account_statement_base_import/statement.py'
--- account_statement_base_import/statement.py	2013-09-12 09:05:01 +0000
+++ account_statement_base_import/statement.py	2013-12-04 17:27:05 +0000
@@ -158,10 +158,14 @@
                 raise osv.except_osv(_("Missing column!"),
                                      _("Column %s you try to import is not "
                                        "present in the bank statement line!") % col)
-
-        statement_id = statement_obj.create(cr, uid,
-                                            {'profile_id': prof.id},
-                                            context=context)
+        st_vals = {
+            'profile_id': prof.id,
+            'name': parser.get_statement_name(),
+            'balance_start': parser.get_start_balance(),
+            'balance_end_real': parser.get_end_balance(),
+        }
+ 
+        statement_id = statement_obj.create(cr, uid, st_vals, context=context)
         if prof.receivable_account_id:
             account_receivable = account_payable = prof.receivable_account_id.id
         else:

=== modified file 'account_statement_base_import/wizard/import_statement.py'
--- account_statement_base_import/wizard/import_statement.py	2013-07-08 18:03:34 +0000
+++ account_statement_base_import/wizard/import_statement.py	2013-12-04 17:27:05 +0000
@@ -97,6 +97,7 @@
             req_id = req_id[0]
         importer = self.browse(cr, uid, req_id, context)
         ftype = self._check_extension(importer.file_name)
+        context['file_name'] = importer.file_name
         sid = self.pool.get(
                 'account.statement.profile').statement_import(
                                             cr,

=== modified file 'account_statement_commission/commission.py'
--- account_statement_commission/commission.py	2013-07-08 18:03:34 +0000
+++ account_statement_commission/commission.py	2013-12-04 17:27:05 +0000
@@ -22,7 +22,7 @@
         commission_analytic_id = profile.commission_analytic_id and profile.commission_analytic_id.id or False
         comm_values = {
             'name': 'IN ' + _('Commission line'),
-            'date': datetime.datetime.now().date(),
+            'date': parser.get_statement_date(),
             'amount': global_commission_amount,
             'partner_id': partner_id,
             'type': 'general',
@@ -65,4 +65,4 @@
                 c.commission_account_id and c.commission_account_id.id or False
             res['value']['commission_a'] = \
                 c.commission_analytic_id and c.commission_analytic_id.id or False
-        return res
\ No newline at end of file
+        return res


Follow ups