killbill-deposit 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +21 -0
- data/README.md +48 -0
- data/Rakefile +35 -0
- data/app/assets/javascripts/application.js +18 -0
- data/app/assets/javascripts/deposit/deposit.js +7 -0
- data/app/assets/stylesheets/application.css +19 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.css +13 -0
- data/app/assets/stylesheets/deposit/deposit.css +16 -0
- data/app/controllers/deposit/collection_controller.rb +149 -0
- data/app/controllers/deposit/engine_controller.rb +32 -0
- data/app/helpers/deposit/application_helper.rb +6 -0
- data/app/views/deposit/collection/_invoices_table.html.erb +68 -0
- data/app/views/deposit/collection/_payment_form.html.erb +53 -0
- data/app/views/deposit/collection/index.html.erb +10 -0
- data/app/views/deposit/layouts/deposit_application.html.erb +31 -0
- data/config/routes.rb +12 -0
- data/lib/deposit.rb +30 -0
- data/lib/deposit/client.rb +47 -0
- data/lib/deposit/engine.rb +20 -0
- data/lib/deposit/version.rb +5 -0
- data/test/deposit_test.rb +9 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +1 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +3 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +91 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +14 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/killbill_client.rb +3 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +14 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +32 -0
- data/test/integration/navigation_test.rb +12 -0
- data/test/test_helper.rb +21 -0
- metadata +317 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
<%= form_tag do_record_payments_path, :class => 'form-horizontal' do %>
|
2
|
+
<div class="form-group">
|
3
|
+
<%= label_tag :account_id, 'Account ID', :class => 'col-sm-2 control-label' %>
|
4
|
+
<div class="col-sm-5">
|
5
|
+
<%= text_field_tag :account_id, @account_id, :class => 'form-control', :readonly => !@account_id.nil?, :required => true %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
<div class="form-group">
|
9
|
+
<%= label_tag :payment_amount, 'Amount Received', :class => 'col-sm-2 control-label' %>
|
10
|
+
<div class="col-sm-2">
|
11
|
+
<%= number_field_tag :payment_amount, nil, :step => :any, :id => 'payment_amount', :class => 'form-control', :required => true %>
|
12
|
+
<p class="help-block">Currency: <%= @currency %></p>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<div class="form-group">
|
16
|
+
<%= label_tag :effective_date, 'Payment Date', :class => 'col-sm-2 control-label' %>
|
17
|
+
<div class="col-sm-2">
|
18
|
+
<%= text_field_tag :effective_date, Date.parse(Time.now.to_s).to_s, :class => 'form-control date-picker', :required => true %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class="form-group">
|
22
|
+
<%= label_tag :payment_reference_number, 'Payment Ref. #', :class => 'col-sm-2 control-label' %>
|
23
|
+
<div class="col-sm-10">
|
24
|
+
<%= text_field_tag :payment_reference_number, nil, :class => 'form-control', :required => true %>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<div class="form-group">
|
28
|
+
<%= label_tag :deposit_type, 'Payment Mode', :class => 'col-sm-2 control-label' %>
|
29
|
+
<div class="col-sm-3">
|
30
|
+
<%= select_tag :deposit_type, options_for_select(Deposit.deposit_types), :class => 'form-control' %>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div id="invoices">
|
35
|
+
<% unless @account_id.nil? %>
|
36
|
+
<%= render(:partial => 'invoices_table') %>
|
37
|
+
<% end %>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="form-group">
|
41
|
+
<div class="col-sm-offset-2 col-sm-10">
|
42
|
+
<%= submit_tag 'Save', :id => 'submit-btn', :class => 'btn btn-default' %>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<%= javascript_tag do %>
|
48
|
+
$(document).ready(function() {
|
49
|
+
$('#account_id').change(function() {
|
50
|
+
$("#invoices").html("<%= j render(:partial => 'invoices_table') %>");
|
51
|
+
});
|
52
|
+
});
|
53
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Deposit</title>
|
5
|
+
<%= yield :scripts %>
|
6
|
+
<%= stylesheet_link_tag 'application', :media => 'all' %>
|
7
|
+
<%= javascript_include_tag 'application' %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<div class="container-fluid">
|
11
|
+
<%- # :alert used by devise -%>
|
12
|
+
<% [:error, :alert].each do |key| %>
|
13
|
+
<% if flash[key] %>
|
14
|
+
<div class="row">
|
15
|
+
<div class="col-md-10 col-md-offset-2">
|
16
|
+
<div class="alert alert-error"><%= flash[key] %></div>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
<% if flash[:notice] %>
|
22
|
+
<div class="row">
|
23
|
+
<div class="col-md-10 col-md-offset-2">
|
24
|
+
<div class="alert alert-info"><%= flash[:notice] %></div>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
<%= yield %>
|
29
|
+
</div>
|
30
|
+
</body>
|
31
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deposit::Engine.routes.draw do
|
4
|
+
root to: 'collection#index'
|
5
|
+
|
6
|
+
resources :collection, only: [:index]
|
7
|
+
|
8
|
+
scope '/collection' do
|
9
|
+
match '/record' => 'collection#record_payments', :via => :post, :as => 'do_record_payments'
|
10
|
+
match '/account_invoices' => 'collection#account_invoices', :via => :get, :as => 'account_invoices'
|
11
|
+
end
|
12
|
+
end
|
data/lib/deposit.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'deposit/engine'
|
4
|
+
|
5
|
+
module Deposit
|
6
|
+
mattr_accessor :current_tenant_user
|
7
|
+
mattr_accessor :layout
|
8
|
+
|
9
|
+
mattr_accessor :deposit_types
|
10
|
+
|
11
|
+
self.current_tenant_user = lambda { |_session, _user|
|
12
|
+
{ username: 'admin',
|
13
|
+
password: 'password',
|
14
|
+
session_id: nil,
|
15
|
+
api_key: KillBillClient.api_key,
|
16
|
+
api_secret: KillBillClient.api_secret }
|
17
|
+
}
|
18
|
+
|
19
|
+
def self.config
|
20
|
+
{
|
21
|
+
layout: layout || 'deposit/layouts/deposit_application'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Default deposit types
|
26
|
+
self.deposit_types = %w[Wire
|
27
|
+
Check
|
28
|
+
Cash
|
29
|
+
OTHER]
|
30
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Killbill
|
4
|
+
module Deposit
|
5
|
+
class DepositClient < KillBillClient::Model::Resource
|
6
|
+
KILLBILL_DEPOSIT_PREFIX = '/plugins/killbill-deposit'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def record_payments(account_id, effective_date, payment_reference_number, deposit_type, invoice_payments, user = nil, reason = nil, comment = nil, options = {})
|
10
|
+
payments = []
|
11
|
+
invoice_payments.each do |invoice_number, payment_amount|
|
12
|
+
payments << { invoiceNumber: invoice_number, paymentAmount: payment_amount }
|
13
|
+
end
|
14
|
+
|
15
|
+
body = {
|
16
|
+
accountId: account_id,
|
17
|
+
effectiveDate: effective_date,
|
18
|
+
paymentReferenceNumber: payment_reference_number,
|
19
|
+
depositType: deposit_type,
|
20
|
+
payments: payments
|
21
|
+
}.to_json
|
22
|
+
|
23
|
+
path = "#{KILLBILL_DEPOSIT_PREFIX}/record"
|
24
|
+
response = KillBillClient::API.post path,
|
25
|
+
body,
|
26
|
+
{},
|
27
|
+
{
|
28
|
+
user: user,
|
29
|
+
reason: reason,
|
30
|
+
comment: comment
|
31
|
+
}.merge(options)
|
32
|
+
response.body
|
33
|
+
end
|
34
|
+
|
35
|
+
def deposit_plugin_available?(options = nil)
|
36
|
+
path = KILLBILL_DEPOSIT_PREFIX
|
37
|
+
KillBillClient::API.get path, nil, options
|
38
|
+
|
39
|
+
[true, nil]
|
40
|
+
# Response error if the deposit plugin is not listening
|
41
|
+
rescue KillBillClient::API::ResponseError => e
|
42
|
+
[false, e.message.to_s]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Dependencies
|
4
|
+
#
|
5
|
+
# Sigh. Rails autoloads the gems specified in the Gemfile and nothing else.
|
6
|
+
# We need to explicitly require all of our dependencies listed in deposit.gemspec
|
7
|
+
#
|
8
|
+
# See also https://github.com/carlhuda/bundler/issues/49
|
9
|
+
require 'jquery-rails'
|
10
|
+
require 'jquery-datatables-rails'
|
11
|
+
require 'font-awesome-rails'
|
12
|
+
require 'twitter-bootstrap-rails'
|
13
|
+
require 'money-rails'
|
14
|
+
require 'killbill_client'
|
15
|
+
|
16
|
+
module Deposit
|
17
|
+
class Engine < ::Rails::Engine
|
18
|
+
isolate_namespace Deposit
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
require 'action_controller/railtie'
|
4
|
+
require 'action_view/railtie'
|
5
|
+
require 'rails/test_unit/railtie'
|
6
|
+
require 'sprockets/railtie'
|
7
|
+
|
8
|
+
# Require the gems listed in Gemfile, including any gems
|
9
|
+
# you've limited to :test, :development, or :production.
|
10
|
+
Bundler.require(*Rails.groups)
|
11
|
+
|
12
|
+
#
|
13
|
+
# Required to load the Deposit UI engine into the dummy app
|
14
|
+
#
|
15
|
+
require File.expand_path('../../../../lib/deposit.rb', __FILE__)
|
16
|
+
|
17
|
+
module Dummy
|
18
|
+
class Application < Rails::Application
|
19
|
+
# Initialize configuration defaults for originally generated Rails version.
|
20
|
+
config.load_defaults 5.1
|
21
|
+
|
22
|
+
# Settings in config/environments/* take precedence over those specified here.
|
23
|
+
# Application configuration should go into files in config/initializers
|
24
|
+
# -- all .rb files in that directory are automatically loaded.
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
|
15
|
+
# Enable/disable caching. By default caching is disabled.
|
16
|
+
if Rails.root.join('tmp/caching-dev.txt').exist?
|
17
|
+
config.action_controller.perform_caching = true
|
18
|
+
|
19
|
+
config.cache_store = :memory_store
|
20
|
+
config.public_file_server.headers = {
|
21
|
+
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
|
22
|
+
}
|
23
|
+
else
|
24
|
+
config.action_controller.perform_caching = false
|
25
|
+
|
26
|
+
config.cache_store = :null_store
|
27
|
+
end
|
28
|
+
|
29
|
+
# Don't care if the mailer can't send.
|
30
|
+
# config.action_mailer.raise_delivery_errors = false
|
31
|
+
|
32
|
+
# config.action_mailer.perform_caching = false
|
33
|
+
|
34
|
+
# Print deprecation notices to the Rails logger.
|
35
|
+
config.active_support.deprecation = :log
|
36
|
+
|
37
|
+
# Raise an error on page load if there are pending migrations.
|
38
|
+
# config.active_record.migration_error = :page_load
|
39
|
+
|
40
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
41
|
+
# This option may cause significant delays in view rendering with a large
|
42
|
+
# number of complex assets.
|
43
|
+
config.assets.debug = true
|
44
|
+
|
45
|
+
# Suppress logger output for asset requests.
|
46
|
+
config.assets.quiet = true
|
47
|
+
|
48
|
+
# Raises error for missing translations
|
49
|
+
# config.action_view.raise_on_missing_translations = true
|
50
|
+
|
51
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
52
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
53
|
+
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
54
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
|
18
|
+
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
|
19
|
+
# `config/secrets.yml.key`.
|
20
|
+
config.read_encrypted_secrets = true
|
21
|
+
|
22
|
+
# Disable serving static files from the `/public` folder by default since
|
23
|
+
# Apache or NGINX already handles this.
|
24
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
25
|
+
|
26
|
+
# Compress JavaScripts and CSS.
|
27
|
+
config.assets.js_compressor = :uglifier
|
28
|
+
# config.assets.css_compressor = :sass
|
29
|
+
|
30
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
31
|
+
config.assets.compile = false
|
32
|
+
|
33
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
34
|
+
|
35
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
36
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
37
|
+
|
38
|
+
# Specifies the header that your server uses for sending files.
|
39
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
40
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
41
|
+
|
42
|
+
# Mount Action Cable outside main process or domain
|
43
|
+
# config.action_cable.mount_path = nil
|
44
|
+
# config.action_cable.url = 'wss://example.com/cable'
|
45
|
+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
46
|
+
|
47
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
48
|
+
# config.force_ssl = true
|
49
|
+
|
50
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
51
|
+
# when problems arise.
|
52
|
+
config.log_level = :debug
|
53
|
+
|
54
|
+
# Prepend all log lines with the following tags.
|
55
|
+
config.log_tags = [ :request_id ]
|
56
|
+
|
57
|
+
# Use a different cache store in production.
|
58
|
+
# config.cache_store = :mem_cache_store
|
59
|
+
|
60
|
+
# Use a real queuing backend for Active Job (and separate queues per environment)
|
61
|
+
# config.active_job.queue_adapter = :resque
|
62
|
+
# config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
|
63
|
+
# config.action_mailer.perform_caching = false
|
64
|
+
|
65
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
66
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
67
|
+
# config.action_mailer.raise_delivery_errors = false
|
68
|
+
|
69
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
70
|
+
# the I18n.default_locale when a translation cannot be found).
|
71
|
+
config.i18n.fallbacks = true
|
72
|
+
|
73
|
+
# Send deprecation notices to registered listeners.
|
74
|
+
config.active_support.deprecation = :notify
|
75
|
+
|
76
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
77
|
+
config.log_formatter = ::Logger::Formatter.new
|
78
|
+
|
79
|
+
# Use a different logger for distributed setups.
|
80
|
+
# require 'syslog/logger'
|
81
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
82
|
+
|
83
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
84
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
85
|
+
logger.formatter = config.log_formatter
|
86
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Do not dump schema after migrations.
|
90
|
+
# config.active_record.dump_schema_after_migration = false
|
91
|
+
end
|