Project

General

Profile

« Previous | Next » 

Revision 81066065

Added by Mikaël Ates over 11 years ago

facturation: update tests.

View differences:

calebasse/facturation/tests.py
91 91
        automated_validation(datetime(2020, 10, 7), service_camsp, self.creator)
92 92
        automated_validation(datetime(2020, 10, 8), service_camsp, self.creator)
93 93

  
94
        not_locked, days_not_locked, not_valide, not_billable, rejected, selected = \
94
        not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, selected = \
95 95
            list_acts_for_billing_CAMSP(datetime(2020, 10, 4), datetime(2020, 10, 8), service_camsp)
96 96

  
97 97
        self.assertEqual(len(days_not_locked), 1)
......
115 115

  
116 116
        states = patient_b.get_states_history()
117 117
        patient_b.change_day_selected_of_state(states[2], datetime(2020, 10, 7))
118
        not_locked, days_not_locked, not_valide, not_billable, rejected, selected = \
118
        not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, selected = \
119 119
            list_acts_for_billing_CAMSP(datetime(2020, 10, 4), datetime(2020, 10, 8), service_camsp)
120 120
        acts_not_locked = [x[0] for x in not_locked[patient_b]]
121 121
        self.assertTrue(act5 in acts_not_locked)
......
131 131
        states = patient_b.get_states_history()
132 132
        patient_b.change_day_selected_of_state(states[2], datetime(2020, 10, 9))
133 133
        patient_b.change_day_selected_of_state(states[1], datetime(2020, 10, 8))
134
        not_locked, days_not_locked, not_valide, not_billable, rejected, selected = \
134
        not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, selected = \
135 135
            list_acts_for_billing_CAMSP(datetime(2020, 10, 4), datetime(2020, 10, 8), service_camsp)
136 136
        acts_not_locked = [x[0] for x in not_locked[patient_b]]
137 137
        self.assertTrue(act5 in acts_not_locked)
......
172 172
        automated_validation(datetime(2020, 10, 7), service_sessad, self.creator)
173 173
        automated_validation(datetime(2020, 10, 8), service_sessad, self.creator)
174 174

  
175
        not_locked, days_not_locked, not_valide, not_billable, rejected, missing_valid_notification, selected = \
175
        not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, missing_valid_notification, selected = \
176 176
            list_acts_for_billing_SESSAD(datetime(2020, 10, 4), datetime(2020, 10, 8), service_sessad)
177 177
        self.assertEqual(not_locked, {})
178 178
        self.assertEqual(not_valide, {})
......
182 182
        self.assertEqual(selected, {})
183 183

  
184 184
        SessadHealthCareNotification(patient=patient_a, author=self.creator, start_date=datetime(2020,10,7), end_date=datetime(2021,10,6)).save()
185
        not_locked, days_not_locked, not_valide, not_billable, rejected, missing_valid_notification, selected = \
185
        not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, missing_valid_notification, selected = \
186 186
            list_acts_for_billing_SESSAD(datetime(2020, 10, 4), datetime(2020, 10, 8), service_sessad)
187 187
        self.assertEqual(not_locked, {})
188 188
        self.assertEqual(not_valide, {})
......
253 253

  
254 254
        billing_cmpp = list_acts_for_billing_CMPP_2(datetime(2020, 11, 30), service_cmpp)
255 255

  
256
        self.assertEqual(len(billing_cmpp[4][patient_a]), 6)
257
        self.assertEqual(len(billing_cmpp[5][patient_a]), 40)
258
        self.assertEqual(len(billing_cmpp[6][patient_a]), 15)
256
        self.assertEqual(len(billing_cmpp[5][patient_a]), 6)
257
        self.assertEqual(len(billing_cmpp[6][patient_a]), 40)
258
        self.assertEqual(len(billing_cmpp[7][patient_a]), 15)
259 259

  
260 260

  
261 261
    def test_prices(self):
