~unifield-team/unifield-toolbox/test-perf-vg

« back to all changes in this revision

Viewing changes to finance_flow.py

  • Committer: vg at tempo-consulting
  • Date: 2015-02-18 14:07:55 UTC
  • Revision ID: vg@tempo-consulting.fr-20150218140755-cda1ck1nv0qo4tjy
[IMP] finance: je/ji mass gen for all active currencies

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    'unit',  # one entry for each register/ccy in first period
14
14
    'period',  # one entry for each register/ccy in all periods
15
15
    'fake',  # process virtually flow iterations, no entry generated
 
16
    'full_1st_period',  # full process of the first period (Jan of first FY)
16
17
)
17
 
TEST_MODE = 'unit'
 
18
TEST_MODE = 'full_1st_period'
18
19
 
19
20
MASK = {
20
21
    'register': "%s %s",
545
546
            self.proxy.get(analytic_obj).create(vals)
546
547
        return distrib_id
547
548
 
548
 
    def create_journal_entry(self, year, month, items_count, with_ad):
 
549
    def create_journal_entry(self, booking_ccy_id, year, month, items_count,
 
550
        with_ad):
549
551
        """
550
552
        create a JE (with items_count JI in it (expense and counterpart lines)
551
553
        :param with_ad: True if AD should be generated
574
576
            'status': 'manu',
575
577
            'name': name,
576
578
            'manual_name': name,
 
579
            'manual_currency_id': booking_ccy_id,
577
580
        }
578
581
        move_id = self.proxy.am.create(vals)
579
582
        if not move_id:
615
618
                'document_date': entry_date,
616
619
                'account_id': random_account_id,
617
620
                'name': name,
 
621
                'currency_id': booking_ccy_id,
618
622
                'amount_currency': random_amount,
619
623
            }
620
624
            if with_ad:
1065
1069
            self.direct_entries()
1066
1070
        
1067
1071
    def direct_entries(self):
 
1072
        ccy_ids = self.proxy.ccy.search([])
 
1073
        if not ccy_ids:
 
1074
            return
 
1075
        
1068
1076
        fy_start = self.get_cfg_int('fy_start')
1069
1077
        if TEST_MODE:
1070
1078
            fy_count = self.get_cfg_int('fy_count') \
1072
1080
        else:
1073
1081
            fy_count = self.get_cfg_int('fy_count')
1074
1082
        
1075
 
        je_per_month = 1 if TEST_MODE else self.get_cfg_int('je_per_month')
 
1083
        je_per_month = 1 if TEST_MODE and TEST_MODE != 'full_1st_period' \
 
1084
            else self.get_cfg_int('je_per_month')
1076
1085
        ji_min_count = self.get_cfg_int('ji_min_count')
1077
1086
        ji_max_count = self.get_cfg_int('ji_max_count')
1078
1087
        
1085
1094
                if TEST_MODE and TEST_MODE == 'fake':
1086
1095
                    continue
1087
1096
                
1088
 
                for je_index in xrange(0, je_per_month):
1089
 
                    # random count of ji for each je of the period
1090
 
                    ji_count = 2 if TEST_MODE else randrange(ji_min_count,
1091
 
                        ji_max_count)
1092
 
                    self.chrono_start('ji', year, m)
1093
 
                    self.create_journal_entry(year, m, ji_count,
1094
 
                        True)
1095
 
                    self.chrono_stop()
1096
 
                    if TEST_MODE and TEST_MODE == 'unit':
1097
 
                        return
 
1097
                for ccy_id in ccy_ids:
 
1098
                    for je_index in xrange(0, je_per_month):
 
1099
                        # random count of ji for each je of the period
 
1100
                        ji_count = 2 if TEST_MODE and \
 
1101
                            TEST_MODE != 'full_1st_period' \
 
1102
                            else randrange(ji_min_count, ji_max_count)
 
1103
                        self.chrono_start('ji', year, m)
 
1104
                        self.create_journal_entry(ccy_id, year, m, ji_count,
 
1105
                            True)
 
1106
                        self.chrono_stop()
 
1107
                        if TEST_MODE and TEST_MODE == 'unit':
 
1108
                            return
1098
1109
                        
1099
1110
                # update report at each period process (in case of crash)
1100
1111
                self.chrono_report('finance_direct_entries', ('ji', ))
 
1112
                if TEST_MODE == 'full_1st_period':
 
1113
                    return
1101
1114
            year_index += 1
1102
1115
            
1103
1116
 
1117
1130
        )
1118
1131
        
1119
1132
        fy_start = self.get_cfg_int('fy_start')
1120
 
        if TEST_MODE:
 
1133
        if TEST_MODE and TEST_MODE != 'full_1st_period':
1121
1134
            fy_count = self.get_cfg_int('fy_count') \
1122
1135
                if TEST_MODE != 'unit' else 1
1123
1136
            reg_expenses_max = 1
1189
1202
                # update report at each period process (in case of crash)
1190
1203
                self.chrono_report('finance_flow', report_entry_types)
1191
1204
                
1192
 
                if TEST_MODE and TEST_MODE == 'unit':
 
1205
                if TEST_MODE and TEST_MODE in ('unit', 'full_1st_period'):
1193
1206
                    break  # 1st period only
1194
 
            if TEST_MODE and TEST_MODE == 'unit':
 
1207
            if TEST_MODE and TEST_MODE in ('unit', 'full_1st_period'):
1195
1208
                break  # 1st FY only
1196
1209
            year_index += 1
1197
1210