It appears that the PayPal CSV has magically changed formats to no longer include a preceding space in the column names, which gets turned into a preceding underscore.
The first 6 lines of the header do need to be removed, however.
This commit is contained in:
parent
3097803d05
commit
5a8375581f
|
@ -17,8 +17,13 @@ class PaypalCsv < ActiveRecord::Base
|
||||||
csv = CSV.table(filename)
|
csv = CSV.table(filename)
|
||||||
csv.each do |row|
|
csv.each do |row|
|
||||||
paypal_csv = PaypalCsv.new()
|
paypal_csv = PaypalCsv.new()
|
||||||
|
logger.fatal row.inspect
|
||||||
paypal_csv.attributes.each do |c|
|
paypal_csv.attributes.each do |c|
|
||||||
|
# Try finding the column without a prepended _ first (compatibility with new CSV format)
|
||||||
|
unless row[c.first[1..-1].to_sym].nil?
|
||||||
|
paypal_csv[c.first.to_sym] = row[c.first[1..-1].to_sym]
|
||||||
|
end
|
||||||
|
# If there's an exact match, it takes precedence
|
||||||
unless row[c.first.to_sym].nil?
|
unless row[c.first.to_sym].nil?
|
||||||
paypal_csv[c.first.to_sym] = row[c.first.to_sym]
|
paypal_csv[c.first.to_sym] = row[c.first.to_sym]
|
||||||
end
|
end
|
||||||
|
@ -37,6 +42,8 @@ class PaypalCsv < ActiveRecord::Base
|
||||||
|
|
||||||
private
|
private
|
||||||
def create_payment
|
def create_payment
|
||||||
|
logger.fatal self.inspect
|
||||||
|
|
||||||
# find user by email, then by payee
|
# find user by email, then by payee
|
||||||
user = User.where("lower(email) = ?", self._from_email_address.downcase).first
|
user = User.where("lower(email) = ?", self._from_email_address.downcase).first
|
||||||
user = User.where("lower(payee) = ?", self._from_email_address.downcase).first if user.nil? && self._from_email_address.present?
|
user = User.where("lower(payee) = ?", self._from_email_address.downcase).first if user.nil? && self._from_email_address.present?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user