Skip to content

Commit

Permalink
Merge branch 'master' into show-activity-open-time
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasDeBruijn authored Jul 23, 2024
2 parents 481107f + 993c9d8 commit 803b30c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 15 additions & 6 deletions app/controllers/admin/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/public/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit 803b30c

Please sign in to comment.