erp_invoicing 3.0.0
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.
- data/GPL-3-LICENSE +674 -0
- data/README.rdoc +3 -0
- data/Rakefile +31 -0
- data/app/assets/javascripts/erp_invoicing/application.js +9 -0
- data/app/assets/stylesheets/erp_invoicing/application.css +7 -0
- data/app/controllers/erp_invoicing/erp_app/organizer/bill_pay/accounts_controller.rb +108 -0
- data/app/controllers/erp_invoicing/erp_app/organizer/bill_pay/base_controller.rb +22 -0
- data/app/helpers/erp_invoicing/application_helper.rb +4 -0
- data/app/models/extensions/financial_txn_account.rb +7 -0
- data/app/models/extensions/product_instance.rb +10 -0
- data/app/models/extensions/product_type.rb +10 -0
- data/app/models/extensions/work_effort.rb +10 -0
- data/app/models/invoice.rb +16 -0
- data/app/models/invoice_item.rb +13 -0
- data/app/models/invoice_item_type.rb +2 -0
- data/app/models/invoice_party_role.rb +7 -0
- data/app/models/invoice_type.rb +2 -0
- data/app/models/payment_application.rb +6 -0
- data/app/views/layouts/erp_invoicing/application.html.erb +14 -0
- data/app/widgets/bill_pay/base.rb +230 -0
- data/app/widgets/bill_pay/helpers/controller/bill_pay_controller_helper.rb +3 -0
- data/app/widgets/bill_pay/helpers/view/bill_pay_view_helper.rb +3 -0
- data/app/widgets/bill_pay/javascript/bill_pay.js +11 -0
- data/app/widgets/bill_pay/views/_menu.html.erb +63 -0
- data/app/widgets/bill_pay/views/_payment_history_table.html.erb +115 -0
- data/app/widgets/bill_pay/views/_statement_table.html.erb +117 -0
- data/app/widgets/bill_pay/views/account_home.html.erb +10 -0
- data/app/widgets/bill_pay/views/index.html.erb +4 -0
- data/app/widgets/bill_pay/views/make_payment.html.erb +24 -0
- data/app/widgets/bill_pay/views/payment_account_forms/bank_account.html.erb +28 -0
- data/app/widgets/bill_pay/views/payment_account_forms/credit_card.html.erb +48 -0
- data/app/widgets/bill_pay/views/payment_accounts.html.erb +120 -0
- data/app/widgets/bill_pay/views/payment_history.html.erb +104 -0
- data/app/widgets/bill_pay/views/pdf/layout.pdf.erb +35 -0
- data/app/widgets/bill_pay/views/statements.html.erb +4 -0
- data/config/routes.rb +6 -0
- data/db/data_migrations/20111121153349_create_bill_pay_organizer_application.rb +14 -0
- data/db/migrate/20111121000000_invoicing_services.rb +197 -0
- data/lib/erp_invoicing/engine.rb +10 -0
- data/lib/erp_invoicing/version.rb +3 -0
- data/lib/erp_invoicing.rb +4 -0
- data/lib/tasks/erp_invoicing_tasks.rake +4 -0
- data/public/javascripts/erp_app/organizer/applications/bill_pay/accounts_grid_panel.js +182 -0
- data/public/javascripts/erp_app/organizer/applications/bill_pay/base.js +134 -0
- data/public/javascripts/erp_app/organizer/applications/bill_pay/extensions.js +112 -0
- data/public/javascripts/erp_app/organizer/applications/bill_pay/make_payment_window.js +103 -0
- data/public/javascripts/erp_app/organizer/applications/bill_pay/payment_accounts_grid_panel.js +104 -0
- data/public/javascripts/erp_app/organizer/applications/bill_pay/transactions_grid_panel.js +84 -0
- metadata +187 -0
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'ErpInvoicing'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require "rspec/core/rake_task"
|
29
|
+
RSpec::Core::RakeTask.new(:spec)
|
30
|
+
task :default => :spec
|
31
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
// the compiled file.
|
6
|
+
//
|
7
|
+
//= require jquery
|
8
|
+
//= require jquery_ujs
|
9
|
+
//= require_tree .
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module ErpInvoicing
|
2
|
+
module ErpApp
|
3
|
+
module Organizer
|
4
|
+
module BillPay
|
5
|
+
class AccountsController < ::ErpApp::Organizer::BaseController
|
6
|
+
|
7
|
+
class Helper
|
8
|
+
include Singleton
|
9
|
+
include ActionView::Helpers::NumberHelper
|
10
|
+
end
|
11
|
+
|
12
|
+
def help
|
13
|
+
Helper.instance
|
14
|
+
end
|
15
|
+
|
16
|
+
def index
|
17
|
+
accounts = {:totalCount => 1, :accounts => [{
|
18
|
+
:id => 1,
|
19
|
+
:account_number => '123455667',
|
20
|
+
:payment_due => help.number_to_currency(33.45),
|
21
|
+
:billing_date => '10/31/2011',
|
22
|
+
:due_date => '11/15/2011',
|
23
|
+
:account_id => 1,
|
24
|
+
:party_id => 1
|
25
|
+
}]}
|
26
|
+
|
27
|
+
render :json => accounts
|
28
|
+
end
|
29
|
+
|
30
|
+
def transactions
|
31
|
+
transactions = {:totalCount => 2, :transactions => [
|
32
|
+
{
|
33
|
+
:date => '10/10/2011',
|
34
|
+
:description => 'Monthly Billing Amount',
|
35
|
+
:amount => help.number_to_currency(50.00)
|
36
|
+
},
|
37
|
+
{
|
38
|
+
:date => '10/15/2011',
|
39
|
+
:description => 'Payment Recieved',
|
40
|
+
:amount => help.number_to_currency(-50.00)
|
41
|
+
}
|
42
|
+
]}
|
43
|
+
|
44
|
+
render :json => transactions
|
45
|
+
end
|
46
|
+
|
47
|
+
def payment_accounts
|
48
|
+
payment_accounts = {:payment_accounts => [
|
49
|
+
{
|
50
|
+
:id => 1,
|
51
|
+
:description => 'My Bank Account',
|
52
|
+
:account_type => 'Bank Account',
|
53
|
+
:routing_number => '0123456',
|
54
|
+
:account_number => '9999321',
|
55
|
+
:edit_action => :edit_back_account
|
56
|
+
},
|
57
|
+
{
|
58
|
+
:id => 2,
|
59
|
+
:description => 'American Express',
|
60
|
+
:account_type => 'Credit Card',
|
61
|
+
:card_number => '1111222233334444',
|
62
|
+
:security_code => '123',
|
63
|
+
:exp_year => '9',
|
64
|
+
:exp_month => '2012',
|
65
|
+
:name_on_card => 'John Doe',
|
66
|
+
:edit_action => :edit_credit_card_account
|
67
|
+
}
|
68
|
+
]}
|
69
|
+
|
70
|
+
render :json => payment_accounts
|
71
|
+
end
|
72
|
+
|
73
|
+
def generate_statement
|
74
|
+
@statement = {
|
75
|
+
:statement_date => '10/31/2011',
|
76
|
+
:transactions => [
|
77
|
+
{
|
78
|
+
:date => '10/10/2011',
|
79
|
+
:description => 'Monthly Billing Amount',
|
80
|
+
:amount => help.number_to_currency(50.00)
|
81
|
+
},
|
82
|
+
{
|
83
|
+
:date => '10/15/2011',
|
84
|
+
:description => 'Payment Recieved',
|
85
|
+
:amount => help.number_to_currency(-50.00)
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
89
|
+
@title = "10/31/2011 Statement"
|
90
|
+
@body_options = {:file => File.join(Widgets::BillPay::Base.views_location,'_statement_table.html.erb'), :locals => {:transactions => @statement[:transactions]}}
|
91
|
+
html = render_to_string(
|
92
|
+
:file => File.join(Widgets::BillPay::Base.views_location,'pdf','layout.pdf.erb'),
|
93
|
+
:layout => false
|
94
|
+
)
|
95
|
+
|
96
|
+
kit = PDFKit.new(html)
|
97
|
+
send_data(kit.to_pdf, :filename => "Statement.pdf", :type => "application/pdf")
|
98
|
+
return
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end#BillPay
|
103
|
+
end#Organizer
|
104
|
+
end#ErpApp
|
105
|
+
end#ErpInvoicing
|
106
|
+
|
107
|
+
|
108
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ErpInvoicing
|
2
|
+
module ErpApp
|
3
|
+
module Organizer
|
4
|
+
module BillPay
|
5
|
+
class BaseController < ::ErpApp::Organizer::BaseController
|
6
|
+
|
7
|
+
def menu
|
8
|
+
menu = []
|
9
|
+
|
10
|
+
menu << {:text => 'Bill Pay', :leaf => true, :iconCls => 'icon-credit_cards', :applicationCardId => "billpay_layout"}
|
11
|
+
|
12
|
+
render :json => menu
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end#BillPay
|
17
|
+
end#Organizer
|
18
|
+
end#ErpApp
|
19
|
+
end#ErpInvoicing
|
20
|
+
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
ProductInstance.class_eval do
|
2
|
+
|
3
|
+
#*************************************************************
|
4
|
+
# This line of code needs to go into an extension of the any
|
5
|
+
# model class that is invoiceable. This includes:
|
6
|
+
# ProductType, ProductInstance, WorkEffort, TimeEntry
|
7
|
+
#*************************************************************
|
8
|
+
has_one :invoice_item, :as => :invoiceable_item
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
ProductType.class_eval do
|
2
|
+
|
3
|
+
#*************************************************************
|
4
|
+
# This line of code needs to go into an extension of the any
|
5
|
+
# model class that is invoiceable. This includes:
|
6
|
+
# ProductType, ProductInstance, WorkEffort, TimeEntry
|
7
|
+
#*************************************************************
|
8
|
+
has_one :invoice_item, :as => :invoiceable_item
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
WorkEffort.class_eval do
|
2
|
+
|
3
|
+
#*************************************************************
|
4
|
+
# This line of code needs to go into an extension of the any
|
5
|
+
# model class that is invoiceable. This includes:
|
6
|
+
# ProductType, ProductInstance, WorkEffort, TimeEntry
|
7
|
+
#*************************************************************
|
8
|
+
has_one :invoice_item, :as => :invoiceable_item
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Invoice < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :invoice_type
|
4
|
+
has_many :invoice_items
|
5
|
+
has_many :invoice_party_roles
|
6
|
+
has_many :parties, :through => :invoice_party_roles
|
7
|
+
|
8
|
+
#This line of code connects the invoice to a polymorphic payment application.
|
9
|
+
#The effect of this is to allow payments to be "applied_to" invoices
|
10
|
+
has_many :payment_applications, :as => :payment_applied_to
|
11
|
+
|
12
|
+
alias :items :invoice_items
|
13
|
+
alias :type :invoice_type
|
14
|
+
alias :party_roles :invoice_party_roles
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class InvoiceItem < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :agreement
|
4
|
+
belongs_to :agreement_item_type
|
5
|
+
|
6
|
+
belongs_to :invoiceable_item, :polymorphic => true
|
7
|
+
|
8
|
+
#This line of code connects the invoice to a polymorphic payment application.
|
9
|
+
#The effect of this is to allow payments to be "applied_to" invoices
|
10
|
+
has_many :payment_applications, :as => :payment_applied_to
|
11
|
+
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>ErpInvoicing</title>
|
5
|
+
<%= stylesheet_link_tag "erp_invoicing/application" %>
|
6
|
+
<%= javascript_include_tag "erp_invoicing/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,230 @@
|
|
1
|
+
module Widgets
|
2
|
+
module BillPay
|
3
|
+
class Base < ErpApp::Widgets::Base
|
4
|
+
|
5
|
+
def index
|
6
|
+
@account = {
|
7
|
+
:account_number => '123455667',
|
8
|
+
:payment_due => 33.45,
|
9
|
+
:billing_date => '10/31/2011',
|
10
|
+
:due_date => '11/15/2011'
|
11
|
+
}
|
12
|
+
|
13
|
+
@account_home_template = File.join(locate,'views','account_home.html.erb')
|
14
|
+
render
|
15
|
+
end
|
16
|
+
|
17
|
+
def account_home
|
18
|
+
@account = {
|
19
|
+
:account_number => '123455667',
|
20
|
+
:payment_due => 33.45,
|
21
|
+
:billing_date => '10/31/2011',
|
22
|
+
:due_date => '11/15/2011'
|
23
|
+
}
|
24
|
+
|
25
|
+
render :update => {:id => "#{@uuid}_result"}
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_payment
|
29
|
+
@acccount_id = params[:account]
|
30
|
+
|
31
|
+
@payment_accounts = [
|
32
|
+
{
|
33
|
+
:id => 1,
|
34
|
+
:description => 'My Bank Account',
|
35
|
+
:account_type => 'Bank Account',
|
36
|
+
:routing_number => '0123456',
|
37
|
+
:account_number => '9999321',
|
38
|
+
:edit_action => :edit_back_account
|
39
|
+
},
|
40
|
+
{
|
41
|
+
:id => 2,
|
42
|
+
:description => 'American Express',
|
43
|
+
:account_type => 'Credit Card',
|
44
|
+
:card_number => '1111222233334444',
|
45
|
+
:security_code => '123',
|
46
|
+
:exp_year => '9',
|
47
|
+
:exp_month => '2012',
|
48
|
+
:name_on_card => 'John Doe',
|
49
|
+
:edit_action => :edit_credit_card_account
|
50
|
+
}
|
51
|
+
]
|
52
|
+
|
53
|
+
@accounts = @payment_accounts.collect{|account| [account[:description],account[:id]]}
|
54
|
+
|
55
|
+
render :update => {:id => "#{@uuid}_result"}
|
56
|
+
end
|
57
|
+
|
58
|
+
def statements
|
59
|
+
@statement = {
|
60
|
+
:statement_date => '10/31/2011',
|
61
|
+
:tranactions => [
|
62
|
+
{
|
63
|
+
:date => '10/10/2011',
|
64
|
+
:description => 'Monthly Billing Amount',
|
65
|
+
:amount => 50.00
|
66
|
+
},
|
67
|
+
{
|
68
|
+
:date => '10/15/2011',
|
69
|
+
:description => 'Payment Recieved',
|
70
|
+
:amount => -50.00
|
71
|
+
}
|
72
|
+
]
|
73
|
+
}
|
74
|
+
|
75
|
+
render :update => {:id => "#{@uuid}_result"}
|
76
|
+
end
|
77
|
+
|
78
|
+
def download_statement
|
79
|
+
@statement = {
|
80
|
+
:statement_date => '10/31/2011',
|
81
|
+
:transactions => [
|
82
|
+
{
|
83
|
+
:date => '10/10/2011',
|
84
|
+
:description => 'Monthly Billing Amount',
|
85
|
+
:amount => 50.00
|
86
|
+
},
|
87
|
+
{
|
88
|
+
:date => '10/15/2011',
|
89
|
+
:description => 'Payment Recieved',
|
90
|
+
:amount => -50.00
|
91
|
+
}
|
92
|
+
]
|
93
|
+
}
|
94
|
+
@title = "10/31/2011 Statement"
|
95
|
+
@body_options = {:file => File.join(locate,'views','_statement_table.html.erb'), :locals => {:transactions => @statement[:transactions]}}
|
96
|
+
html = render_to_string(
|
97
|
+
:file => File.join(locate,'views','pdf','layout.pdf.erb'),
|
98
|
+
:layout => false
|
99
|
+
)
|
100
|
+
|
101
|
+
kit = PDFKit.new(html)
|
102
|
+
send_data(kit.to_pdf, :filename => "Statement.pdf", :type => "application/pdf")
|
103
|
+
return
|
104
|
+
end
|
105
|
+
|
106
|
+
def payment_history
|
107
|
+
@payments = [{
|
108
|
+
:payment_account => 'American Express',
|
109
|
+
:amount => 50.00,
|
110
|
+
:payment_date => '9/13/2011',
|
111
|
+
:post_date => '9/16/2011'
|
112
|
+
},{
|
113
|
+
:payment_account => 'My Bank',
|
114
|
+
:amount => 50.00,
|
115
|
+
:payment_date => '8/13/2011',
|
116
|
+
:post_date => '8/14/2011'
|
117
|
+
}]
|
118
|
+
|
119
|
+
render :update => {:id => "#{@uuid}_result"}
|
120
|
+
end
|
121
|
+
|
122
|
+
def download_payment_history
|
123
|
+
@payments = [{
|
124
|
+
:payment_account => 'American Express',
|
125
|
+
:amount => 50.00,
|
126
|
+
:payment_date => '9/13/2011',
|
127
|
+
:post_date => '9/16/2011'
|
128
|
+
},{
|
129
|
+
:payment_account => 'My Bank',
|
130
|
+
:amount => 50.00,
|
131
|
+
:payment_date => '8/13/2011',
|
132
|
+
:post_date => '8/14/2011'
|
133
|
+
}]
|
134
|
+
|
135
|
+
@title = "Payment History"
|
136
|
+
@body_options = {:file => File.join(locate,'views','_payment_history_table.html.erb'), :locals => {:payments => @payments}}
|
137
|
+
html = render_to_string(
|
138
|
+
:file => File.join(locate,'views','pdf','layout.pdf.erb'),
|
139
|
+
:layout => false
|
140
|
+
)
|
141
|
+
|
142
|
+
kit = PDFKit.new(html, :page_size => 'Letter')
|
143
|
+
send_data(kit.to_pdf, :filename => "PaymentHistory.pdf", :type => "application/pdf")
|
144
|
+
return
|
145
|
+
end
|
146
|
+
|
147
|
+
def payment_accounts
|
148
|
+
@payment_accounts = [
|
149
|
+
{
|
150
|
+
:description => 'My Bank Account',
|
151
|
+
:account_type => 'Bank Account',
|
152
|
+
:routing_number => '0123456',
|
153
|
+
:account_number => '9999321',
|
154
|
+
:edit_action => :edit_back_account
|
155
|
+
},
|
156
|
+
{
|
157
|
+
:description => 'American Express',
|
158
|
+
:account_type => 'Credit Card',
|
159
|
+
:card_number => '1111222233334444',
|
160
|
+
:security_code => '123',
|
161
|
+
:exp_year => '9',
|
162
|
+
:exp_month => '2012',
|
163
|
+
:name_on_card => 'John Doe',
|
164
|
+
:edit_action => :edit_credit_card_account
|
165
|
+
}
|
166
|
+
]
|
167
|
+
|
168
|
+
render :update => {:id => "#{@uuid}_result"}
|
169
|
+
end
|
170
|
+
|
171
|
+
def delete_payment_account
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
def edit_back_account
|
176
|
+
@account = {
|
177
|
+
:description => 'My Bank Account',
|
178
|
+
:account_type => 'Bank Account',
|
179
|
+
:routing_number => '0123456',
|
180
|
+
:account_number => '9999321'
|
181
|
+
}
|
182
|
+
|
183
|
+
render :update => {:id => "#{@uuid}_result", :view => '/payment_account_forms/bank_account'}
|
184
|
+
end
|
185
|
+
|
186
|
+
def edit_credit_card_account
|
187
|
+
@account = {
|
188
|
+
:description => 'American Express',
|
189
|
+
:account_type => 'Credit Card',
|
190
|
+
:card_number => '1111222233334444',
|
191
|
+
:security_code => '123',
|
192
|
+
:exp_year => '9',
|
193
|
+
:exp_month => '2012',
|
194
|
+
:name_on_card => 'John Doe'
|
195
|
+
}
|
196
|
+
|
197
|
+
render :update => {:id => "#{@uuid}_result", :view => '/payment_account_forms/credit_card'}
|
198
|
+
end
|
199
|
+
|
200
|
+
#should not be modified
|
201
|
+
#modify at your own risk
|
202
|
+
def locate
|
203
|
+
File.dirname(__FILE__)
|
204
|
+
end
|
205
|
+
|
206
|
+
class << self
|
207
|
+
def title
|
208
|
+
"Bill Pay"
|
209
|
+
end
|
210
|
+
|
211
|
+
def views_location
|
212
|
+
File.join(File.dirname(__FILE__),"/views")
|
213
|
+
end
|
214
|
+
|
215
|
+
def widget_name
|
216
|
+
File.basename(File.dirname(__FILE__))
|
217
|
+
end
|
218
|
+
|
219
|
+
def base_layout
|
220
|
+
begin
|
221
|
+
file = File.join(File.dirname(__FILE__),"/views/layouts/base.html.erb")
|
222
|
+
IO.read(file)
|
223
|
+
rescue
|
224
|
+
return nil
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end#Base
|
229
|
+
end#AccountPayment
|
230
|
+
end#Widgets
|