Exemple #1
0
 def test_case3(self):
     result = compute_total_cost(
         reading=160,
         data=[
             {
                 "start": date(2019, 2, 14),
                 "end": date(2019, 12, 31),
                 "we": 3,
                 "dom": 3,
             },
             {
                 "start": date(2020, 1, 1),
                 "end": date(2020, 2, 18),
                 "we": 3,
                 "dom": 3,
             },
         ],
         vat=0.0,
     )
     expected = 805.25
     self.assertAlmostEqual(result, expected, places=2)
Exemple #2
0
 def test_case6_vat(self):
     result = compute_total_cost(
         reading=365,
         data=[
             {
                 "start": date(2020, 2, 19),
                 "end": date(2020, 12, 31),
                 "we": 3,
                 "dom": 6,
             },
             {
                 "start": date(2021, 1, 1),
                 "end": date(2021, 2, 18),
                 "we": 3,
                 "dom": 6,
             },
         ],
         vat=0.06,
     )
     expected = 1887.73
     self.assertAlmostEqual(result, expected, places=2)
Exemple #3
0
 def test_case2_vat(self):
     result = compute_total_cost(
         reading=449,
         data=[
             {
                 "start": date(2019, 2, 14),
                 "end": date(2019, 12, 31),
                 "we": 3,
                 "dom": 5,
             },
             {
                 "start": date(2020, 1, 1),
                 "end": date(2020, 2, 18),
                 "we": 3,
                 "dom": 6,
             },
         ],
         vat=0.06,
     )
     expected = 2601.77
     self.assertAlmostEqual(result, expected, places=2)
Exemple #4
0
 def test_case5_vat(self):
     result = compute_total_cost(
         reading=292,
         data=[
             {
                 "start": date(2020, 2, 19),
                 "end": date(2020, 12, 31),
                 "we": 3,
                 "dom": 5,
             },
             {
                 "start": date(2021, 1, 1),
                 "end": date(2021, 2, 4),
                 "we": 3,
                 "dom": 6
             },
         ],
         vat=0.06,
     )
     expected = 1493.86
     self.assertAlmostEqual(result, expected, places=2)
Exemple #5
0
colors = []

fig1, ax1 = plt.subplots(figsize=(12, 7))
fig2, ax2 = plt.subplots(figsize=(12, 7))
for dom in doms:
    readings = np.linspace(0, 500, 100)
    costs = np.array([
        compute_total_cost(
            reading=reading,
            data=[
                {
                    "start": START_DATE,
                    "end": date(START_DATE.year, 12, 31),
                    "we": WE,
                    "dom": dom,
                },
                {
                    "start": date(END_DATE.year, 1, 1),
                    "end": END_DATE,
                    "we": WE,
                    "dom": dom,
                },
            ],
        ) for reading in readings
    ])

    ax1.plot(readings, costs, label=f"dom={dom}", alpha=0.7)
    ax2.plot(readings, costs / dom, label=f"dom={dom}", alpha=0.7)

ax12 = ax1.twinx()
ax22 = ax2.twinx()