8
by Andhitia Rama
Penambahan modul perhitungan backdate dari PT. SIS |
1 |
from datetime import datetime, timedelta, date |
2 |
from dateutil import parser |
|
3 |
from dateutil import rrule |
|
4 |
from dateutil.relativedelta import relativedelta |
|
5 |
from openerp.osv import fields, osv |
|
6 |
from openerp.service import web_services |
|
7 |
from openerp.tools.translate import _ |
|
8 |
import pytz |
|
9 |
import re |
|
10 |
import time |
|
11 |
import logging |
|
12 |
from openerp import tools, SUPERUSER_ID |
|
13 |
||
14 |
_logger = logging.getLogger(__name__) |
|
15 |
||
16 |
class bank_statement(osv.osv): |
|
17 |
_name = 'account.bank.statement.recalc' |
|
18 |
# _inherit = 'procurement.order'
|
|
19 |
_description = 'Kalkulasi ulang saldo Bank Statement' |
|
20 |
# _inherit = 'res.alarm'
|
|
21 |
__attribute__ = {} |
|
22 |
||
23 |
_columns = { |
|
24 |
'name' : fields.char('Reference'), |
|
25 |
'backdated_statement_id': fields.many2one('account.bank.statement', 'Bank Statement Reference', select=True), |
|
26 |
}
|
|
27 |
||
28 |
_defaults = {} |
|
29 |
||
30 |
def do_run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \ |
|
31 |
context=None): |
|
32 |
_logger.info("Start Scheduler Recalculate Backdated Transaction") |
|
33 |
||
34 |
cr.execute("select a.id, a.name, a.balance_start, a.total_entry_encoding, a.balance_end, a.date" |
|
35 |
" from account_bank_statement a "
|
|
36 |
" where a.state = 'confirm' "
|
|
37 |
" order by a.date asc, id asc") |
|
38 |
||
39 |
#datas = cr.fetchall()
|
|
40 |
datas = cr.dictfetchall() |
|
41 |
print 'datas ', datas |
|
42 |
idx = 0 |
|
43 |
tmp_balance_start=0 |
|
44 |
for rows in datas: |
|
45 |
if idx == 0: |
|
46 |
balance_start = rows['balance_start'] |
|
47 |
if rows['balance_start'] > 0 : |
|
48 |
balance_start = 0 |
|
49 |
else: |
|
50 |
balance_start = tmp_balance_start |
|
51 |
||
52 |
print 'balance_start : %s ' % balance_start |
|
53 |
||
54 |
balance_end = balance_start + rows['total_entry_encoding'] |
|
55 |
||
56 |
print 'balance_start : %s ' % balance_start |
|
57 |
||
58 |
#print "update account_bank_statement set balance_start = %s, balance_end= %s, balance_end_real= %s where id = %s " % (balance_start, balance_end, rows['id'])
|
|
59 |
||
60 |
cr.execute("update account_bank_statement " |
|
61 |
" set balance_start = %s, " |
|
62 |
" balance_end= %s, " |
|
63 |
" balance_end_real= %s " |
|
64 |
" where id = %s " % (balance_start, balance_end, balance_end, rows['id'])) |
|
65 |
idx += 1 |
|
66 |
||
67 |
tmp_balance_start = balance_end |
|
68 |
||
69 |
_logger.info("End Scheduler Recalculate Backdated Transaction") |
|
70 |
return True |
|
71 |
||
72 |
bank_statement() |
|
73 |