262
        price_o = add_price(120)
262
        price_o = add_price(120, date(2012, 10, 1))
263 263
        self.assertEqual(PricePerAct.get_price(), 120)
264 264
        price_o = add_price(130, date.today())
265 265
        self.assertEqual(PricePerAct.get_price(date.today() + relativedelta(days=-1)), 120)
......
274 274

  
275 275
    def test_invoicing(self):
276 276
        service_cmpp = Service.objects.get(name='CMPP')
277
        price_o = add_price(120)
277
        price_o = add_price(120, date(2012, 10, 1))
278 278

  
279 279

  
280 280
        patients = []
281 281
        for j in range(2):
282
            patients.append(create_patient(str(j), str(j), service_cmpp, self.creator, date_selected=datetime(2020, 10, 1)))
282
            patients.append(create_patient(str(j), str(j), service_cmpp, self.creator, date_selected=datetime(2012, 10, 1)))
283 283
            acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patients[j], [self.therapist3],
284
                    self.act_type, service_cmpp, start_datetime=datetime(2020, 10, i, 10, 15),
285
                    end_datetime=datetime(2020, 10, i, 12, 20)) for i in range (1, 32)]
284
                    self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15),
285
                    end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (1, 32)]
286 286
            acts_2 = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patients[j], [self.therapist3],
287
                    self.act_type, service_cmpp, start_datetime=datetime(2020, 11, i, 10, 15),
288
                    end_datetime=datetime(2020, 11, i, 12, 20)) for i in range (1, 31)]
289
            hct = CmppHealthCareTreatment(patient=patients[j], start_date=datetime(2020, 10, 7), author=self.creator)
287
                    self.act_type, service_cmpp, start_datetime=datetime(2012, 11, i, 10, 15),
288
                    end_datetime=datetime(2012, 11, i, 12, 20)) for i in range (1, 31)]
289
            hct = CmppHealthCareTreatment(patient=patients[j], start_date=datetime(2012, 10, 7), author=self.creator)
290 290
            hct.save()
291 291
            hct.add_prolongation()
292 292

  
293 293
        for i in range(1, 32):
294
            automated_validation(datetime(2020, 10, i), service_cmpp, self.creator)
294
            automated_validation(datetime(2012, 10, i), service_cmpp, self.creator)
295 295
        for i in range(1, 31):
296
            automated_validation(datetime(2020, 11, i), service_cmpp, self.creator)
296
            automated_validation(datetime(2012, 11, i), service_cmpp, self.creator)
297 297

  
298
        self.assertEqual(get_days_with_acts_not_locked(datetime(2020, 10, 1), datetime(2020, 11, 30)), [])
298
        self.assertEqual(get_days_with_acts_not_locked(datetime(2012, 10, 1), datetime(2012, 11, 30)), [])
299 299
        invoicing = Invoicing.objects.create(service=service_cmpp, seq_id=666, start_date=date.today())
300 300
        (len_patients, len_invoices, len_invoices_hors_pause,
301
        len_acts_invoiced, len_acts_invoiced_hors_pause,
302
        len_patient_invoiced, len_patient_invoiced_hors_pause,
303
        len_acts_lost, len_patient_with_lost_acts, patients_stats, days_not_locked) = invoicing.get_stats_or_validate()
301
                len_acts_invoiced, len_acts_invoiced_hors_pause,
302
                len_patient_invoiced, len_patient_invoiced_hors_pause,
303
                len_acts_lost, len_patient_with_lost_acts, patients_stats,
304
                days_not_locked, len_patient_acts_paused,
305
                len_acts_paused) = invoicing.get_stats_or_validate()
304 306

  
305 307
        self.assertEqual(len_patients, 2)
306 308
        self.assertEqual(len_invoices, 4)
......
316 318
        patients[1].save()
