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
@@ -1,25 +1,44 @@
1
- Ext.ns("Compass.ErpApp.Organizer.Applications.BillPay");
2
-
3
- Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.Layout",{
1
+ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.AccountDetailsPanel",{
4
2
  extend:"Ext.panel.Panel",
5
- alias:'widget.organizer_billpaylayout',
6
- accountId:null,
3
+ alias:'widget.organizer-billpayaccountdetailspanel',
7
4
  constructor : function(config) {
8
- var southPanel = Ext.create("Ext.panel.Panel",{
9
- layout:'fit',
5
+ var southPanel = {
6
+ xtype:'tabpanel',
10
7
  region:'south',
11
8
  height:300,
9
+ split:true,
12
10
  collapsible:true,
13
- border:false,
14
- items:[config['southComponent']]
15
- });
16
-
17
- var centerPanel = Ext.create("Ext.panel.Panel",{
11
+ items:[{
12
+ xtype:'shared-invoicesgridpanel',
13
+ billingAccountNumber:config.billingAccountNumber,
14
+ billingAccountId:config.billingAccountId,
15
+ showAddDelete:true
16
+ },{
17
+ xtype:'billpay-paymentaccountsgridpanel',
18
+ billingAccountNumber:config.billingAccountNumber,
19
+ billingAccountId:config.billingAccountId
20
+ }]
21
+ };
22
+
23
+ var billingAccount = config.billingAccount;
24
+ var billing_account_details = new Ext.Template(["<div style=\"padding: 10px;\"> ",
25
+ "Account Number: "+ billingAccount.get('account_number') +"<br>",
26
+ "Send Paper Bills: "+ billingAccount.get('send_paper_bills') +"<br>",
27
+ "Payable Online: "+ billingAccount.get('payable_online') +"<br>",
28
+ "Calculate Balance: "+ billingAccount.get('calculate_balance') +"<br>",
29
+ "Payment Due: "+ billingAccount.get('payment_due') +"<br>",
30
+ "Balance: "+ billingAccount.get('balance') +"<br>",
31
+ "Balance Date: "+ Ext.Date.format(billingAccount.get('balance_date'), 'm/d/Y') +"<br>",
32
+ "Due Date: "+ Ext.Date.format(billingAccount.get('due_date'), 'm/d/Y') +"<br>",
33
+ "</div>"]);
34
+
35
+ var centerPanel = {
36
+ xtype:'panel',
18
37
  layout:'fit',
19
38
  region:'center',
20
39
  autoScroll:true,
21
- items:[config['centerComponent']]
22
- })
40
+ html:billing_account_details
41
+ };
23
42
 
24
43
  config = Ext.apply({
25
44
  layout:'border',
@@ -33,47 +52,6 @@ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.Layout",{
33
52
 
34
53
  }, config);
35
54
  this.callParent([config]);
36
- },
37
-
38
- /**
39
- * set the private member accountId
40
- * @param {Integer} accountId
41
- */
42
- setaccountId : function(accountId){
43
- this.accountId = accountId;
44
- },
45
-
46
-
47
- loadAccountDetails : function(accountId){
48
- if(accountId == null){
49
- Ext.Msg.alert('Error', 'Account must be selected.');
50
- }
51
- else{
52
- this.accountId = accountId;
53
- var tabPanel = this.query('tabpanel')[0];
54
-
55
- var transactionsGrid = tabPanel.query('billpay_transactionsgridpanel')[0];
56
- transactionsGrid.getStore().load({
57
- params:{
58
- account_id:this.account_id
59
- }
60
- });
61
-
62
- var paymentAccountsGrid = tabPanel.query('billpay_paymentaccountsgridpanel')[0];
63
- paymentAccountsGrid.getStore().load({
64
- params:{
65
- account_id:this.account_id
66
- }
67
- });
68
-
69
- tabPanel.setActiveTab(0);
70
- }
71
- },
72
-
73
- loadRemoteData:function(){
74
- this.orderId = null;
75
- var accountsGridPanel = this.query('billpay_accountsgridpanel')[0]
76
- accountsGridPanel.getStore().load();
77
55
  }
