loan_creator_web 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b135913a7255e5860b7c936017d581f302b81219
4
- data.tar.gz: 5bc7d815b82c378488205a2a694e1df2722d5c0e
3
+ metadata.gz: 6a0006b273338281b259f833896c04bc5da2bce4
4
+ data.tar.gz: 8e18811695f38f2a765303410c2fe7f6e6e7a181
5
5
  SHA512:
6
- metadata.gz: 899c8283b857ca655c99a79b85f1c1f02df8acb51d3b707e62f35415f8e5d8cdbc54468eae0b2cf22f3119ec5fe9278552d87061a3e57b661016ef74af27e3a6
7
- data.tar.gz: da53247ec278a2a22b6bbf4a3d58a48117e1fb2d0215c32ed67a67c4c4c5d45085a6cbb8f89798c2bed7f82e991c5f07caa0c7d083bb60589ad26cc945420c45
6
+ metadata.gz: 28479f266deba31a1dfbb28940596ced475981c7b385b8f187acb3eabca91274f9b75b8140e4cb5d69cd70fed6f4626dc5c5ed4598448c7cf697fd18b166d805
7
+ data.tar.gz: 9a0e888e95ed4044fd55b7c8774f7b94b713bcf7048960b23e2f2751b54bccfad15480b089dac4ace58d5ec4847f3d07aa2bc583eec2ff891c4139dd06065cf6
data/Gemfile CHANGED
@@ -4,3 +4,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in loan_creator_web.gemspec
6
6
  gemspec
7
+ gem 'pry'
data/README.md CHANGED
@@ -26,7 +26,7 @@ You can mount a route in your Ruby on Rails application:
26
26
  ```ruby
27
27
  # routes.rb
28
28
 
29
- mount LoanCreator::Web => '/loan-creator'
29
+ mount LoanCreatorWeb::App => '/loan-creator'
30
30
 
31
31
  ```
32
32
 
@@ -1,6 +1,7 @@
1
1
  require "sinatra/base"
2
2
  require_relative "./helpers/application_helper"
3
3
  require 'loan_creator'
4
+ require 'pry'
4
5
 
5
6
  module LoanCreatorWeb
6
7
  class App < Sinatra::Base
@@ -13,6 +13,7 @@ module LoanCreatorWeb
13
13
  h[:annual_interests_rate] = to_right_format(params: 'annual_interests_rate', value: params[:annual_interests_rate])
14
14
  h[:starts_on] = to_right_format(params: 'starts_on', value: params[:starts_on])
15
15
  h[:duration_in_periods] = to_right_format(params: 'duration_in_periods', value: params[:duration_in_periods])
16
+ h[:term_dates] = to_right_format(params: 'term_dates', value: params[:term_dates]) if params[:button] == 'update'
16
17
  h[:initial_values] = {}.tap do |ivh|
17
18
  ivh[:paid_capital] = to_right_format(params: 'paid_capital', value: params[:initial_values][:paid_capital])
18
19
  ivh[:paid_interests] = to_right_format(params: 'paid_interests', value: params[:initial_values][:paid_interests])
@@ -33,6 +34,8 @@ module LoanCreatorWeb
33
34
  value.to_i
34
35
  when 'starting_index'
35
36
  (value.blank? && value.to_i.zero?) ? nil : value.to_i
37
+ when 'term_dates'
38
+ value.values
36
39
  end
37
40
  end
38
41
 
@@ -1,3 +1,3 @@
1
1
  module LoanCreatorWeb
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,127 +1,125 @@
1
- <form action="<%= env["SCRIPT_NAME"] %>/" method="GET">
2
- <label class="switch">
3
- <input name="realistic_durations" type="checkbox" <%= checked(params: fixed_params[:realistic_durations]) %>>
4
- <span class="slider round"></span>
5
- </label>
6
- <span>Année au réel</span>
1
+ <label class="switch">
2
+ <input name="realistic_durations" type="checkbox" <%= checked(params: fixed_params[:realistic_durations]) %>>
3
+ <span class="slider round"></span>
4
+ </label>
5
+ <span>Realistic duration</span>
7
6
 
