erp_invoicing 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/app/controllers/erp_invoicing/erp_app/organizer/bill_pay/accounts_controller.rb +98 -46
  2. data/app/controllers/erp_invoicing/erp_app/organizer/bill_pay/base_controller.rb +1 -1
  3. data/app/controllers/erp_invoicing/erp_app/shared/billing_accounts_controller.rb +111 -0
  4. data/app/controllers/erp_invoicing/erp_app/shared/files_controller.rb +52 -0
  5. data/app/controllers/erp_invoicing/erp_app/shared/invoices_controller.rb +208 -0
  6. data/app/controllers/erp_invoicing/sms_controller.rb +156 -0
  7. data/app/models/billing_account.rb +204 -0
  8. data/app/models/extensions/document.rb +5 -0
  9. data/app/models/extensions/financial_txn.rb +5 -0
  10. data/app/models/extensions/party.rb +10 -0
  11. data/app/models/invoice.rb +100 -7
  12. data/app/models/invoice_item.rb +35 -2
  13. data/app/models/invoice_payment_strategy_type.rb +5 -0
  14. data/app/models/invoice_payment_term.rb +4 -0
  15. data/app/models/invoice_payment_term_set.rb +6 -0
  16. data/app/models/invoice_payment_term_type.rb +3 -0
  17. data/app/models/payment_application.rb +6 -1
  18. data/app/models/recurring_payment.rb +40 -0
  19. data/config/routes.rb +8 -1
  20. data/db/data_migrations/20111121153349_create_bill_pay_organizer_application.rb +1 -1
  21. data/db/data_migrations/20120118181839_create_invoice_management_desktop_application.rb +26 -0
  22. data/db/data_migrations/20120229174322_add_billpay_widget.rb +28 -0
  23. data/db/migrate/20111121000000_invoicing_services.rb +170 -103
  24. data/db/migrate/20120228184317_add_text_to_pay_to_recurring_payments.rb +13 -0
  25. data/db/migrate/20120301155722_add_billing_date_to_billing_account.rb +13 -0
  26. data/lib/erp_invoicing/engine.rb +5 -0
  27. data/lib/erp_invoicing/version.rb +7 -1
  28. data/lib/erp_invoicing.rb +1 -0
  29. data/public/javascripts/erp_app/desktop/applications/invoice_management/billing_accounts_panel.js +80 -0
  30. data/public/javascripts/erp_app/desktop/applications/invoice_management/invoices_panel.js +48 -0
  31. data/public/javascripts/erp_app/desktop/applications/invoice_management/module.js +36 -0
  32. data/public/javascripts/erp_app/organizer/applications/bill_pay/base.js +88 -76
  33. data/public/javascripts/erp_app/organizer/applications/bill_pay/extensions.js +6 -97
  34. data/public/javascripts/erp_app/organizer/applications/bill_pay/make_payment_window.js +19 -13
  35. data/public/javascripts/erp_app/organizer/applications/bill_pay/payment_accounts_grid_panel.js +2 -1
  36. data/public/javascripts/erp_app/shared/add_invoice_window.js +220 -0
  37. data/public/javascripts/erp_app/shared/billing_accounts_grid_panel.js +318 -0
  38. data/public/javascripts/erp_app/shared/invoice_items_grid_panel.js +152 -0
  39. data/public/javascripts/erp_app/shared/invoices_grid_panel.js +363 -0
  40. data/public/javascripts/erp_app/shared/payments_grid_panel.js +74 -0
  41. data/spec/dummy/Rakefile +7 -0
  42. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  43. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  44. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  45. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  46. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  47. data/spec/dummy/config/application.rb +50 -0
  48. data/spec/dummy/config/boot.rb +10 -0
  49. data/spec/dummy/config/database.yml +8 -0
  50. data/spec/dummy/config/environment.rb +5 -0
  51. data/spec/dummy/config/environments/spec.rb +27 -0
  52. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  53. data/spec/dummy/config/initializers/inflections.rb +10 -0
  54. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  55. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  56. data/spec/dummy/config/initializers/session_store.rb +8 -0
  57. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  58. data/spec/dummy/config/locales/en.yml +5 -0
  59. data/spec/dummy/config/routes.rb +3 -0
  60. data/spec/dummy/config.ru +4 -0
  61. data/spec/dummy/public/404.html +26 -0
  62. data/spec/dummy/public/422.html +26 -0
  63. data/spec/dummy/public/500.html +26 -0
  64. data/spec/dummy/public/favicon.ico +0 -0
  65. data/spec/dummy/script/rails +6 -0
  66. data/spec/factories/basic.rb +9 -0
  67. data/spec/models/billing_account_spec.rb +78 -0
  68. data/spec/models/invoice_item_spec.rb +22 -0
  69. data/spec/models/invoice_spec.rb +58 -0
  70. data/spec/models/payment_application_spec.rb +17 -0
  71. data/spec/spec_helper.rb +60 -0
  72. metadata +148 -67
  73. data/app/widgets/bill_pay/base.rb +0 -230
  74. data/app/widgets/bill_pay/helpers/controller/bill_pay_controller_helper.rb +0 -3
  75. data/app/widgets/bill_pay/helpers/view/bill_pay_view_helper.rb +0 -3
  76. data/app/widgets/bill_pay/javascript/bill_pay.js +0 -11
  77. data/app/widgets/bill_pay/views/_menu.html.erb +0 -63
  78. data/app/widgets/bill_pay/views/_payment_history_table.html.erb +0 -115
  79. data/app/widgets/bill_pay/views/_statement_table.html.erb +0 -117
  80. data/app/widgets/bill_pay/views/account_home.html.erb +0 -10
  81. data/app/widgets/bill_pay/views/index.html.erb +0 -4
  82. data/app/widgets/bill_pay/views/make_payment.html.erb +0 -24
  83. data/app/widgets/bill_pay/views/payment_account_forms/bank_account.html.erb +0 -28
  84. data/app/widgets/bill_pay/views/payment_account_forms/credit_card.html.erb +0 -48
  85. data/app/widgets/bill_pay/views/payment_accounts.html.erb +0 -120
  86. data/app/widgets/bill_pay/views/payment_history.html.erb +0 -104
  87. data/app/widgets/bill_pay/views/pdf/layout.pdf.erb +0 -35
  88. data/app/widgets/bill_pay/views/statements.html.erb +0 -4
  89. data/public/javascripts/erp_app/organizer/applications/bill_pay/accounts_grid_panel.js +0 -182
