erp_invoicing 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -66,7 +66,7 @@ module ErpInvoicing
66
66
  @total_payment = params[:total_payment]
67
67
 
68
68
  money = Money.create(
69
- :amount => @total_payment.to_f,
69
+ :amount => @total_payment.to_d,
70
70
  :description => "Online Payment",
71
71
  :currency => Currency.usd
72
72
  )
@@ -79,40 +79,46 @@ module ErpInvoicing
79
79
  financial_txn.save
80
80
 
81
81
  @billing_account_payment_amts.each do |hash|
82
- amount = hash[:amount].to_f rescue 0
82
+ amount = hash[:amount].to_d rescue 0
83
83
  if amount > 0
84
84
  comment = (params[:short_payment_comment] and hash[:short_payment]) ? params[:short_payment_comment] : nil
85
85
  PaymentApplication.create(
86
86
  :financial_txn => financial_txn,
87
87
  :payment_applied_to => hash[:billing_account],
88
- :money => Money.create(:amount => hash[:amount].to_f),
88
+ :money => Money.create(:amount => amount),
89
89
  :comment => comment
90
90
  )
91
91
  end
92
92
  end
93
93
 
94
- if financial_txn.apply_date == Date.today
95
- case @payment_account.class.to_s
94
+ #if financial_txn.apply_date == Date.today
95
+ case @payment_account.class.to_s
96
96
  when "BankAccount"
97
97
  financial_txn.txn_type = BizTxnType.ach_sale
98
98
  financial_txn.save
99
- result = @payment_account.purchase(financial_txn, ErpCommerce::Config.active_merchant_gateway_wrapper)
100
- if !result[:payment].nil? and result[:payment].success
101
- @authorization_code = result[:payment].authorization_code
102
- else
103
- @message = result[:message]
99
+
100
+ if financial_txn.apply_date == Date.today
101
+ result = @payment_account.purchase(financial_txn, ErpCommerce::Config.active_merchant_gateway_wrapper)
102
+ if !result[:payment].nil? and result[:payment].success
103
+ @authorization_code = result[:payment].authorization_code
104
+ else
105
+ @message = result[:message]
106
+ end
104
107
  end
105
108
  when "CreditCardAccount"
106
109
  financial_txn.txn_type = BizTxnType.cc_sale
107
110
  financial_txn.save
108
- result = @payment_account.purchase(financial_txn, params[:cvv], ErpCommerce::Config.active_merchant_gateway_wrapper)
109
- if !result[:payment].nil? and result[:payment].success
110
- @authorization_code = result[:payment].authorization_code
111
- else
112
- @message = result[:message]
111
+
112
+ if financial_txn.apply_date == Date.today
113
+ result = @payment_account.purchase(financial_txn, params[:cvv], ErpCommerce::Config.active_merchant_gateway_wrapper)
114
+ if !result[:payment].nil? and result[:payment].success
115
+ @authorization_code = result[:payment].authorization_code
116
+ else
117
+ @message = result[:message]
118
+ end
113
119
  end
114
- end
115
120
  end
121
+
116
122
 
117
123
  if @message.nil?
118
124
  render :json => {:success => true, :message => "Payment Successful!" }
@@ -145,7 +151,7 @@ module ErpInvoicing
145
151
  billing_account_payment_amts = []
146
152
  billing_account = BillingAccount.find(params["billing_account_id"])
147
153
  amount = params[:total_payment]
148
- billing_account_payment_amts << {:billing_account => billing_account, :amount => amount, :short_payment => (amount.to_f < billing_account.balance)}
154
+ billing_account_payment_amts << {:billing_account => billing_account, :amount => amount, :short_payment => (amount.to_d < billing_account.balance)}
149
155
 
150
156
  billing_account_payment_amts
151
157
  end
@@ -12,16 +12,16 @@ module ErpInvoicing
12
12
  clear_files
13
13
 
14
14
  result = {}
15
- upload_path = request.env['HTTP_EXTRAPOSTDATA_DIRECTORY'].blank? ? params[:directory] : request.env['HTTP_EXTRAPOSTDATA_DIRECTORY']
16
- name = request.env['HTTP_X_FILE_NAME'].blank? ? params[:file_data].original_filename : request.env['HTTP_X_FILE_NAME']
17
- data = request.env['HTTP_X_FILE_NAME'].blank? ? params[:file_data] : request.raw_post
15
+ upload_path = params[:directory]
16
+ name = params[:name]
17
+ data = request.raw_post
18
18
 