8
- <div class="row">
9
- <div class="col form-group">
10
- <label for="type">
11
- Type
12
- </label>
13
- <select name="type" class="form-control" id="type-select">
14
- <option value="">--Chose an option--</option>
15
- <option value="standard" <%= selected(params: fixed_params[:type], value: 'standard') %>>Standard</option>
16
- <option value="in_fine" <%= selected(params: fixed_params[:type], value: 'in_fine') %>>In fine</option>
17
- <option value="bullet" <%= selected(params: fixed_params[:type], value: 'bullet') %>>Bullet</option>
18
- <option value="linear" <%= selected(params: fixed_params[:type], value: 'linear') %>>Linear</option>
19
- </select>
20
- </div>
21
-
22
- <div class="col form-group">
23
- <label for="amount" id="amount">
24
- Amount
25
- </label>
26
- <input type="number" class="form-control" name="amount" value=<%= fixed_params[:amount] %>>
27
- </div>
7
+ <div class="row">
8
+ <div class="col form-group">
9
+ <label for="type">
10
+ Type
11
+ </label>
12
+ <select name="type" class="form-control" id="type-select">
13
+ <option value="">--Chose an option--</option>
14
+ <option value="standard" <%= selected(params: fixed_params[:type], value: 'standard') %>>Standard</option>
15
+ <option value="in_fine" <%= selected(params: fixed_params[:type], value: 'in_fine') %>>In fine</option>
16
+ <option value="bullet" <%= selected(params: fixed_params[:type], value: 'bullet') %>>Bullet</option>
17
+ <option value="linear" <%= selected(params: fixed_params[:type], value: 'linear') %>>Linear</option>
18
+ </select>
19
+ </div>
28
20
 
29
- <div class="col form-group">
30
- <label for="period">
31
- Period
32
- </label>
33
- <select name="period" class="form-control" id="period-select">
34
- <option value="">--Chose an option--</option>
35
- <option value="month" <%= selected(params: fixed_params[:period], value: 'month') %>>Month</option>
36
- <option value="quarter" <%= selected(params: fixed_params[:period], value: 'quarter') %>>Quarter</option>
37
- <option value="semester" <%= selected(params: fixed_params[:period], value: 'semester') %>>Semester</option>
38
- <option value="year" <%= selected(params: fixed_params[:period], value: 'year') %>>Year</option>
39
- </select>
40
- </div>
21
+ <div class="col form-group">
22
+ <label for="amount" id="amount">
23
+ Amount
24
+ </label>
25
+ <input type="number" class="form-control" name="amount" value=<%= fixed_params[:amount] %>>
41
26
  </div>
42
27
 
43
- <div class="row">
44
- <div class="col form-group">
45
- <label for="annual_interests_rate" id="annual_interests_rate">
46
- Annual Interests Rate
47
- </label>
48
- <input type="number" class="form-control" step="0.01" name="annual_interests_rate" value=<%= fixed_params[:annual_interests_rate] %>>
49
- </div>
28
+ <div class="col form-group">
29
+ <label for="period">
30
+ Period
31
+ </label>
32
+ <select name="period" class="form-control" id="period-select">
33
+ <option value="">--Chose an option--</option>
34
+ <option value="month" <%= selected(params: fixed_params[:period], value: 'month') %>>Month</option>
35
+ <option value="quarter" <%= selected(params: fixed_params[:period], value: 'quarter') %>>Quarter</option>
36
+ <option value="semester" <%= selected(params: fixed_params[:period], value: 'semester') %>>Semester</option>
37
+ <option value="year" <%= selected(params: fixed_params[:period], value: 'year') %>>Year</option>
38
+ </select>
39
+ </div>
40
+ </div>
50
41
 
51
- <div class="col form-group">
52
- <label for="starts_on">Starts on</label>
53
- <input type="date"
54
- class="form-control"
55
- name="starts_on"
56
- id="starts_on"
57
- value= <%= fixed_params[:starts_on] %>>
58
- </div>
42
+ <div class="row">
43
+ <div class="col form-group">
44
+ <label for="annual_interests_rate" id="annual_interests_rate">
45
+ Annual Interests Rate
46
+ </label>
47
+ <input type="number" class="form-control" step="0.01" name="annual_interests_rate" value=<%= fixed_params[:annual_interests_rate] %>>
48
+ </div>
59
49
 
