app/models/imports/donations_import.rb in artfully_ose-1.2.0.beta.1 vs app/models/imports/donations_import.rb in artfully_ose-1.2.0.pre
- old
+ new
@@ -46,12 +46,30 @@
end
validate_amounts(parsed_row)
true
end
+
+ def create_person(parsed_row)
+ Rails.logger.info("Import #{id} DONATION_IMPORT: Creating person")
+ if !parsed_row.email.blank?
+ person = Person.first_or_create({:email => parsed_row.email, :organization => self.organization}.merge(parsed_row.person_attributes), {}) do |p|
+ p.import = self
+ end
+ else
+ person = attach_person(parsed_row)
+ if !person.save
+ Rails.logger.info("Import #{id} DONATION_IMPORT: Person save failed")
+ self.import_errors.create! :row_data => parsed_row.row, :error_message => person.errors.full_messages.join(", ")
+ self.reload
+ fail!
+ end
+ end
+ person
+ end
def create_contribution(parsed_row, person)
- Rails.logger.info("Processing Import [#{id}] DONATION_IMPORT: Creating contribution")
+ Rails.logger.info("Import #{id} DONATION_IMPORT: Creating contribution")
validate_amounts(parsed_row)
amount = parsed_row.amount
deductible_amount = parsed_row.unparsed_deductible_amount.blank? ? amount - parsed_row.nongift_amount : parsed_row.deductible_amount
nongift_amount = parsed_row.unparsed_nongift_amount.blank? ? amount - deductible_amount : parsed_row.nongift_amount
\ No newline at end of file