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

Proposed by Sébastien BEAU - http://www.akretion.com
Status: Merged
Merged at revision: 113
Proposed branch: lp:~akretion-team/banking-addons/bank-statement-reconcile-70-improve-import
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 124 lines (+50/-5)
4 files modified
account_statement_base_import/parser/parser.py (+36/-0)
account_statement_base_import/statement.py (+11/-3)
account_statement_base_import/wizard/import_statement.py (+1/-0)
account_statement_commission/commission.py (+2/-2)
To merge this branch: bzr merge lp:~akretion-team/banking-addons/bank-statement-reconcile-70-improve-import
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza Approve
Frederic Clementi - Camptocamp functionnal Approve
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Nicolas Bessi - Camptocamp Pending
Review via email: mp+197759@code.launchpad.net

Description of the change

Hi
I just add some function in order to be able to fill the balance, the name and the date of the bank statement based on the data of the file parsed.

To post a comment you must log in.
106. By Sébastien BEAU - http://www.akretion.com

[REF] add a prepare method for custom for creating the bank statement

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi Sebastien,

Thanks for the contribs ! Just a little remark on lines 45 to 57, you should review and adpat your comment.

Otherwise LGTM.

Regards,

Joël

review: Approve (code review, no tests)
Revision history for this message
Frederic Clementi - Camptocamp (frederic-clementi) wrote :

Ok for me

review: Approve (functionnal)
107. By Florian da Costa

[FIX] Change some methods description

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I also approved the changes. There is one similar MP from Laurent Mignon of Acsone that I have redirected to here:

https://code.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-import-statement-hook/+merge/201732

I proceed with the merge now, and if anyone discover any problem or improvement, can comment here or in another MP.

Regards.

review: Approve
Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

Hi,

The proposal covers an identical need that the one I've proposed. I'm not comfortable with your approach. Values available from the parser for the statement are 'hard coded' in the parser and the profile call one by one each method defined on the parser to fill the dictionary used for the statement creation. I've the feeling that it's the responsibility of the parser to fill this dictionary. The profile is just there to do the glue between the parser and the importation logic.
With your proposal, if I have a parser able to provide more info than the four now available via the new API, I need to override the parser AND the profile.
What do you think of my proposal? https://code.launchpad.net/~acsone-openerp/banking-addons/bank-statement-reconcile-70-import-statement-hook/+merge/201732

Regards,

lmi

Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hi,

Note to self: look into existing MP before contributing.

That said, I looked at both proposals, and I believe Laurent's approach is indeed more extensible. It also mirrors closely the approach for statement lines (get_st_line_vals) with the same approch for the statement (get_st_vals).

Best regards,

-sbi

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

@Pedro Wasn't it a bit expeditive to merge it without waiting for Acsone eyes to see it?

@Laurent & Stéphane To sum up do we need to revert and set it to Need Fixing to try to converge both MP?
Or are you willing to improve this in an other MP?

Cheers

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Sorry if I bother you, but my intention was to close this MP (because it already had two approvals) and then make another one if there is improvement, as we can see that there is room for this. Tonight, I'm going to propose a new MP with Laurent's remarks, because reverting things is a little odd.

Regards.

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

@Pedro, no stress. contribution is not competition. Contribution is a nice way to improve our experience and get better quality and functionalities.

@Yannick. No need to revert. I'll improve my merge proposal and I'll include your needs. Just a little question. At line 70 you doesn't use the statement_date from the parser for the statement date but you use it at line 114 for the commission line. Is this an oversight?

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

I'm not in Sébastien's head so I let him answer to the question :)

Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) wrote :

Laurent
Yes your right it have been lost during the merge proposal.

You fix it with your next merge proposal? Or I propose a small merge for adding it?

Thanks

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote :

I'll fix it ;)

On Tue, Jan 21, 2014 at 1:53 PM, Sébastien BEAU - http://www.akretion.com <
<email address hidden>> wrote:

> Laurent
> Yes your right it have been lost during the merge proposal.
>
> You fix it with your next merge proposal? Or I propose a small merge for
> adding it?
>
> Thanks
>
> --
>
> https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-70-improve-import/+merge/197759
> You are subscribed to branch
> lp:banking-addons/bank-statement-reconcile-7.0.
>

--
*Laurent Mignon*
*Senior Software Engineer*

*Tel : +352 20 21 10 20 32*
*Fax : +352 20 21 10 21*
*Gsm : +352 691 506 009*
*Email: <email address hidden> <email address hidden>*

*Acsone SA, Succursale de Luxembourg*
*22, Zone industrielle*
*L-8287 Kehlen, Luxembourg*
*www.acsone.eu <http://www.acsone.eu>*

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Laurent, how is the state of this MP?