60
- <div class="col form-group">
61
- <label for="duration_in_periods">Duration in periods</label>
62
- <input type="number"
63
- class="form-control"
64
- name="duration_in_periods"
65
- id="duration_in_periods"
66
- value= <%= fixed_params[:duration_in_periods] %>>
67
- </div>
50
+ <div class="col form-group">
51
+ <label for="starts_on">Starts on</label>
52
+ <input type="date"
53
+ class="form-control"
54
+ name="starts_on"
55
+ id="starts_on"
56
+ value= <%= fixed_params[:starts_on] %>>
68
57
  </div>
69
58
 
70
- <div class="row">
71
- <div class="col form-group">
72
- <label for="initial_values[starting_index]">Initial values[starting index]</label>
73
- <input step="0.01"
74
- class="form-control"
75
- type="number"
76
- name="initial_values[starting_index]"
77
- id="initial_values[starting_index]"
78
- value= <%= initial_values_for_form(fixed_params[:initial_values][:starting_index]) %>>
79
- </div>
59
+ <div class="col form-group">
60
+ <label for="duration_in_periods">Duration in periods</label>
61
+ <input type="number"
62
+ class="form-control"
63
+ name="duration_in_periods"
64
+ id="duration_in_periods"
65
+ value= <%= fixed_params[:duration_in_periods] %>>
66
+ </div>
67
+ </div>
80
68
 
81
- <div class="col form-group">
82
- <label for="initial_values[due_interests]">Initial values[due interests]</label>
83
- <input step="0.01"
84
- class="form-control"
85
- type="number"
86
- name="initial_values[due_interests]"
87
- id="initial_values[due_interests]"
88
- value= <%= initial_values_for_form(fixed_params[:initial_values][:due_interests]) %>>
89
- </div>
69
+ <div class="row">
70
+ <div class="col form-group">
71
+ <label for="initial_values[starting_index]">Initial values[starting index]</label>
72
+ <input step="0.01"
73
+ class="form-control"
74
+ type="number"
75
+ name="initial_values[starting_index]"
76
+ id="initial_values[starting_index]"
77
+ value= <%= initial_values_for_form(fixed_params[:initial_values][:starting_index]) %>>
78
+ </div>
90
79
 
91
- <div class="col form-group">
92
- <label for="initial_values[accrued_delta_interests]">Initial values[accrued delta interests]</label>
93
- <input step="1.0e-07"
80
+ <div class="col form-group">
81
+ <label for="initial_values[due_interests]">Initial values[due interests]</label>
82
+ <input step="0.01"
94
83
  class="form-control"
95
84
  type="number"
96
- name="initial_values[accrued_delta_interests]"
97
- id="initial_values[accrued_delta_interests]"
98
- value= <%= initial_values_for_form(fixed_params[:initial_values][:accrued_delta_interests]) %>>
99
- </div>
85
+ name="initial_values[due_interests]"
86
+ id="initial_values[due_interests]"
87
+ value= <%= initial_values_for_form(fixed_params[:initial_values][:due_interests]) %>>
100
88
  </div>
101
89
 
102
- <div class="row">
103
- <div class="col form-group">
104
- <label for="initial_values[paid_interests]">Initial values[paid interests]</label>
105
- <input step="0.01"
106
- class="form-control"
107
- type="number"
108
- name="initial_values[paid_interests]"
109
- id="initial_values[paid_interests]"
110
- value= <%= initial_values_for_form(fixed_params[:initial_values][:paid_interests]) %>>
111
- </div>
90
+ <div class="col form-group">
91
+ <label for="initial_values[accrued_delta_interests]">Initial values[accrued delta interests]</label>
92
+ <input step="1.0e-07"
93
+ class="form-control"
94
+ type="number"
95
+ name="initial_values[accrued_delta_interests]"
96
+ id="initial_values[accrued_delta_interests]"
97
+ value= <%= initial_values_for_form(fixed_params[:initial_values][:accrued_delta_interests]) %>>
98
+ </div>
99
+ </div>
112
100
 
