loan_creator_web 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b135913a7255e5860b7c936017d581f302b81219
4
+ data.tar.gz: 5bc7d815b82c378488205a2a694e1df2722d5c0e
5
+ SHA512:
6
+ metadata.gz: 899c8283b857ca655c99a79b85f1c1f02df8acb51d3b707e62f35415f8e5d8cdbc54468eae0b2cf22f3119ec5fe9278552d87061a3e57b661016ef74af27e3a6
7
+ data.tar.gz: da53247ec278a2a22b6bbf4a3d58a48117e1fb2d0215c32ed67a67c4c4c5d45085a6cbb8f89798c2bed7f82e991c5f07caa0c7d083bb60589ad26cc945420c45
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.7.1
7
+ before_install: gem install bundler -v 2.0.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at juliette@capsens.eu. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in loan_creator_web.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 CapSens
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # LoanCreatorWeb
2
+
3
+ `loan_creator_web` gem intends to provide a testing tool to visualise generations of loan timetables by the gem [loan_creator](https://github.com/CapSens/loan-creator).
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'loan_creator_web'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install loan_creator_web
21
+
22
+ ## Usage
23
+
24
+ You can mount a route in your Ruby on Rails application:
25
+
26
+ ```ruby
27
+ # routes.rb
28
+
29
+ mount LoanCreator::Web => '/loan-creator'
30
+
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bundle` to install dependencies. Then, run `rake config.ru` to run the tests.
36
+
37
+ You can now check the form on `localhost:9292`.
38
+
39
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/CapSens/loan_creator_web. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
50
+
51
+ ## Code of Conduct
52
+
53
+ Everyone interacting in the LoanCreatorWeb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/CapSens/loan_creator_web/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "loan_creator_web"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config.ru ADDED
@@ -0,0 +1,3 @@
1
+ require_relative "./lib/loan_creator_web"
2
+
3
+ run LoanCreatorWeb::App
@@ -0,0 +1,34 @@
1
+ require "sinatra/base"
2
+ require_relative "./helpers/application_helper"
3
+ require 'loan_creator'
4
+
5
+ module LoanCreatorWeb
6
+ class App < Sinatra::Base
7
+ helpers LoanCreatorWeb::ApplicationHelper
8
+
9
+ get "/" do
10
+ parameters = fix_params_type(params)
11
+
12
+ timetable =
13
+ case params[:type]
14
+ when 'in_fine'
15
+ LoanCreator::InFine.new(**parameters)
16
+ when 'bullet'
17
+ LoanCreator::Bullet.new(**parameters)
18
+ when 'linear'
19
+ LoanCreator::Linear.new(**parameters)
20
+ when 'standard'
21
+ LoanCreator::Standard.new(**parameters)
22
+ end
23
+
24
+ terms =
25
+ if timetable
26
+ timetable.lender_timetable.terms
27
+ else
28
+ []
29
+ end
30
+
31
+ erb :index, locals: { fixed_params: parameters, terms: terms }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,66 @@
1
+ require 'pry'
2
+
3
+ module LoanCreatorWeb
4
+ module ApplicationHelper
5
+ def fix_params_type(params)
6
+ params = params.merge({ initial_values: {} }) if params[:initial_values].nil?
7
+
8
+ {}.tap do |h|
9
+ h[:type] = params[:type]
10
+ h[:realistic_durations] = true unless params[:realistic_durations].nil?
11
+ h[:period] = params[:period]
12
+ h[:amount] = to_right_format(params: 'amount', value: params[:amount])
13
+ h[:annual_interests_rate] = to_right_format(params: 'annual_interests_rate', value: params[:annual_interests_rate])
14
+ h[:starts_on] = to_right_format(params: 'starts_on', value: params[:starts_on])
15
+ h[:duration_in_periods] = to_right_format(params: 'duration_in_periods', value: params[:duration_in_periods])
16
+ h[:initial_values] = {}.tap do |ivh|
17
+ ivh[:paid_capital] = to_right_format(params: 'paid_capital', value: params[:initial_values][:paid_capital])
18
+ ivh[:paid_interests] = to_right_format(params: 'paid_interests', value: params[:initial_values][:paid_interests])
19
+ ivh[:accrued_delta_interests] = to_right_format(params: 'accrued_delta_interests', value: params[:initial_values][:accrued_delta_interests])
20
+ ivh[:due_interests] = to_right_format(params: 'due_interests', value: params[:initial_values][:due_interests])
21
+ ivh[:starting_index] = to_right_format(params: 'starting_index', value: params[:initial_values][:starting_index])
22
+ end
23
+ end
24
+ end
25
+
26
+ def to_right_format(params:, value:)
27
+ case params
28
+ when *values_to_f
29
+ value.to_f
30
+ when 'starts_on'
31
+ value.blank? ? nil : Date.parse(value)
32
+ when 'duration_in_periods'
33
+ value.to_i
34
+ when 'starting_index'
35
+ (value.blank? && value.to_i.zero?) ? nil : value.to_i
36
+ end
37
+ end
38
+
39
+ def values_to_f
40
+ %w(
41
+ amount
42
+ annual_interests_rate
43
+ paid_capital
44
+ paid_interests
45
+ accrued_delta_interests
46
+ due_interests
47
+ )
48
+ end
49
+
50
+ def selected(params:, value:)
51
+ value == params ? 'selected' : ''
52
+ end
53
+
54
+ def number_to_euro(number)
55
+ "#{number} €"
56
+ end
57
+
58
+ def checked(params:)
59
+ params ? 'checked' : ''
60
+ end
61
+
62
+ def initial_values_for_form(initial_value)
63
+ (initial_value.present? && initial_value.zero?) ? nil : initial_value
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module LoanCreatorWeb
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,127 @@
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>
7
+
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>
28
+
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>
41
+ </div>
42
+
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>
50
+
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>
59
+
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>
68
+ </div>
69
+
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>
80
+
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>
90
+
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"
94
+ class="form-control"
95
+ 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>
100
+ </div>
101
+
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>
112
+
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>
122
+ </div>
123
+
124
+ <div class="d-flex justify-content-center">
125
+ <input type="submit" class="btn btn-primary btn-lg my-2" value="generate">
126
+ </div>
127
+ </form>
@@ -0,0 +1,2 @@
1
+ <%= erb :form, locals: { fixed_params: fixed_params } %>
2
+ <%= erb :table, locals: { terms: terms } %>
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width">
6
+ <title>LoanCreator Simulator</title>
7
+
8
+ <%= erb :stylesheet %>
9
+ </head>
10
+
11
+ <body>
12
+ <div class="container mx-auto mt-5">
13
+ <%= yield %>
14
+ </div>
15
+ </body>
16
+ </html>
@@ -0,0 +1,223 @@
1
+ <style>
2
+ body {
3
+ margin: 0;
4
+ font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
5
+ font-size: 1rem;
6
+ font-weight: 400;
7
+ line-height: 1.5;
8
+ color: #212529;
9
+ text-align: left;
10
+ background-color: #fff;
11
+ }
12
+
13
+ *, ::after, ::before {
14
+ box-sizing: border-box;
15
+ }
16
+
17
+ .mx-auto {
18
+ margin-left: auto!important;
19
+ margin-right: auto!important;
20
+ }
21
+
22
+ .mt-5 {
23
+ margin-top: 3rem!important;
24
+ }
25
+
26
+ @media (min-width: 1200px) {
27
+ .container {
28
+ max-width: 1140px;
29
+ }
30
+ }
31
+
32
+ .container {
33
+ width: 100%;
34
+ padding-right: 15px;
35
+ }
36
+
37
+ div {
38
+ display: block;
39
+ }
40
+
41
+ .row {
42
+ display: -ms-flexbox;
43
+ display: flex;
44
+ -ms-flex-wrap: wrap;
45
+ flex-wrap: wrap;
46
+ margin-right: -15px;
47
+ margin-left: -15px;
48
+ }
49
+
50
+ .col {
51
+ -ms-flex-preferred-size: 0;
52
+ flex-basis: 0;
53
+ -ms-flex-positive: 1;
54
+ flex-grow: 1;
55
+ max-width: 100%;
56
+ position: relative;
57
+ width: 100%;
58
+ padding-right: 15px;
59
+ padding-left: 15px;
60
+ }
61
+
62
+ .d-flex {
63
+ display: -ms-flexbox!important;
64
+ display: flex!important;
65
+ }
66
+
67
+ .justify-content-center {
68
+ -ms-flex-pack: center!important;
69
+ justify-content: center!important;
70
+ }
71
+
72
+ .my-2 {
73
+ margin-top: .5rem!important;
74
+ margin-bottom: .5rem!important;
75
+ }
76
+
77
+ /* FORM */
78
+
79
+ label {
80
+ display: inline-block;
81
+ margin-bottom: .5rem;
82
+ }
83
+
84
+ .form-control {
85
+ display: block;
86
+ width: 100%;
87
+ height: calc(1.5em + .75rem + 2px);
88
+ padding: .375rem .75rem;
89
+ font-size: 1rem;
90
+ font-weight: 400;
91
+ line-height: 1.5;
92
+ color: #495057;
93
+ background-color: #fff;
94
+ background-clip: padding-box;
95
+ border: 1px solid #ced4da;
96
+ border-radius: .25rem;
97
+ transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
98
+ }
99
+
100
+ .form-group {
101
+ margin-bottom: 1rem;
102
+ }
103
+
104
+ /* TABLE */
105
+
106
+ .table {
107
+ width: 100%;
108
+ margin-bottom: 1rem;
109
+ color: #212529;
110
+ }
111
+
112
+ .table td, .table th {
113
+ padding: .75rem;
114
+ vertical-align: top;
115
+ border-top: 1px solid #dee2e6;
116
+ }
117
+
118
+ /* BUTTON */
119
+
120
+ .btn-lg {
121
+ padding: .5rem 1rem;
122
+ font-size: 1.25rem;
123
+ line-height: 1.5;
124
+ border-radius: .3rem;
125
+ }
126
+
127
+ .btn-primary {
128
+ color: #fff;
129
+ background-color: #007bff;
130
+ border-color: #007bff;
131
+ }
132
+
133
+ .btn {
134
+ display: inline-block;
135
+ font-weight: 400;
136
+ text-align: center;
137
+ vertical-align: middle;
138
+ -webkit-user-select: none;
139
+ -moz-user-select: none;
140
+ -ms-user-select: none;
141
+ user-select: none;
142
+ border: 1px solid transparent;
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
+ }
145
+
146
+ [type=submit] {
147
+ -webkit-appearance: button;
148
+ }
149
+
150
+ input {
151
+ overflow: visible;
152
+ margin: 0;
153
+ font-family: inherit;
154
+ font-size: inherit;
155
+ line-height: inherit;
156
+ }
157
+
158
+ [type=submit]:not(:disabled) {
159
+ cursor: pointer;
160
+ }
161
+
162
+ /* Switch button */
163
+
164
+ .switch {
165
+ position: relative;
166
+ display: inline-block;
167
+ width: 30px;
168
+ height: 17px;
169
+ }
170
+
171
+ .switch input {
172
+ opacity: 0;
173
+ width: 0;
174
+ height: 0;
175
+ }
176
+
177
+ .slider {
178
+ position: absolute;
179
+ cursor: pointer;
180
+ top: 0;
181
+ left: 0;
182
+ right: 0;
183
+ bottom: 0;
184
+ background-color: #ccc;
185
+ -webkit-transition: .4s;
186
+ transition: .4s;
187
+ }
188
+
189
+ .slider:before {
190
+ position: absolute;
191
+ content: "";
192
+ height: 13px;
193
+ width: 13px;
194
+ left: 2px;
195
+ bottom: 2px;
196
+ background-color: white;
197
+ -webkit-transition: .4s;
198
+ transition: .4s;
199
+ }
200
+
201
+ input:checked + .slider {
202
+ background-color: #2196F3;
203
+ }
204
+
205
+ input:focus + .slider {
206
+ box-shadow: 0 0 1px #2196F3;
207
+ }
208
+
209
+ input:checked + .slider:before {
210
+ -webkit-transform: translateX(13px);
211
+ -ms-transform: translateX(13px);
212
+ transform: translateX(13px);
213
+ }
214
+
215
+ /* Rounded sliders */
216
+ .slider.round {
217
+ border-radius: 17px;
218
+ }
219
+
220
+ .slider.round:before {
221
+ border-radius: 50%;
222
+ }
223
+ </style>
@@ -0,0 +1,6 @@
1
+ <table class="table">
2
+ <%= erb :table_head %>
3
+ <% terms.each do |term| %>
4
+ <%= erb :table_row, locals: { term: term } %>
5
+ <% end %>
6
+ </table>
@@ -0,0 +1,11 @@
1
+ <br />
2
+ <tr>
3
+ <th>t</td>
4
+ <th>date</td>
5
+ <th>period total</td>
6
+ <th>period capital</td>
7
+ <th>period interests</td>
8
+ <th>remaining capital</td>
9
+ <th>total capital</td>
10
+ <th>total interests</td>
11
+ </tr>
@@ -0,0 +1,10 @@
1
+ <tr>
2
+ <td><%= term.index %></td>
3
+ <td><%= term.due_on.strftime('%d/%m/%Y') %></td>
4
+ <td><%= number_to_euro(term.period_amount_to_pay) %></td>
5
+ <td><%= number_to_euro(term.period_capital) %></td>
6
+ <td><%= number_to_euro(term.period_interests) %></td>
7
+ <td><%= number_to_euro(term.crd_end_of_period) %></td>
8
+ <td><%= number_to_euro(term.total_paid_capital_end_of_period) %></td>
9
+ <td><%= number_to_euro(term.total_paid_interests_end_of_period) %></td>
10
+ </tr>
@@ -0,0 +1 @@
1
+ require_relative './loan_creator_web/app'
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "loan_creator_web/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "loan_creator_web"
8
+ spec.version = LoanCreatorWeb::VERSION
9
+ spec.authors = ["Juliette Audema"]
10
+ spec.email = ["juliette@capsens.eu"]
11
+
12
+ spec.summary = 'View for loan_creator gem'
13
+ spec.homepage = 'https://github.com/CapSens/loan-creator-web'
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.17"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rack-test"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+
30
+ spec.add_runtime_dependency 'sinatra'
31
+ spec.add_runtime_dependency 'loan_creator'
32
+ end
@@ -0,0 +1,16 @@
1
+ require_relative './lib/loan_creator_web'
2
+ require 'test/unit'
3
+ require 'rack/test'
4
+
5
+ class LoanCreatorWebTest < Test::Unit::TestCase
6
+ include Rack::Test::Methods
7
+
8
+ def app
9
+ LoanCreatorWeb::App
10
+ end
11
+
12
+ def test_homepage
13
+ get '/'
14
+ assert last_response.ok?
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: loan_creator_web
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Juliette Audema
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-05-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: loan_creator
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - juliette@capsens.eu
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - config.ru
115
+ - lib/loan_creator_web.rb
116
+ - lib/loan_creator_web/app.rb
117
+ - lib/loan_creator_web/helpers/application_helper.rb
118
+ - lib/loan_creator_web/version.rb
119
+ - lib/loan_creator_web/views/form.erb
120
+ - lib/loan_creator_web/views/index.erb
121
+ - lib/loan_creator_web/views/layout.erb
122
+ - lib/loan_creator_web/views/stylesheet.erb
123
+ - lib/loan_creator_web/views/table.erb
124
+ - lib/loan_creator_web/views/table_head.erb
125
+ - lib/loan_creator_web/views/table_row.erb
126
+ - loan_creator_web.gemspec
127
+ - loan_creator_web_test.rb
128
+ homepage: https://github.com/CapSens/loan-creator-web
129
+ licenses:
130
+ - MIT
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.5.2.3
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: View for loan_creator gem
152
+ test_files: []