19
19
  begin
20
20
  @invoice.add_file(data, File.join(base_path, name))
21
21
  result = {:success => true}
22
22
  rescue Exception=>ex
23
- logger.error ex.message
24
- logger.error ex.backtrace.join("\n")
23
+ Rails.logger.error ex.message
24
+ Rails.logger.error ex.backtrace.join("\n")
25
25
  result = {:success => false, :error => "Error uploading file."}
26
26
  end
27
27
 
@@ -129,7 +129,7 @@ module ErpInvoicing
129
129
  def create_invoice_item
130
130
  data = params[:data]
131
131
  invoice = Invoice.find(params[:invoice_id])
132
- invoice_item = InvoiceItem.create(:amount => data[:amount].to_f, :quantity => data[:quantity], :item_description => data[:item_description])
132
+ invoice_item = InvoiceItem.create(:amount => data[:amount].to_d, :quantity => data[:quantity], :item_description => data[:item_description])
133
133
  invoice.items << invoice_item
134
134
 
135
135
  {:success => true,
@@ -146,7 +146,7 @@ module ErpInvoicing
146
146
  def update_invoice_item
147
147
  data = params[:data]
148
148
  invoice_item = InvoiceItem.find(data[:id])
149
- invoice_item.amount = data[:amount].to_f
149
+ invoice_item.amount = data[:amount].to_d
150
150
  invoice_item.quantity = data[:quantity]
151
151
  invoice_item.item_description = data[:item_description]
152
152
  invoice_item.save
@@ -87,7 +87,7 @@ module ErpInvoicing
87
87
  @payment_date = Date.today
88
88
 
89
89
  money = Money.create(
90
- :amount => @amount.to_f,
90
+ :amount => @amount.to_d,
91
91
  :description => "Clicktopay Payment Applied",
92
92
  :currency => Currency.usd
93
93
  )
@@ -1,5 +1,4 @@
1
1
  class BillingAccount < ActiveRecord::Base
2
- has_relational_dynamic_attributes
3
2
  acts_as_financial_txn_account
4
3
 
5
4
  belongs_to :calculate_balance_strategy_type
@@ -62,12 +61,13 @@ class BillingAccount < ActiveRecord::Base
62
61
  when 'invoices_and_payments'
63
62
  (self.invoices.balance.amount - self.total_payments)
64
63
  when 'payments'
65
- (self.balance - self.total_payments)
64
+ balance_amt = (self.balance - self.total_payments)
65
+ balance_amt == 0 ? 0 : balance_amt.round(2)
66
66
  else
67
- self.balance
67
+ self.balance == 0 ? 0 : self.balance.round(2)
68
68
  end
69
69
  else
70
- self.balance
70
+ self.balance == 0 ? 0 : self.balance.round(2)
71
71
  end
72
72
  end
73
73
 
@@ -76,7 +76,8 @@ class BillingAccount < ActiveRecord::Base
76
76
  end
77
77
 
78
78
  def outstanding_balance
79
- (calculate_balance - total_pending_payments)
79
+ outstanding_balance_amt = (calculate_balance - total_pending_payments)
80
+ outstanding_balance_amt == 0 ? 0 : outstanding_balance_amt.round(2)
80
81
  end
81
82
 
82
83
  def total_pending_payments
@@ -9,7 +9,7 @@ class RecurringPayment < ActiveRecord::Base
9
9
  if payment_amount < self.pay_up_to_amount
10
10
 
11
11
  money = Money.create(
12
- :amount => payment_amount.to_f,
12
+ :amount => payment_amount.to_d,
13
13
  :description => "AutoPayment",
14
14
  :currency => Currency.usd
15
15
  )
@@ -75,9 +75,9 @@ class InvoicingServices < ActiveRecord::Migration
75
75
  #non-key columns
76
76
  t.integer :item_seq_id
77
77
  t.string :item_description
78
- t.float :sales_tax
79
- t.float :quantity
80
- t.float :amount
78
+ t.decimal :sales_tax, :precision => 8, :scale => 2
79
+ t.decimal :quantity, :precision => 8, :scale => 2
80
+ t.decimal :amount, :precision => 8, :scale => 2
81
81
 
82
82
  t.timestamps
83
83
  end
@@ -151,8 +151,8 @@ class InvoicingServices < ActiveRecord::Migration
151
151
  create_table :recurring_payments do |t|
152
152
  t.references :payment_account, :polymorphic => true
153
153
  t.references :billing_account
154
- t.float :pay_up_to_amount
155
- t.float :payment_amount
154
+ t.decimal :pay_up_to_amount, :precision => 8, :scale => 2
155
+ t.decimal :payment_amount, :precision => 8, :scale => 2
156
156
  t.integer :payment_day
157
157
  t.date :from_date
158
158
  t.date :thru_date
@@ -217,7 +217,7 @@ class InvoicingServices < ActiveRecord::Migration
217
217
  #non-key columns
218
218
  t.string :description
219
219
  t.date :pay_by
220
- t.float :amount
220
+ t.decimal :amount, :precision => 8, :scale => 2
221
221
 
222
222
  t.timestamps
223
223
  end
@@ -2,7 +2,7 @@ module ErpInvoicing
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
8
  end
@@ -42,8 +42,6 @@ Ext.define("Compass.ErpApp.Shared.BillingAccountsGridPanel",{
42
42
  addDocument : function(rec){
43
43
  var uploadWindow = new Compass.ErpApp.Shared.UploadWindow({
44
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
45
  extraPostData:{}
48
46
  });
49
47
  uploadWindow.show();
@@ -262,7 +260,7 @@ Ext.define("Compass.ErpApp.Shared.BillingAccountsGridPanel",{
262
260
  width:100,
263
261
  dataIndex: 'payment_due',
264
262
  renderer:function(v){
265
- return v.toFixed(2);
263
+ return parseFloat(v).toFixed(2);
266
264
  },
267
265
  editor:{
268
266
  xtype:'numberfield'
@@ -273,7 +271,7 @@ Ext.define("Compass.ErpApp.Shared.BillingAccountsGridPanel",{
273
271
  width:100,
274
272
  dataIndex: 'balance',
275
273
  renderer:function(v){
276
- return v.toFixed(2);
274
+ return parseFloat(v).toFixed(2);
277
275
  },
278
276
  editor:{
279
277
  xtype:'numberfield'
@@ -5,8 +5,6 @@ Ext.define("Compass.ErpApp.Shared.InvoicesGridPanel",{
5
5
  addDocument : function(rec){
6
6
  var uploadWindow = new Compass.ErpApp.Shared.UploadWindow({
7
7
  standardUploadUrl:'/erp_invoicing/erp_app/shared/invoices/files/'+rec.get('id')+'/upload_file',
8
- flashUploadUrl:'/erp_invoicing/erp_app/shared/invoices/files/'+rec.get('id')+'/upload_file',
9
- xhrUploadUrl:'/erp_invoicing/erp_app/shared/invoices/files/'+rec.get('id')+'/upload_file',
10
8
  extraPostData:{}
11
9
  });
12
10
  uploadWindow.show();
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erp_invoicing
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-26 00:00:00.000000000 Z
12
+ date: 2012-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erp_inventory
16
- requirement: &70249999417200 !ruby/object:Gem::Requirement
16
+ requirement: &70232070628880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70249999417200
24
+ version_requirements: *70232070628880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: erp_work_effort
27
- requirement: &70249999412520 !ruby/object:Gem::Requirement
27
+ requirement: &70232070628360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70249999412520
35
+ version_requirements: *70232070628360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: erp_commerce
38
- requirement: &70249999424560 !ruby/object:Gem::Requirement
38
+ requirement: &70232070627820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70249999424560
46
+ version_requirements: *70232070627820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: erp_dev_svcs
49
- requirement: &70249999420280 !ruby/object:Gem::Requirement
49
+ requirement: &70232070627200 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '3.0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70249999420280
57
+ version_requirements: *70232070627200
58
58
  description: ErpInvoicing adds models and services to the CompassAE core to handle
59
59
  invoicing and billing functions. It includes extensions to the core ERP classes
60
60
  for accounts and things that are 'billable' (products, work efforts), and additional