-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdown_payment_calculator.php
More file actions
executable file
·139 lines (135 loc) · 4.09 KB
/
down_payment_calculator.php
File metadata and controls
executable file
·139 lines (135 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
* The entry point of the legacy application, basically a single script to run.
*
* @package vtos/php-refactoring-practice
* @author Vitaly Potenko <potenkov@gmail.com>
*/
require_once(__DIR__ . '/vendor/autoload.php');
use DownPaymentCalculator\Request\Request;
use DownPaymentCalculator\Service\Controller;
use DownPaymentCalculator\Service\DownPaymentCalculator;
use DownPaymentCalculator\View\HTMLRenderer;
use DownPaymentCalculator\View\JSONRenderer;
$request = new Request();
$request->postalCode = '10789';
$request->vat = 19.00;
$request->yearlyUsage = 3500;
$request->downPaymentInterval = 12;
$request->product = [
[
'name' => 'Electricity Simple',
'validFrom' => '2021-01-01',
'validUntil' => '2022-12-31',
'tariff' => [
[
'name' => 'Tariff 1',
'usageFrom' => 0,
'validFrom' => '2021-01-01',
'validUntil' => '2021-12-31',
'workingPriceNet' => 0.20,
'basePriceNet' => 50.00
],
[
'name' => 'Tariff 2',
'usageFrom' => 0,
'validFrom' => '2022-01-01',
'validUntil' => '2022-12-31',
'workingPriceNet' => 0.20,
'basePriceNet' => 50.00
],
[
'name' => 'Tariff 3',
'usageFrom' => 3001,
'validFrom' => '2022-01-01',
'validUntil' => '2022-12-31',
'workingPriceNet' => 0.15,
'basePriceNet' => 40.00
],
[
'name' => 'Tariff 4',
'usageFrom' => 5001,
'validFrom' => '2022-01-01',
'validUntil' => '2022-12-31',
'workingPriceNet' => 0.12,
'basePriceNet' => 35.00
]
]
],
[
'name' => 'Electricity Advanced',
'validFrom' => '2021-01-01',
'validUntil' => '2022-12-31',
'tariff' => [
[
'name' => 'Tariff 1',
'usageFrom' => 0,
'validFrom' => '2021-01-01',
'validUntil' => '2021-12-31',
'workingPriceNet' => 0.25,
'basePriceNet' => 50.00
],
[
'name' => 'Tariff 2',
'usageFrom' => 0,
'validFrom' => '2022-01-01',
'validUntil' => '2022-12-31',
'workingPriceNet' => 0.25,
'basePriceNet' => 50.00
],
[
'name' => 'Tariff 3',
'usageFrom' => 3001,
'validFrom' => '2022-01-01',
'validUntil' => '2022-12-31',
'workingPriceNet' => 0.18,
'basePriceNet' => 41.00
],
[
'name' => 'Tariff 4',
'usageFrom' => 5001,
'validFrom' => '2022-01-01',
'validUntil' => '2022-12-31',
'workingPriceNet' => 0.15,
'basePriceNet' => 38.00
]
]
],
];
$request->bonus = [
[
'name' => 'BONUS-A',
'usageFrom' => 0,
'validFrom' => '2021-01-01',
'validUntil' => '2022-12-31',
'value' => 5,
'paymentAfterMonths' => 0
],
[
'name' => 'BONUS-B',
'usageFrom' => 0,
'validFrom' => '2021-01-01',
'validUntil' => '2022-12-31',
'value' => 5,
'paymentAfterMonths' => 6
],
[
'name' => 'BONUS-C',
'usageFrom' => 2500,
'validFrom' => '2021-01-01',
'validUntil' => '2022-12-31',
'value' => 2.5,
'paymentAfterMonths' => 3
],
[
'name' => 'BONUS-D',
'usageFrom' => 4500,
'validFrom' => '2021-01-01',
'validUntil' => '2022-12-31',
'value' => 1.25,
'paymentAfterMonths' => 9
]
];
echo (new Controller(new DownPaymentCalculator(), new HTMLRenderer()))->run($request);
echo "\n";
echo (new Controller(new DownPaymentCalculator(), new JSONRenderer()))->run($request);