317 319

  
318 320
        (len_patients, len_invoices, len_invoices_hors_pause,
319
        len_acts_invoiced, len_acts_invoiced_hors_pause,
320
        len_patient_invoiced, len_patient_invoiced_hors_pause,
321
        len_acts_lost, len_patient_with_lost_acts, patients_stats, days_not_locked) = invoicing.get_stats_or_validate()
321
                len_acts_invoiced, len_acts_invoiced_hors_pause,
322
                len_patient_invoiced, len_patient_invoiced_hors_pause,
323
                len_acts_lost, len_patient_with_lost_acts, patients_stats,
324
                days_not_locked, len_patient_acts_paused,
325
                len_acts_paused) = invoicing.get_stats_or_validate()
322 326

  
323 327
        self.assertEqual(len_patients, 2)
324 328
        self.assertEqual(len_invoices, 4)
......
330 334
        self.assertEqual(len_acts_lost, 30)
331 335
        self.assertEqual(len_patient_with_lost_acts, 2)
332 336

  
333
        invoicing_next = invoicing.close(date(day=30, month=11, year=2020))
337
        invoicing_next = invoicing.close(date(day=30, month=11, year=2012))
334 338

  
335 339
        (len_patients, len_invoices, len_invoices_hors_pause,
336
        len_acts_invoiced, len_acts_invoiced_hors_pause,
337
        len_patient_invoiced, len_patient_invoiced_hors_pause,
338
        len_acts_lost, len_patient_with_lost_acts, patients_stats, days_not_locked) = invoicing.get_stats_or_validate(commit=True)
340
                len_acts_invoiced, len_acts_invoiced_hors_pause,
341
                len_patient_invoiced, len_patient_invoiced_hors_pause,
342
                len_acts_lost, len_patient_with_lost_acts, patients_stats,
343
                days_not_locked, len_patient_acts_paused,
344
                len_acts_paused) = invoicing.get_stats_or_validate(commit=True)
339 345

  
340 346
        (len_patients, len_invoices, len_invoices_hors_pause,
341
        len_acts_invoiced, len_acts_invoiced_hors_pause,
342
        len_patient_invoiced, len_patient_invoiced_hors_pause,
343
        len_acts_lost, len_patient_with_lost_acts, patients_stats, days_not_locked) = invoicing.get_stats_or_validate()
347
                len_acts_invoiced, len_acts_invoiced_hors_pause,
348
                len_patient_invoiced, len_patient_invoiced_hors_pause,
349
                len_acts_lost, len_patient_with_lost_acts, patients_stats,
350
                days_not_locked, len_patient_acts_paused,
351
                len_acts_paused) = invoicing.get_stats_or_validate()
344 352

  
345 353
        self.assertEqual(len_patients, 1)
346 354
        self.assertEqual(len_invoices, 2)
......
348 356

  
349 357
        patients[1].pause = False
350 358
        patients[1].save()
351
        invoicing_next.close(date(day=2, month=12, year=2020))
359
        invoicing_next.close(date(day=2, month=12, year=2012))
352 360

  
353 361
        (len_patients, len_invoices, len_invoices_hors_pause,
354
        len_acts_invoiced, len_acts_invoiced_hors_pause,
355
        len_patient_invoiced, len_patient_invoiced_hors_pause,
356
        len_acts_lost, len_patient_with_lost_acts, patients_stats, days_not_locked) = invoicing_next.get_stats_or_validate()
362
                len_acts_invoiced, len_acts_invoiced_hors_pause,
363
                len_patient_invoiced, len_patient_invoiced_hors_pause,
364
                len_acts_lost, len_patient_with_lost_acts, patients_stats,
365
                days_not_locked, len_patient_acts_paused,
366
                len_acts_paused) = invoicing_next.get_stats_or_validate()
357 367

  
358 368
        self.assertEqual(len_patients, 2)
359 369
        self.assertEqual(len_invoices, 2)

Also available in: Unified diff