78
56
 
79
57
  });
@@ -81,7 +59,7 @@ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.Layout",{
81
59
  Compass.ErpApp.Organizer.Applications.BillPay.Base = function(config){
82
60
 
83
61
  //setup extensions
84
- Compass.ErpApp.Organizer.Applications.BillPay.loadExtensions();
62
+ //Compass.ErpApp.Organizer.Applications.BillPay.loadExtensions();
85
63
 
86
64
  var treeMenuStore = Ext.create('Compass.ErpApp.Organizer.DefaultMenuTreeStore', {
87
65
  url:'/erp_invoicing/erp_app/organizer/bill_pay/base/menu',
@@ -90,6 +68,7 @@ Compass.ErpApp.Organizer.Applications.BillPay.Base = function(config){
90
68
  });
91
69
 
92
70
  var menuTreePanel = {
71
+ id:'billpaymenu',
93
72
  xtype:'defaultmenutree',
94
73
  title:'BillPay',
95
74
  store:treeMenuStore,
@@ -100,34 +79,67 @@ Compass.ErpApp.Organizer.Applications.BillPay.Base = function(config){
100
79
  }
101
80
  };
102
81
 
103
- var southTabPanel = {
82
+ var tabPanel = {
104
83
  xtype:'tabpanel',
84
+ title:'Bill Pay',
85
+ itemId:'billpay-application',
86
+ plugins: Ext.create('Ext.ux.TabCloseMenu', {
87
+ extraItemsTail: [
88
+ '-',
89
+ {
90
+ text: 'Closable',
91
+ checked: true,
92
+ hideOnClick: true,
93
+ handler: function (item) {
94
+ currentItem.tab.setClosable(item.checked);
95
+ }
96
+ }
97
+ ],
98
+ listeners: {
99
+ aftermenu: function () {
100
+ currentItem = null;
101
+ },
102
+ beforemenu: function (menu, item) {
103
+ var menuitem = menu.child('*[text="Closable"]');
104
+ currentItem = item;
105
+ menuitem.setChecked(item.closable);
106
+ }
107
+ }
108
+ }),
105
109
  items:[{
106
- xtype:'billpay_transactionsgridpanel'
107
- },{
108
- xtype:'billpay_paymentaccountsgridpanel'
109
- }]
110
- };
111
-
112
- var layout = {
113
- id:'billpay_layout',
114
- xtype:'organizer_billpaylayout',
115
- centerComponent:{
116
- id:'billpay_accountsGrid',
117
- xtype:'billpay_accountsgridpanel',
110
+ xtype:'shared-billingaccountsgridpanel',
111
+ title:'Search',
112
+ closable:false,
113
+ autoLoad:false,
118
114
  listeners:{
119
- 'itemclick':function(view, record, item, index, e, options){
120
- var id = record.get("id");
121
- var layout = view.findParentByType('organizer_billpaylayout');
122
- layout.loadAccountDetails(id);
115
+ 'itemdblclick':function(view, record, item, index, e, options){
116
+ var tabPanel = view.ownerCt.up('tabpanel');
117
+ var billingAccountNumber = record.get("account_number");
118
+ var billingAccountId = record.get("id");
119
+ var itemId = 'billingaccount'+billingAccountId;
120
+ item = tabPanel.query('#'+itemId).first();
121
+
122
+ if(Compass.ErpApp.Utility.isBlank(item)){
123
+ item = Ext.create("widget.organizer-billpayaccountdetailspanel",{
124
+ title:billingAccountNumber,
125
+ closable:true,
126
+ itemId:itemId,
127
+ billingAccountId:billingAccountId,
128
+ billingAccountNumber:billingAccountNumber,
129
+ billingAccount: record
130
+ });
131
+ tabPanel.add(item);
132
+ }
133
+
134
+ tabPanel.setActiveTab(item);
135
+
123
136
  }
124
137
  }
125
- },
126
- southComponent:southTabPanel
138
+ }]
127
139
  };
128
140
 
129
141
  this.setup = function(){
130
- config['organizerLayout'].addApplication(menuTreePanel, [layout]);
142
+ config['organizerLayout'].addApplication(menuTreePanel, [tabPanel]);
131
143
  };
132
144
 
133
145
  };
@@ -1,98 +1,7 @@
1
- Compass.ErpApp.Organizer.Applications.BillPay.loadExtensions = function(){
2
- //add Bill Pay tab to individuals tab panel
3
- var individualsTabPanel = Ext.getCmp('individualsTabPanel');
4
- individualsTabPanel.add({
5
- title:'Bill Pay',
6
- xtype:'billpay_accountsgridpanel',
7
- columns: [
8
- {
9
- header:'Account Number',
10
- sortable: true,
11
- dataIndex: 'account_number'
12
- },
13
- {
14
- header:'Payment Due',
15
- sortable: true,
16
- width:150,
17
- dataIndex: 'payment_due'
18
- },
19
- {
20
- header:'Next Billing Date',
21
- sortable: true,
22
- width:150,
23
- dataIndex: 'billing_date'
24
- },
25
- {
26
- header:'Next Payment Due',
27
- sortable: true,
28
- dataIndex: 'due_date'
29
- },
30
- {
31
- menuDisabled:true,
32
- resizable:false,
33
- xtype:'actioncolumn',
34
- header:'Make Payment',
35
- align:'center',
36
- width:100,
37
- items:[{
38
- icon:'/images/icons/creditcards/creditcards_16x16.png',
39
- tooltip:'Make Payment',
40
- handler :function(grid, rowIndex, colIndex){
41
- var rec = grid.getStore().getAt(rowIndex);
42
- var makePaymentWindow = Ext.create("Compass.ErpApp.Organizer.Applications.BillPay.MakePaymentWindow",{
43
- amount:rec.get('payment_due'),
44
- accountId:rec.get('id')
45
- });
46
- makePaymentWindow.show();
47
- }
48
- }]
49
- },
50
- {
51
- menuDisabled:true,
52
- resizable:false,
53
- xtype:'actioncolumn',
54
- header:'Account Details',
55
- align:'center',
56
- width:100,
57
- items:[{
58
- icon:'/images/icons/about/about_16x16.png',
59
- tooltip:'View Account Details',
60
- handler :function(grid, rowIndex, colIndex){
61
- var rec = grid.getStore().getAt(rowIndex);
62
- var accountId = rec.get('id');
63
-
64
- var billPayLayout = Ext.getCmp('billpay_layout');
65
- billPayLayout.loadAccountDetails(accountId);
66
- var accountsGridPanel = billPayLayout.query('billpay_accountsgridpanel')[0];
67
- accountsGridPanel.getStore().load({
68
- params:{
69
- account_id:accountId,
70
- start:1,
71
- limit:1
72
- }
73
- })
74
-
75
- Compass.ErpApp.Organizer.Layout.setActiveCenterItem('billpay_layout', false);
76
- }
77
- }]
78
- },
79
- {
80
- menuDisabled:true,
81
- resizable:false,
82
- xtype:'actioncolumn',
83
- header:'Delete',
84
- align:'center',
85
- width:60,
86
- items:[{
87
- icon:'/images/icons/delete/delete_16x16.png',
88
- tooltip:'Delete',
89
- handler :function(grid, rowIndex, colIndex){
90
- var rec = grid.getStore().getAt(rowIndex);
91
- grid.deleteOrder(rec);
92
- }
93
- }]
94
- }
95
- ],
1
+ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.PartyAccountsTab",{
2
+ extend:"Compass.ErpApp.Shared.BillingAccountsGridPanel",
3
+ alias:'widget.billpay',
4
+ title:'Accounts',
96
5
  listeners:{
97
6
  activate:function(grid){
98
7
  var contactsLayout = grid.findParentByType('contactslayout');
@@ -108,5 +17,5 @@ Compass.ErpApp.Organizer.Applications.BillPay.loadExtensions = function(){
108
17
  }
109
18
  }
110
19
  }
111
- });
112
- };
20
+
21
+ });
@@ -3,22 +3,25 @@ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.MakePaymentWindow",{
3
3
  alias:'widget.billpay_makepaymentwindow',