@@ -0,0 +1,318 @@
1
+ Ext.define('Compass.ErpApp.Shared.BillingAccount',{
2
+ extend:'Ext.data.Model',
3
+ fields:[{
4
+ name:'id'
5
+ },{
6
+ name:'account_number'
7
+ },{
8
+ name:'calculate_balance'
9
+ },{
10
+ name:'payment_due'
11
+ },{
12
+ name:'balance'
13
+ },{
14
+ name:'due_date'
15
+ },{
16
+ name:'balance_date'
17
+ },{
18
+ name:'payable_online'
19
+ },{
20
+ name:'send_paper_bills'
21
+ }],
22
+ validations:[
23
+ {
24
+ type:'presence',
25
+ field: 'account_number'
26
+ },
27
+ {
28
+ type:'presence',
29
+ field: 'balance'
30
+ },
31
+ {
32
+ type:'presence',
33
+ field: 'payment_due'
34
+ }
35
+ ]
36
+ });
37
+
38
+ Ext.define("Compass.ErpApp.Shared.BillingAccountsGridPanel",{
39
+ extend:"Ext.grid.Panel",
40
+ alias:'widget.shared-billingaccountsgridpanel',
41
+ title:'Billing Accounts',
42
+ addDocument : function(rec){
43
+ var uploadWindow = new Compass.ErpApp.Shared.UploadWindow({
44
+ standardUploadUrl:'/erp_invoicing/erp_app/shared/billing_accounts/'+rec.get('id')+'/upload_file',
45
+ flashUploadUrl:'/erp_invoicing/erp_app/shared/billing_accounts/'+rec.get('id')+'/upload_file',
46
+ xhrUploadUrl:'/erp_invoicing/erp_app/shared/billing_accounts/'+rec.get('id')+'/upload_file',
47
+ extraPostData:{}
48
+ });
49
+ uploadWindow.show();
50
+ },
51
+
52
+ initComponent : function(){
53
+ this.setParams = function(params) {
54
+ this.partyId = params.partyId;
55
+ this.store.proxy.extraParams.party_id = params.partyId;
56
+ };
57
+
58
+ this.callParent(this.arguemnts);
59
+ },
60
+
61
+ constructor : function(config) {
62
+ var self = this;
63
+
64
+ var store = Ext.create('Ext.data.Store', {
65
+ fields:['id', 'account_number', 'calculate_balance', 'payment_due','balance', {
66
+ name:'due_date',
67
+ type:'date',
68
+ dateFormat:'Y-m-d'
69
+ }, {
70
+ name:'balance_date',
71
+ type:'date',
72
+ dateFormat:'Y-m-d'
73
+ },'payable_online','send_paper_bills'],
74
+ autoLoad: Compass.ErpApp.Utility.isBlank(config['autoLoad']) ? true : config['autoLoad'],
75
+ autoSync: true,
76
+ proxy: {
77
+ type: 'rest',
78
+ url:'/erp_invoicing/erp_app/shared/billing_accounts/index',
79
+ extraParams:{
80
+ account_number:null
81
+ },
82
+ reader: {
83
+ type: 'json',
84
+ successProperty: 'success',
85
+ idProperty: 'id',
86
+ root: 'billing_accounts',
87
+ totalProperty:'totalCount',
88
+ messageProperty: 'messages'
89
+ },
90
+ writer: {
91
+ type: 'json',
92
+ writeAllFields:true,
93
+ root: 'billingAccount'
94
+ },
95
+ listeners: {
96
+ exception: function(proxy, response, operation){
97
+ Ext.MessageBox.show({
98
+ title: 'REMOTE EXCEPTION',
99
+ msg: 'Error performing action please try again.',
100
+ icon: Ext.MessageBox.ERROR,
101
+ buttons: Ext.Msg.OK
102
+ });
103
+ }
104
+ }
105
+ }
106
+ });
107
+
108
+ var editingPlugin = Ext.create('Ext.grid.plugin.RowEditing', {
109
+ clicksToMoveEditor: 1
110
+ });
111
+
112
+ var tbar = {
113
+ items:[]
114
+ };
115
+ if(config.showAddDelete){
116
+ tbar.items.push({
117
+ text: 'Add',
118
+ xtype:'button',
119
+ iconCls: 'icon-add',
120
+ handler: function(button) {
121
+ var grid = button.up('shared-billingaccountsgridpanel');
122
+ grid.store.insert(0, new Compass.ErpApp.Shared.BillingAccount({
123
+ payment_due:0.00,
124
+ balance:0.00,
125
+ due_date:new Date(),
126
+ balance_date:new Date()
127
+ }));
128
+ editingPlugin.startEdit(0,0);
129
+ }
130
+ });
131
+
132
+ tbar.items.push('-');
133
+ tbar.items.push({
134
+ text: 'Delete',
135
+ type:'button',
136
+ iconCls: 'icon-delete',
137
+ handler: function(button) {
138
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this billing account?', function(btn){
139
+ if(btn == 'no'){
140
+ return false;
141
+ }
142
+ else
143
+ {
144
+ var selection = self.getView().getSelectionModel().getSelection()[0];
145
+ if (selection) {
146
+ store.remove(selection);
147
+ }
148
+ }
149
+ });
150
+ }
151
+ });
152
+ tbar.items.push('|');
153
+ }
154
+
155
+ tbar.items = tbar.items.concat([
156
+ '<span class="x-btn-inner">Account Number:</span>',
157
+ {
158
+ xtype:'textfield',
159
+ hideLabel:true,
160
+ itemId:'accountNumberSearchTextField'
161
+ },
162
+ {
163
+ text:'Search',
164
+ iconCls:'icon-search',
165
+ handler:function(btn){
166
+ var grid = btn.up('shared-billingaccountsgridpanel');
167
+ grid.store.proxy.extraParams.account_number = grid.query('#accountNumberSearchTextField').first().getValue();
168
+ grid.store.load();
169
+ }
170
+ },
171
+ '|',
172
+ {
173
+ text: 'All',
174
+ xtype:'button',
175
+ iconCls: 'icon-eye',
176
+ handler: function(btn) {
177
+ var grid = btn.up('shared-billingaccountsgridpanel');
178
+ grid.store.proxy.extraParams.account_number = null;
179
+ grid.store.load();
180
+ }
181
+ }]);
182
+
183
+ config = Ext.apply({
184
+ plugins:[editingPlugin],
185
+ columns: [
186
+ {
187
+ header:'Account Number',
188
+ width:300,
189
+ dataIndex: 'account_number',
190
+ editor:{
191
+ xtype:'textfield'
192
+ }
193
+ },
194
+ {
195
+ header:'Send Paper Bills',
196
+ width:100,
197
+ sortable: false,
198
+ dataIndex: 'send_paper_bills',
199
+ renderer:function(v){
200
+ var result = ''
201
+ if(v){
202
+ result = 'Yes';
203
+ }
204
+ else{
205
+ result = 'No';
206
+ }
207
+ return result;
208
+ },
209
+ editor:{
210
+ xtype:'combo',
211
+ store:[[true,'Yes'],[false,'No']],
212
+ forceSelection:true,
213
+ triggerAction:'all'
214
+ }
215
+ },
216
+ {
217
+ header:'Payable Online',
218
+ width:100,
219
+ sortable: false,
220
+ dataIndex: 'payable_online',
221
+ renderer:function(v){
222
+ var result = ''
223
+ if(v){
224
+ result = 'Yes';
225
+ }
226
+ else{
227
+ result = 'No';
228
+ }
229
+ return result;
230
+ },
231
+ editor:{
232
+ xtype:'combo',
233
+ store:[[true,'Yes'],[false,'No']],
234
+ forceSelection:true,
235
+ triggerAction:'all'
236
+ }
237
+ },
238
+ {
239
+ header:'Calculate Balance',
240
+ width:100,
241
+ sortable: false,
242
+ dataIndex: 'calculate_balance',
243
+ renderer:function(v){
244
+ var result = ''
245
+ if(v){
246
+ result = 'Yes';
247
+ }
248
+ else{
249
+ result = 'No';
250
+ }
251
+ return result;
252
+ },
253
+ editor:{
254
+ xtype:'combo',
255
+ store:[[true,'Yes'],[false,'No']],
256
+ forceSelection:true,
257
+ triggerAction:'all'
258
+ }
259
+ },
260
+ {
261
+ header:'Payment Due',
262
+ width:100,
263
+ dataIndex: 'payment_due',
264
+ renderer:function(v){
265
+ return v.toFixed(2);
266
+ },
267
+ editor:{
268
+ xtype:'numberfield'
269
+ }
270
+ },
271
+ {
272
+ header:'Balance',
273
+ width:100,
274
+ dataIndex: 'balance',
275
+ renderer:function(v){
276
+ return v.toFixed(2);
277
+ },
278
+ editor:{
279
+ xtype:'numberfield'
280
+ }
281
+ },
282
+ {
283
+ header:'Balance Date',
284
+ width:150,
285
+ dataIndex: 'balance_date',
286
+ renderer: Ext.util.Format.dateRenderer('m/d/Y'),
287
+ editor:{
288
+ xtype:'datefield'
289
+ }
290
+ },
291
+ {
292
+ header:'Due Date',
293
+ width:150,
294
+ dataIndex: 'due_date',
295
+ renderer: Ext.util.Format.dateRenderer('m/d/Y'),
296
+ editor:{
297
+ xtype:'datefield'
298
+ }
299
+ }
300
+ ],
301
+ store:store,
302
+ loadMask: true,
303
+ autoScroll:true,
304
+ stripeRows: true,
305
+ tbar:tbar,
306
+ bbar:Ext.create("Ext.PagingToolbar",{
307
+ pageSize:50,
308
+ store:store,
309
+ displayInfo: true,
310
+ displayMsg: '{0} - {1} of {2}',
311
+ emptyMsg: "Empty"
312
+ })
313
+
314
+ }, config);
315
+
316
+ this.callParent([config]);
317
+ }
318
+ });
@@ -0,0 +1,152 @@
1
+ Ext.define('Compass.ErpApp.Shared.InvoiceItem',{
2
+ extend:'Ext.data.Model',
3
+ fields:['item_description','quantity', 'id','created_at','amount', 'invoice_id'],
4
+ validations:[
5
+ {
6
+ type:'presence',
7
+ field:'item_description'
8
+ },
9
+ {
10
+ type:'presence',
11
+ field:'quantity'
12
+ },
13
+ {
14
+ type:'presence',
15
+ field:'amount'
16
+ }
17
+ ]
18
+ });
19
+
20
+ Ext.define("Compass.ErpApp.Shared.InvoiceItemsGridPanel",{
21
+ extend:"Ext.grid.Panel",
22
+ alias:'widget.shared-invoiceitemsgridpanel',
23
+ title:'Invoice Items',
24
+ initComponent : function(){
25
+ this.callParent(this.arguemnts);
26
+ },
27
+
28
+ constructor : function(config) {
29
+ var self = this;
30
+
31
+ var store = Ext.create('Ext.data.Store', {
32
+ fields:['item_description','quantity', 'id','created_at','amount'],
33
+ autoLoad: false,
34
+ autoSync: true,
35
+ proxy: {
36
+ type: 'rest',
37
+ url:'/erp_invoicing/erp_app/shared/invoices/invoice_items',
38
+ extraParams:{
39
+ invoice_id:null
40
+ },
41
+ reader: {
42
+ type: 'json',
43
+ successProperty: 'success',
44
+ idProperty: 'id',
45
+ root: 'invoice_items',
46
+ totalProperty:'totalCount',
47
+ messageProperty: 'messages'
48
+ },
49
+ writer: {
50
+ type: 'json',
51
+ writeAllFields:true,
52
+ root: 'data'
53
+ },
54
+ listeners: {
55
+ exception: function(proxy, response, operation){
56
+ Ext.MessageBox.show({
57
+ title: 'REMOTE EXCEPTION',
58
+ msg: 'Error performing action please try again.',
59
+ icon: Ext.MessageBox.ERROR,
60
+ buttons: Ext.Msg.OK
61
+ });
62
+ }
63
+ }
64
+ }
65
+ });
66
+
67
+ this.editingPlugin = Ext.create('Ext.grid.plugin.RowEditing', {
68
+ clicksToMoveEditor: 1
69
+ });
70
+
71
+ config = Ext.apply({
72
+ plugins:[this.editingPlugin],
73
+ layout:'fit',
74
+ columns: [
75
+ {
76
+ header:'Description',
77
+ width:500,
78
+ sortable: false,
79
+ dataIndex: 'item_description',
80
+ editor:{
81
+ xtype:'textfield'
82
+ }
83
+ },
84
+ {
85
+ header:'Quantity',
86
+ sortable: false,
87
+ dataIndex: 'quantity',
88
+ editor:{
89
+ xtype:'numberfield'
90
+ }
91
+ },
92
+ {
93
+ header:'Amount',
94
+ sortable: true,
95
+ dataIndex: 'amount',
96
+ editor:{
97
+ xtype:'numberfield'
98
+ }
99
+
100
+ },
101
+ {
102
+ header: 'Created At',
103
+ sortable: true,
104
+ width:150,
105
+ dataIndex: 'created_at',
106
+ renderer: Ext.util.Format.dateRenderer('m/d/Y H:i:s')
107
+ }
108
+ ],
109
+ autoScroll:true,
110
+ stripeRows: true,
111
+ store:store,
112
+ viewConfig:{
113
+ loadMask:false,
114
+ forceFit:true
115
+ },
116
+ tbar:{
117
+ items:[{
118
+ text: 'Add',
119
+ xtype:'button',
120
+ iconCls: 'icon-add',
121
+ handler: function(button) {
122
+ var grid = button.up('shared-invoiceitemsgridpanel');
123
+ var edit = grid.editingPlugin;
124
+ grid.store.insert(0, new Compass.ErpApp.Shared.InvoiceItem({invoice_id:grid.getStore().proxy.extraParams.invoice_id}));
125
+ edit.startEdit(0,0);
126
+ }
127
+ },'-',
128
+ {
129
+ text: 'Delete',
130
+ type:'button',
131
+ iconCls: 'icon-delete',
132
+ handler: function(button) {
133
+ Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this invoice item?', function(btn){
134
+ if(btn == 'no'){
135
+ return false;
136
+ }
137
+ else
138
+ {
139
+ var selection = self.getView().getSelectionModel().getSelection()[0];
140
+ if (selection) {
141
+ self.store.remove(selection);
142
+ }
143
+ }
144
+ });
145
+ }
146
+ }]
147
+ }
148
+ }, config);
149
+
150
+ this.callParent([config]);
151
+ }
152
+ });