diff --git a/app/controllers/admin/payments_controller.rb b/app/controllers/admin/payments_controller.rb index b3fc6fbff..7df4cb47b 100644 --- a/app/controllers/admin/payments_controller.rb +++ b/app/controllers/admin/payments_controller.rb @@ -134,12 +134,11 @@ def create_invoice(csv, payments, payment_type, start_date, end_date = nil) # now create every transaction row with the following date: Blank, ledger account, # transaction description, VAT number, amount, cost_location () a = Activity.find_by(id: activity_id) - csv << if a && a.name == "Lidmaatschap" - # Dislike this way of doing it but need better ways to find membership activities - # An alternative could be activity_id == Settings['intro.membership'], - # this would make it only pass for last year membership activity + csv << if a && (a.name == "Lidmaatschap" || a.id == Settings['intro.membership']) + # Check on the name to allow previous years to be exported. + ["", "8000", "#{ p.activity.name } - #{ p.member_id }", '0', - p.currency + payment.transaction_fee, ""] + p.currency + p.transaction_fee, ""] elsif p.activity.group.nil? || (!p.activity.group.nil? && p.activity.group.ledgernr.blank?) ["", "1302", "#{ p.activity.name } - #{ p.member_id }", p.activity.VAT, @@ -156,8 +155,13 @@ def create_invoice(csv, payments, payment_type, start_date, end_date = nil) csv << ["", Settings.mongoose_ledger_number, "Mongoose - #{ payment.member_id }", "9", payment.amount - Settings.mongoose_ideal_costs, ""] end + # minus lidmaatschap payments + activity_amount = payments.where(transaction_type: :activity).count - payments.where( + transaction_type: :activity, + transaction_id: Settings['intro.membership'] + ).count + # TODO: should probably be backwards compatible but we don't log all membership activities - activity_amount = payments.where(transaction_type: :activity).count mongoose_amount = payments.where(transaction_type: :checkout).count trx_cost = "Transaction costs #{ Settings.mongoose_ideal_costs } x #{ activity_amount }" trx_cost_amount = (Settings.mongoose_ideal_costs * activity_amount).round(2) @@ -166,6 +170,11 @@ def create_invoice(csv, payments, payment_type, start_date, end_date = nil) csv << ["", Settings.accountancy_ledger_number, trx_cost, "21", trx_cost_amount, Settings.accountancy_cost_location] + + # As of December 2023, mongoose has been decoupled from Koala + # Exports after that don't really have to include the mongoose costs or TRX costs + return unless trx_mongoose_amount != 0 + csv << ["", Settings.accountancy_ledger_number, trx_mongoose_cost, "21", trx_mongoose_amount, Settings.accountancy_cost_location] end diff --git a/app/controllers/public/home_controller.rb b/app/controllers/public/home_controller.rb index eba07fca0..79d05f5a7 100644 --- a/app/controllers/public/home_controller.rb +++ b/app/controllers/public/home_controller.rb @@ -52,14 +52,13 @@ def create transaction = Payment.new( description: I18n.t("form.introduction", user: @member.name), - amount: total, + amount: total - Settings.mongoose_ideal_costs, # Transaction costs are paid by the association issuer: params[:bank], member: @member, transaction_id: activities.map(&:id), transaction_type: :activity, payment_type: :ideal, - redirect_uri: public_url )