4
4
  constructor : function(config) {
5
5
  config = Ext.apply({
6
+ id: 'billpay_makepayment_window',
6
7
  layout:'fit',
7
8
  width:300,
8
9
  title:'Make Payment',
9
- iconCls:'icon-credit_cards',
10
+ iconCls:'icon-creditcards',
10
11
  buttonAlign:'center',
11
12
  plain: true,
12
13
  items: Ext.create('Ext.form.Panel',{
14
+ id: 'billpay_makepayment_form',
13
15
  baseParams:{
14
- account_id:config.accountId
16
+ billing_account_id:config.billing_account_id
15
17
  },
16
18
  url:config['url'],
17
19
  items: [
18
20
  {
19
- xtype:'displayfield',
21
+ xtype:'numberfield',
20
22
  value:config['amount'],
21
- fieldLabel:'Amount'
23
+ fieldLabel:'Amount',
24
+ name: 'amount'
22
25
  },
23
26
  {
24
27
  xtype:'combo',
@@ -58,21 +61,24 @@ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.MakePaymentWindow",{
58
61
  text:'Submit',
59
62
  listeners:{
60
63
  'click':function(button){
61
- var win = button.findParentByType('creditcardwindow');
62
- var formPanel = win.findByType('form')[0];
64
+ var win = Ext.getCmp('billpay_makepayment_window');
65
+ var formPanel = Ext.getCmp('billpay_makepayment_form');
63
66
  //formPanel.findById('credit_card_amount_hidden').setValue(formPanel.findById('credit_card_amount').getValue().replace("$","").replace(",",""));
64
- if(win.validateCreditCardInfo(formPanel.getForm())){
67
+ //if(win.validateCreditCardInfo(formPanel.getForm())){
65
68
  formPanel.getForm().submit({
66
69
  method:config['method'] || 'POST',
67
70
  waitMsg:'Processing Credit Card...',
68
71
  success:function(form, action){
69
- var response = Ext.util.JSON.decode(action.response.responseText);
70
- win.fireEvent('charge_response', win, response);
72
+ var response = Ext.decode(action.response.responseText);
73
+ //win.fireEvent('charge_response', win, response);
74
+ if (response.success == true){ win.destroy(); }
75
+ Ext.Msg.alert('Success','Payment Successful');
71
76
  },
72
77
  failure:function(form, action){
73
78
  if(action.response != null){
74
- var response = Ext.util.JSON.decode(action.response.responseText);
75
- win.fireEvent('charge_failure', win, response);
79
+ var response = Ext.decode(action.response.responseText);
80
+ //win.fireEvent('charge_failure', win, response);
81
+ Ext.Msg.alert('Error','Payment Failed');
76
82
  }
77
83
  else
78
84
  {
@@ -80,7 +86,7 @@ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.MakePaymentWindow",{
80
86
  }
81
87
  }
82
88
  });
83
- }
89
+ //}
84
90
  }
85
91
  }
86
92
  },
@@ -89,7 +95,7 @@ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.MakePaymentWindow",{
89
95
  listeners:{
90
96
  'click':function(button){
91
97
  var win = button.findParentByType('billpay_makepaymentwindow');
92
- win.close();
98
+ win.destroy();
93
99
  }
94
100
  }
95
101
  }]
@@ -1,6 +1,6 @@
1
1
  Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.PaymentAccountsGridPanel",{
2
2
  extend:"Ext.grid.Panel",
3
- alias:'widget.billpay_paymentaccountsgridpanel',
3
+ alias:'widget.billpay-paymentaccountsgridpanel',
4
4
 
5
5
  initComponent : function(){
6
6
  this.bbar = Ext.create("Ext.PagingToolbar",{
@@ -16,6 +16,7 @@ Ext.define("Compass.ErpApp.Organizer.Applications.BillPay.PaymentAccountsGridPan
16
16
 
17
17
  constructor : function(config) {
18
18
  var store = Ext.create("Ext.data.Store",{
19
+ autoLoad: true,
19
20
  proxy:{
20
21
  type:'ajax',
21
22
  url: '/erp_invoicing/erp_app/organizer/bill_pay/accounts/payment_accounts',
@@ -0,0 +1,220 @@
1
+ Ext.define("Compass.ErpApp.Shared.AddInvoiceWindow",{
2
+ extend:"Ext.window.Window",
3
+ alias:'widget.shared-addinvoicewindow',
4
+ initComponent : function() {
5
+ this.addEvents(
6
+ "create_success",
7
+ "create_failure"
8
+ );
9
+
10
+ this.callParent(this.arguments);
11
+ },
12
+ constructor : function(config) {
13
+ var form = Ext.create("Ext.form.Panel",{
14
+ labelWidth:110,
15
+ frame:false,
16
+ bodyStyle:'padding:5px 5px 0',
17
+ autoHeight:true,
18
+ url:'/erp_invoicing/erp_app/shared/invoices/create_invoice',
19
+ items: [{
20
+ xtype: 'textfield',
21
+ fieldLabel:'Invoice Number',
22
+ name:'invoice_number',
23
+ allowBlank:false
24
+ },
25
+ {
26
+ xtype: 'textarea',
27
+ height:100,
28
+ fieldLabel:'Description',
29
+ name:'description',
30
+ allowBlank:false
31
+ },
32
+ {
33
+ xtype: 'textarea',
34
+ height:100,
35
+ fieldLabel:'Message',
36
+ name:'message',
37
+ allowBlank:true
38
+ },
39
+ {
40
+ xtype: 'datefield',
41
+ fieldLabel:'Invoice Date',
42
+ name:'invoice_date',
43
+ allowBlank:false
44
+ },
45
+ {
46
+ xtype: 'datefield',
47
+ fieldLabel:'Due Date',
48
+ name:'due_date',
49
+ allowBlank:false
50
+ }
51
+ // {
52
+ // xtype:'combo',
53
+ // hiddenName:'billed_from_party_id',
54
+ // name:'billed_from_party_id',
55
+ // loadingText:'Retrieving Parties...',
56
+ // store:Ext.create('Ext.data.Store',{
57
+ // proxy:{
58
+ // type:'ajax',
59
+ // reader:{
60
+ // type:'json',
61
+ // root:'parties'
62
+ // },
63
+ // url:'/erp_invoicing/erp_app/desktop/invoice_management/parties'
64
+ // },
65
+ // fields:[
66
+ // {
67
+ // name:'id'
68
+ // },
69
+ // {
70
+ // name:'description'
71
+ //
72
+ // }
73
+ // ]
74
+ // }),
75
+ // forceSelection:true,
76
+ // editable:true,
77
+ // fieldLabel:'Billed From Party',
78
+ // autoSelect:true,
79
+ // typeAhead: true,
80
+ // mode: 'remote',
81
+ // displayField:'description',
82
+ // valueField:'id',
83
+ // triggerAction: 'all',
84
+ // allowBlank:true
85
+ // },
86
+ // {
87
+ // xtype:'combo',
88
+ // hiddenName:'billed_to_party_id',
89
+ // name:'billed_to_party_id',
90
+ // loadingText:'Retrieving Parties...',
91
+ // store:Ext.create('Ext.data.Store',{
92
+ // proxy:{
93
+ // type:'ajax',
94
+ // reader:{
95
+ // type:'json',
96
+ // root:'parties'
97
+ // },
98
+ // url:'/erp_invoicing/erp_app/desktop/invoice_management/parties'
99
+ // },
100
+ // fields:[
101
+ // {
102
+ // name:'id'
103
+ // },
104
+ // {
105
+ // name:'description'
106
+ //
107
+ // }
108
+ // ]
109
+ // }),
110
+ // forceSelection:true,
111
+ // editable:true,
112
+ // fieldLabel:'Billed To Party',
113
+ // autoSelect:true,
114
+ // typeAhead: true,
115
+ // mode: 'remote',
116
+ // displayField:'description',
117
+ // valueField:'id',
118
+ // triggerAction: 'all',
119
+ // allowBlank:true
120
+ // }
121
+ ]
122
+ });
123
+
124
+ if(!Compass.ErpApp.Utility.isBlank(config['billingAccountNumber'])){
125
+ form.add({
126
+ xtype:'displayfield',
127
+ fieldLabel:'Billing Account',
128
+ value:config['billingAccountNumber']
129
+ });
130
+ form.add({
131
+ xtype:'hidden',
132
+ name:'billing_account_id',
133
+ value:config['billingAccountId']
134
+ });
135
+ }
136
+ else{
137
+ form.add({
138
+ xtype:'combo',
139
+ hiddenName:'billing_account_id',
140
+ name:'billing_account_id',
141
+ itemId:'billingAccountIdCombo',
142
+ loadingText:'Retrieving Billing Accounts...',
143
+ store:{
144
+ autoLoad:true,
145
+ xtype:'store',
146
+ proxy:{
147
+ type:'ajax',
148
+ reader:{
149
+ type:'json',
150
+ root:'billing_accounts'
151
+ },
152
+ url:'/erp_invoicing/erp_app/shared/invoices/billing_accounts'
153
+ },
154
+ fields:[
155
+ {
156
+ name:'id'
157
+ },
158
+ {
159
+ name:'account_number'
160
+ }
161
+ ]
162
+ },
163
+ forceSelection:true,
164
+ editable:true,
165
+ fieldLabel:'Billing Account',
166
+ autoSelect:true,
167
+ typeAhead: true,
168
+ mode: 'remote',
169
+ displayField:'account_number',
170
+ valueField:'id',
171
+ triggerAction: 'all',
172
+ allowBlank:false
173
+ });
174
+ }
175
+
176
+ config = Ext.apply({
177
+ title:'Add Invoice',
178
+ iconCls:'icon-add',
179
+ buttonAlign:'center',
180
+ plain: true,
181
+ items: [form],
182
+ buttons: [{
183
+ text:'Submit',
184
+ listeners:{
185
+ 'click':function(button){
186
+ var win = button.findParentByType('shared-addinvoicewindow');
187
+ var formPanel = win.query('form')[0];
188
+ formPanel.getForm().submit({
189
+ method:'POST',
190
+ waitMsg:'Creating...',
191
+ success:function(form, action){
192
+ var response = Ext.decode(action.response.responseText);
193
+ win.fireEvent('create_success', win, response);
194
+ win.close();
195
+ },
196
+ failure:function(form, action){
197
+ Ext.Msg.alert('Error', 'Error creating invoice.');
198
+ }
199
+ });
200
+ }
201
+ }
202
+ },
203
+ {
204
+ text: 'Cancel',
205
+ listeners:{
206
+ 'click':function(button){
207
+ var win = button.findParentByType('shared-addinvoicewindow');
208
+ var form = win.query('form')[0];
209
+ form.getForm().reset();
210
+ win.close();
211
+ }
212
+ }
213
+ }
214
+ ]
215
+ }, config);
216
+
217
+ this.callParent([config]);
218
+ }
219
+
220
+ });