1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

[bug] invoices with total = 0, are marked as paid on site even if paid by card

This commit is contained in:
Sylvain 2019-09-17 15:13:20 +02:00
parent 1fa36d4029
commit 30e7ce8377
4 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,7 @@
# Changelog Fab Manager
- Ability to configure and export the accounting data to the ACD accounting software
- Fix a bug: invoices with total = 0, are marked as paid on site even if paid by card
- [TODO DEPLOY] `rake db:migrate`
## v4.1.0 2019 September 12

View File

@ -253,7 +253,7 @@ class Invoice < ActiveRecord::Base
end
def paid_with_stripe?
stp_payment_intent_id? || stp_invoice_id?
stp_payment_intent_id? || stp_invoice_id? || payment_method == 'stripe'
end
private

View File

@ -202,11 +202,14 @@ class Reservation < ActiveRecord::Base
end
def save_with_payment(operator_profile_id, coupon_code = nil, payment_intent_id = nil)
method = InvoicingProfile.find(operator_profile_id)&.user&.admin? ? nil : 'stripe'
build_invoice(
invoicing_profile: user.invoicing_profile,
statistic_profile: user.statistic_profile,
operator_profile_id: operator_profile_id,
stp_payment_intent_id: payment_intent_id
stp_payment_intent_id: payment_intent_id,
payment_method: method
)
generate_invoice_items(true, coupon_code)

View File

@ -46,6 +46,7 @@ class Subscription < ActiveRecord::Base
def generate_invoice(operator_profile_id, coupon_code = nil, payment_intent_id = nil)
coupon_id = nil
total = plan.amount
method = InvoicingProfile.find(operator_profile_id)&.user&.admin? ? nil : 'stripe'
unless coupon_code.nil?
@coupon = Coupon.find_by(code: coupon_code)
@ -64,7 +65,8 @@ class Subscription < ActiveRecord::Base
total: total,
coupon_id: coupon_id,
operator_profile_id: operator_profile_id,
stp_payment_intent_id: payment_intent_id
stp_payment_intent_id: payment_intent_id,
payment_method: method
)
invoice.invoice_items.push InvoiceItem.new(
amount: plan.amount,