Regards.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_statement_base_import/parser/parser.py'
2--- account_statement_base_import/parser/parser.py 2013-05-03 19:57:26 +0000
3+++ account_statement_base_import/parser/parser.py 2013-12-11 19:12:22 +0000
4@@ -20,6 +20,7 @@
5 ##############################################################################
6 import base64
7 import csv
8+from datetime import datetime
9
10
11 def UnicodeDictReader(utf8_data, **kwargs):
12@@ -49,6 +50,10 @@
13 self.result_row_list = None
14 # The file buffer on which to work on
15 self.filebuffer = None
16+ self.balance_start = None
17+ self.balance_end = None
18+ self.statement_name = None
19+ self.statement_date = None
20
21 @classmethod
22 def parser_for(cls, parser_name):
23@@ -150,6 +155,37 @@
24 self._post(*args, **kwargs)
25 return self.result_row_list
26
27+ def get_start_balance(self, *args, **kwargs):
28+ """
29+ This is called by the importation method to set the balance start
30+ amount in the bank statement.
31+ return: float of the balance start (self.balance_start)
32+ """
33+ return self.balance_start
34+
35+ def get_end_balance(self, *args, **kwargs):
36+ """
37+ This is called by the importation method to set the balance end
38+ amount in the bank statement.
39+ return: float of the balance end (self.balance_end)
40+ """
41+ return self.balance_end
42+
43+ def get_statement_name(self, *args, **kwargs):
44+ """
45+ This is called by the importation method to set the statement
46+ name in the bank statement.
47+ return: string of the statement name (self.statement_name)
48+ """
49+ return self.statement_name or '/'
50+
51+ def get_statement_date(self, *args, **kwargs):
52+ """
53+ This is called by the importation method to set the statement
54+ date in the bank statement.
55+ return: datetime of the statement date (self.statement_date)
56+ """
57+ return self.statement_date or datetime.now()
58
59 def itersubclasses(cls, _seen=None):
60 """
61
62=== modified file 'account_statement_base_import/statement.py'
63--- account_statement_base_import/statement.py 2013-09-12 09:05:01 +0000
64+++ account_statement_base_import/statement.py 2013-12-11 19:12:22 +0000
65@@ -126,6 +126,15 @@
66 values['type'] = 'general'
67 return values
68
69+
70+ def _prepare_statement_vals(self, cr, uid, prof, parser, context=None):
71+ return {
72+ 'profile_id': prof.id,
73+ 'name': parser.get_statement_name(),
74+ 'balance_start': parser.get_start_balance(),
75+ 'balance_end_real': parser.get_end_balance(),
76+ }
77+
78 def statement_import(self, cr, uid, ids, profile_id, file_stream, ftype="csv", context=None):
79 """
80 Create a bank statement with the given profile and parser. It will fullfill the bank statement
81@@ -159,9 +168,8 @@
82 _("Column %s you try to import is not "
83 "present in the bank statement line!") % col)
84
85- statement_id = statement_obj.create(cr, uid,
86- {'profile_id': prof.id},
87- context=context)
88+ st_vals = self._prepare_statement_vals(cr, uid, prof, parser, context=context)
89+ statement_id = statement_obj.create(cr, uid, st_vals, context=context)
90 if prof.receivable_account_id:
91 account_receivable = account_payable = prof.receivable_account_id.id
92 else:
93
94=== modified file 'account_statement_base_import/wizard/import_statement.py'
95--- account_statement_base_import/wizard/import_statement.py 2013-07-08 18:03:34 +0000
96+++ account_statement_base_import/wizard/import_statement.py 2013-12-11 19:12:22 +0000
97@@ -97,6 +97,7 @@
98 req_id = req_id[0]
99 importer = self.browse(cr, uid, req_id, context)
100 ftype = self._check_extension(importer.file_name)
101+ context['file_name'] = importer.file_name
102 sid = self.pool.get(
103 'account.statement.profile').statement_import(
104 cr,
105
106=== modified file 'account_statement_commission/commission.py'
107--- account_statement_commission/commission.py 2013-07-08 18:03:34 +0000
108+++ account_statement_commission/commission.py 2013-12-11 19:12:22 +0000
109@@ -22,7 +22,7 @@
110 commission_analytic_id = profile.commission_analytic_id and profile.commission_analytic_id.id or False
111 comm_values = {
112 'name': 'IN ' + _('Commission line'),
113- 'date': datetime.datetime.now().date(),
114+ 'date': parser.get_statement_date(),
115 'amount': global_commission_amount,
116 'partner_id': partner_id,
117 'type': 'general',
118@@ -65,4 +65,4 @@
119 c.commission_account_id and c.commission_account_id.id or False
120 res['value']['commission_a'] = \
121 c.commission_analytic_id and c.commission_analytic_id.id or False
122- return res
123\ No newline at end of file
124+ return res

Subscribers

People subscribed via source and target branches