113
- <div class="col form-group">
114
- <label for="initial_values[paid_capital]">Initial values[paid capital]</label>
115
- <input step="0.01"
116
- class="form-control"
117
- type="number"
118
- name="initial_values[paid_capital]"
119
- id="initial_values[paid_capital]"
120
- value= <%= initial_values_for_form(fixed_params[:initial_values][:paid_capital]) %>>
121
- </div>
101
+ <div class="row">
102
+ <div class="col form-group">
103
+ <label for="initial_values[paid_interests]">Initial values[paid interests]</label>
104
+ <input step="0.01"
105
+ class="form-control"
106
+ type="number"
107
+ name="initial_values[paid_interests]"
108
+ id="initial_values[paid_interests]"
109
+ value= <%= initial_values_for_form(fixed_params[:initial_values][:paid_interests]) %>>
122
110
  </div>
123
111
 
124
- <div class="d-flex justify-content-center">
125
- <input type="submit" class="btn btn-primary btn-lg my-2" value="generate">
112
+ <div class="col form-group">
113
+ <label for="initial_values[paid_capital]">Initial values[paid capital]</label>
114
+ <input step="0.01"
115
+ class="form-control"
116
+ type="number"
117
+ name="initial_values[paid_capital]"
118
+ id="initial_values[paid_capital]"
119
+ value= <%= initial_values_for_form(fixed_params[:initial_values][:paid_capital]) %>>
126
120
  </div>
127
- </form>
121
+ </div>
122
+
123
+ <div class="d-flex justify-content-center">
124
+ <input type="submit" class="btn btn-primary btn-lg my-2" value="generate">
125
+ </div>
@@ -1,2 +1,4 @@
1
- <%= erb :form, locals: { fixed_params: fixed_params } %>
2
- <%= erb :table, locals: { terms: terms } %>
1
+ <form action="<%= env["SCRIPT_NAME"] %>/" method="GET" id="loan-form">
2
+ <%= erb :form, locals: { fixed_params: fixed_params } %>
3
+ <%= erb :table, locals: { terms: terms } %>
4
+ </form>
@@ -30,7 +30,7 @@
30
30
  }
31
31
 
32
32
  .container {
33
- width: 100%;
33
+ width: 80%;
34
34
  padding-right: 15px;
35
35
  }
36
36
 
@@ -141,6 +141,8 @@
141
141
  user-select: none;
142
142
  border: 1px solid transparent;
143
143
  transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
144
+ -webkit-appearance: button;
145
+ cursor: pointer;
144
146
  }
145
147
 
146
148
  [type=submit] {
@@ -1,6 +1,10 @@
1
- <table class="table">
1
+ <table class="table" id="container">
2
2
  <%= erb :table_head %>
3
3
  <% terms.each do |term| %>
4
4
  <%= erb :table_row, locals: { term: term } %>
5
5
  <% end %>
6
6
  </table>
7
+
8
+ <div class="d-flex justify-content-center">
9
+ <button name="button" class="btn btn-primary btn-lg my-2" type="submit" value="update">update</button>
10
+ </div>
@@ -6,6 +6,7 @@
6
6
  <th>period capital</td>
7
7
  <th>period interests</td>
8
8
  <th>remaining capital</td>
9
+ <th>due interests</td>
9
10
  <th>total capital</td>
10
11
  <th>total interests</td>
11
12
  </tr>
@@ -1,10 +1,13 @@
1
1
  <tr>
2
2
  <td><%= term.index %></td>
3
- <td><%= term.due_on.strftime('%d/%m/%Y') %></td>
3
+ <td>
4
+ <input type="date" class="form-control" name="term_dates[<%= term.index %>]" value= <%= term.due_on %>>
5
+ </td>
4
6
  <td><%= number_to_euro(term.period_amount_to_pay) %></td>
5
7
  <td><%= number_to_euro(term.period_capital) %></td>
6
8
  <td><%= number_to_euro(term.period_interests) %></td>
7
9
  <td><%= number_to_euro(term.crd_end_of_period) %></td>
10
+ <td><%= number_to_euro(term.due_interests_end_of_period) %></td>
8
11
  <td><%= number_to_euro(term.total_paid_capital_end_of_period) %></td>
9
12
  <td><%= number_to_euro(term.total_paid_interests_end_of_period) %></td>
10
13
  </tr>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loan_creator_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juliette Audema
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-04 00:00:00.000000000 Z
11
+ date: 2021-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler