1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

WIP: refactor models to use payment_gateway_objects

This commit is contained in:
Sylvain 2021-04-21 17:38:06 +02:00
parent 95a06f7d02
commit 26dfbef5e1
35 changed files with 120 additions and 71 deletions

View File

@ -7,6 +7,7 @@
- Fix a bug: unable to set date formats during installation
- Fix a bug: unable to cancel the upgrade before it begins
- `SUPERADMIN_EMAIL` renamed to `ADMINSYS_EMAIL`
- [BREAKING CHANGE] GET `open_api/v1/invoices` won't return `stp_invoice_id` OR `stp_payment_intent_id` anymore. The new field `payment_gateway_object` will contain some similar data if the invoice was paid online by card.
- [TODO DEPLOY] `rails fablab:stripe:set_gateway`
- [TODO DEPLOY] `rails fablab:maintenance:rebuild_stylesheet`
- [TODO DEPLOY] `\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/rename-adminsys.sh | bash`

View File

@ -37,7 +37,7 @@ class API::PaymentSchedulesController < API::ApiController
def cash_check
authorize @payment_schedule_item.payment_schedule
PaymentScheduleService.new.generate_invoice(@payment_schedule_item)
PaymentScheduleService.new.generate_invoice(@payment_schedule_item, payment_method: 'check')
attrs = { state: 'paid', payment_method: 'check' }
@payment_schedule_item.update_attributes(attrs)

View File

@ -26,8 +26,10 @@ class OpenAPI::V1::InvoicesDoc < OpenAPI::V1::BaseDoc
"invoiced_id": 3257,
"user_id": 211,
"invoiced_type": "Reservation",
"stp_invoice_id": "in_187DLE4zBvgjueAZ6L7SyQlU",
"stp_payment_intent_id": "pi_1Dat4P2eZvKYlo2C3MxszwQp",
"payment_gateway_object": {
id: "in_187DLE4zBvgjueAZ6L7SyQlU",
type: "Stripe::Invoice"
},
"reference": "1605017/VL",
"total": 1000,
"type": null,
@ -42,8 +44,10 @@ class OpenAPI::V1::InvoicesDoc < OpenAPI::V1::BaseDoc
"invoiced_id": 3229,
"user_id": 211,
"invoiced_type": "Reservation",
"stp_invoice_id": "in_185Hmt4zBvgjueAZl5lio1pK",
"stp_payment_intent_id": "pi_2Dat4P2eYbKYlo2C3MxszwQp",
"payment_gateway_object": {
id: "pi_2Dat4P2eYbKYlo2C3MxszwQp",
type: "Stripe::PaymentIntent"
},
"reference": "1604176/VL",
"total": 2000,
"type": null,
@ -58,8 +62,10 @@ class OpenAPI::V1::InvoicesDoc < OpenAPI::V1::BaseDoc
"invoiced_id": 3218,
"user_id": 211,
"invoiced_type": "Reservation",
"stp_invoice_id": "in_184oNK4zBvgjueAZJdOxHJjT",
"stp_payment_intent_id": "pi_1Pub4P2eZvKYlo2C3MxszwQm",
"payment_gateway_object": {
id: "ba15dc9d8f3e0fa17bf527466",
type: "PayZen::Order"
},
"reference": "1604166/VL",
"total": 2000,
"type": null,

View File

@ -1126,8 +1126,8 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
});
});
if (invoice.stripe) {
return $scope.avoirModes.push({ name: _t('app.admin.invoices.online_payment'), value: 'stripe' });
if (invoice.online_payment) {
return $scope.avoirModes.push({ name: _t('app.admin.invoices.online_payment'), value: 'card' });
}
};

View File

@ -6,7 +6,7 @@ class InvoiceItem < Footprintable
belongs_to :subscription
has_one :invoice_item # associates invoice_items of an invoice to invoice_items of an Avoir
has_one :payment_gateway_object
has_one :payment_gateway_object, as: :item
after_create :chain_record
after_update :log_changes

View File

@ -6,6 +6,10 @@ require 'payment/item_builder'
class PaymentGatewayObject < ApplicationRecord
belongs_to :item, polymorphic: true
belongs_to :invoice, foreign_type: 'Invoice', foreign_key: 'item_id'
belongs_to :invoice_item, foreign_type: 'InvoiceItem', foreign_key: 'item_id'
belongs_to :subscription, foreign_type: 'Subscription', foreign_key: 'item_id'
belongs_to :payment_schedule, foreign_type: 'PaymentSchedule', foreign_key: 'item_id'
belongs_to :payment_schedule_item, foreign_type: 'PaymentScheduleItem', foreign_key: 'item_id'
def gateway_object
item = Payment::ItemBuilder.build(gateway_object_type)

View File

@ -16,7 +16,7 @@ class PaymentSchedule < PaymentDocument
belongs_to :reservation, foreign_type: 'Reservation', foreign_key: 'scheduled_id'
has_many :payment_schedule_items
has_many :payment_gateway_object
has_many :payment_gateway_objects, as: :item
before_create :add_environment
after_create :update_reference, :chain_record
@ -48,6 +48,10 @@ class PaymentSchedule < PaymentDocument
payment_schedule_items.order(due_date: :asc)
end
def gateway_object(klass)
payment_gateway_objects.find_by(gateway_object_type: klass)
end
def user
invoicing_profile.user
end
@ -63,7 +67,7 @@ class PaymentSchedule < PaymentDocument
end
def post_save(setup_intent_id)
return unless payment_method == 'stripe'
return unless payment_method == 'card'
StripeService.create_stripe_subscription(self, setup_intent_id)
end

View File

@ -4,7 +4,7 @@
class PaymentScheduleItem < Footprintable
belongs_to :payment_schedule
belongs_to :invoice
has_one :payment_gateway_object
has_one :payment_gateway_object, as: :item
after_create :chain_record

View File

@ -8,7 +8,7 @@ class Subscription < ApplicationRecord
belongs_to :statistic_profile
has_one :payment_schedule, as: :scheduled, dependent: :destroy
has_one :payment_gateway_object
has_one :payment_gateway_object, as: :item
has_many :invoices, as: :invoiced, dependent: :destroy
has_many :offer_days, dependent: :destroy

View File

@ -78,15 +78,19 @@ class PaymentScheduleService
# Generate the invoice associated with the given PaymentScheduleItem, with the children elements (InvoiceItems).
# @param payment_method {String} the payment method or gateway in use
# @param payment_id {String} the identifier of the payment as provided by the payment gateway, in case of card payment
# @param payment_type {String} the object type of payment_id
##
def generate_invoice(payment_schedule_item, payment_method: nil, payment_id: nil)
def generate_invoice(payment_schedule_item, payment_method: nil, payment_id: nil, payment_type: nil)
# build the base invoice
invoice = Invoice.new(
invoiced: payment_schedule_item.payment_schedule.scheduled,
invoicing_profile: payment_schedule_item.payment_schedule.invoicing_profile,
statistic_profile: payment_schedule_item.payment_schedule.statistic_profile,
operator_profile_id: payment_schedule_item.payment_schedule.operator_profile_id,
stp_payment_intent_id: payment_id,
payment_gateway_object_attributes: {
gateway_object_id: payment_id,
gateway_object_type: payment_type
},
payment_method: payment_method
)
# complete the invoice with some InvoiceItem

View File

@ -68,9 +68,14 @@ class Subscriptions::Subscribe
operator_profile_id: operator_profile_id,
user: new_sub.user,
payment_method: schedule.payment_method,
payment_id: schedule.stp_setup_intent_id)
payment_id: schedule.gateway_object('Stripe::SetupIntent').id)
else
generate_invoice(subscription, operator_profile_id, details)
generate_invoice(subscription,
operator_profile_id,
details,
payment_id: schedule.gateway_object('Stripe::SetupIntent').id,
payment_type: 'Stripe::SetupIntent',
payment_method: schedule.payment_method)
end
payment.save
payment.post_save(schedule&.stp_setup_intent_id)

View File

@ -8,7 +8,6 @@ json.date @avoir.avoir_date
json.chained_footprint @avoir.check_footprint
json.items @avoir.invoice_items do |item|
json.id item.id
json.stp_invoice_item_id item.stp_invoice_item_id
json.amount item.amount / 100.0
json.description item.description
json.invoice_item_id item.invoice_item_id

View File

@ -12,7 +12,7 @@ json.array!(@invoices) do |invoice|
json.has_avoir invoice.refunded?
json.is_avoir invoice.is_a?(Avoir)
json.is_subscription_invoice invoice.subscription_invoice?
json.stripe invoice.paid_by_card?
json.online_payment invoice.paid_by_card?
json.date invoice.is_a?(Avoir) ? invoice.avoir_date : invoice.created_at
json.prevent_refund invoice.prevent_refund?
json.chained_footprint invoice.check_footprint

View File

@ -12,7 +12,6 @@ json.date @invoice.is_a?(Avoir) ? @invoice.avoir_date : @invoice.created_at
json.chained_footprint @invoice.check_footprint
json.items @invoice.invoice_items do |item|
json.id item.id
json.stp_invoice_item_id item.stp_invoice_item_id
json.amount item.amount / 100.0
json.description item.description
json.avoir_item_id item.invoice_item.id if item.invoice_item

View File

@ -65,7 +65,6 @@ if member.subscription
json.id member.subscription.id
json.expired_at member.subscription.expired_at.iso8601
json.canceled_at member.subscription.canceled_at.iso8601 if member.subscription.canceled_at
json.stripe member.subscription.stp_subscription_id.present?
json.plan do # TODO, refactor: duplicates subscribed_plan
json.id member.subscription.plan.id
json.base_name member.subscription.plan.base_name

View File

@ -54,7 +54,6 @@ json.array!(@members) do |member|
json.id member.subscription.id
json.expired_at member.subscription.expired_at.iso8601
json.canceled_at member.subscription&.canceled_at&.iso8601
json.stripe member.subscription.stp_subscription_id.present?
json.plan do
json.id member.subscription.plan.id
json.name member.subscription.plan.name

View File

@ -1,7 +1,8 @@
# frozen_string_literal: true
json.extract! subscription, :id, :plan_id
json.expired_at subscription.expired_at.iso8601
json.canceled_at subscription.canceled_at.iso8601 if subscription.canceled_at
json.stripe subscription.stp_subscription_id.present?
json.plan do
json.partial! 'api/shared/plan', plan: subscription.plan
end

View File

@ -2,7 +2,13 @@
json.invoices do
json.array!(invoices) do |invoice|
json.extract! invoice[:invoice], :id, :stp_invoice_id, :stp_payment_intent_id, :created_at, :reference, :footprint
json.extract! invoice[:invoice], :id, :payment_method, :created_at, :reference, :footprint
if invoice[:invoice].payment_gateway_object
json.payment_gateway_object do
json.id invoice[:invoice].payment_gateway_object.gateway_object_id
json.type invoice[:invoice].payment_gateway_object.gateway_object_type
end
end
json.total number_to_currency(invoice[:invoice].total / 100.0)
json.invoiced do
json.type invoice[:invoice].invoiced_type
@ -25,7 +31,13 @@ json.invoices do
end
end
json.invoice_items invoice[:invoice].invoice_items do |item|
json.extract! item, :id, :stp_invoice_item_id, :created_at, :description, :footprint
json.extract! item, :id, :created_at, :description, :footprint
if item.payment_gateway_object
json.payment_gateway_object do
json.id item.payment_gateway_object.gateway_object_id
json.type item.payment_gateway_object.gateway_object_type
end
end
json.partial! 'archive/vat', price: item.amount, vat_rate: invoice[:vat_rate]
end
end

View File

@ -1,6 +1,12 @@
# frozen_string_literal: true
json.extract! invoiced, :stp_subscription_id, :created_at, :expiration_date, :canceled_at
json.extract! invoiced, :created_at, :expiration_date, :canceled_at
if invoiced.payment_gateway_object
json.payment_gateway_object do
json.id invoiced.payment_gateway_object.gateway_object_id
json.type invoiced.payment_gateway_object.gateway_object_type
end
end
json.plan do
json.extract! invoiced.plan, :id, :base_name, :interval, :interval_count, :stp_plan_id, :is_rolling
json.group do

View File

@ -1,7 +1,9 @@
# frozen_string_literal: true
wb = xlsx_package.workbook
header = wb.styles.add_style :b => true, :bg_color => Stylesheet.primary.upcase.gsub('#', 'FF'), :fg_color => 'FFFFFFFF'
date = wb.styles.add_style :format_code => Rails.application.secrets.excel_date_format
header = wb.styles.add_style b: true, bg_color: Stylesheet.primary.upcase.gsub('#', 'FF'), fg_color: 'FFFFFFFF'
date = wb.styles.add_style format_code: Rails.application.secrets.excel_date_format
wb.add_worksheet(name: t('export_subscriptions.subscriptions')) do |sheet|
@ -9,25 +11,24 @@ wb.add_worksheet(name: t('export_subscriptions.subscriptions')) do |sheet|
# heading labels
columns = [t('export_subscriptions.id'), t('export_subscriptions.customer'), t('export_subscriptions.email'),
t('export_subscriptions.subscription'), t('export_subscriptions.period'), t('export_subscriptions.start_date'),
t('export_subscriptions.expiration_date'), t('export_subscriptions.amount'), t('export_subscriptions.payment_method')]
sheet.add_row columns, :style => header
t('export_subscriptions.expiration_date'), t('export_subscriptions.amount')]
sheet.add_row columns, style: header
# data rows
@subscriptions.each do |sub|
data = [
sub.user&.id,
sub.user&.profile&.full_name || t('export_subscriptions.deleted_user'),
sub.user&.email,
sub.plan.human_readable_name(group: true),
t("duration.#{sub.plan.interval}", count: sub.plan.interval_count),
sub.created_at.to_date,
sub.expired_at.to_date,
number_to_currency(sub.plan.amount / 100.00),
(sub.stp_subscription_id.nil?)? t('export_subscriptions.local_payment') : t('export_subscriptions.online_payment')
sub.user&.id,
sub.user&.profile&.full_name || t('export_subscriptions.deleted_user'),
sub.user&.email,
sub.plan.human_readable_name(group: true),
t("duration.#{sub.plan.interval}", count: sub.plan.interval_count),
sub.created_at.to_date,
sub.expired_at.to_date,
number_to_currency(sub.plan.amount / 100.00)
]
styles = [nil, nil, nil, nil, nil, date, date, nil, nil]
types = [:integer, :string, :string, :string, :string, :date, :date, :string, :string]
types = %i[integer string string string string date date string string]
sheet.add_row data, :style => styles, :types => types
sheet.add_row data, style: styles, types: types
end
end
end

View File

@ -1,5 +1,13 @@
# frozen_string_literal: true
json.invoices @invoices do |invoice|
json.extract! invoice, :id, :invoiced_id, :user_id, :invoiced_type, :stp_invoice_id, :stp_payment_intent_id, :reference, :total, :type, :description
json.extract! invoice, :id, :invoiced_id, :user_id, :invoiced_type, :reference, :total, :type, :description
if invoice.payment_gateway_object
json.payment_gateway_object do
json.id invoice.payment_gateway_object.gateway_object_id
json.type invoice.payment_gateway_object.gateway_object_type
end
end
json.invoice_url download_open_api_v1_invoice_path(invoice)
json.invoiced do

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true
require 'integrity/checksum'
# Will generate a ZIP archive file containing all invoicing data for the given period.
# This file will be asynchronously generated by sidekiq and a notification will be sent to the requesting user when it's done.
class ArchiveWorker
@ -10,11 +12,11 @@ class ArchiveWorker
data = period.invoices.includes(:invoice_items).order(id: :asc)
previous_file = period.previous_period&.archive_file
last_archive_checksum = previous_file ? Checksum.file(previous_file) : nil
last_archive_checksum = previous_file ? Integrity::Checksum.file(previous_file) : nil
json_data = to_json_archive(period, data, previous_file, last_archive_checksum)
current_archive_checksum = Checksum.text(json_data)
current_archive_checksum = Integrity::Checksum.text(json_data)
date = DateTime.iso8601
chained = Checksum.text("#{current_archive_checksum}#{last_archive_checksum}#{date}")
chained = Integrity::Checksum.text("#{current_archive_checksum}#{last_archive_checksum}#{date}")
Zip::OutputStream.open(period.archive_file) do |io|
io.put_next_entry(period.archive_json_file)
@ -33,7 +35,7 @@ class ArchiveWorker
private
def to_json_archive(period, invoices, previous_file, last_checksum)
code_checksum = Checksum.code
code_checksum = Integrity::Checksum.code
ApplicationController.new.view_context.render(
partial: 'archive/accounting',
locals: {

View File

@ -18,15 +18,15 @@ class PaymentScheduleItemWorker
def check_item(psi)
# the following depends on the payment method (stripe/check)
if psi.payment_schedule.payment_method == 'stripe'
if psi.payment_schedule.payment_method == 'card'
### Stripe
stripe_key = Setting.get('stripe_secret_key')
stp_subscription = Stripe::Subscription.retrieve(psi.payment_schedule.stp_subscription_id, api_key: stripe_key)
stp_invoice = Stripe::Invoice.retrieve(stp_subscription.latest_invoice, api_key: stripe_key)
if stp_invoice.status == 'paid'
##### Stripe / Successfully paid
PaymentScheduleService.new.generate_invoice(psi, payment_method: 'stripe', payment_id: stp_invoice.payment_intent)
psi.update_attributes(state: 'paid', payment_method: 'stripe', stp_invoice_id: stp_invoice.id)
PaymentScheduleService.new.generate_invoice(psi, payment_method: 'card', payment_id: stp_invoice.payment_intent, payment_type: 'Stripe::PaymentIntent') # FIXME
psi.update_attributes(state: 'paid', payment_method: 'card', stp_invoice_id: stp_invoice.id)
elsif stp_subscription.status == 'past_due' || stp_invoice.status == 'open'
##### Stripe / Payment error
if psi.state == 'new'

View File

@ -213,7 +213,6 @@ de:
start_date: "Startdatum"
expiration_date: "Ablaufdatum"
amount: "Betrag"
payment_method: "Zahlungsmethode"
local_payment: "Zahlung an der Rezeption"
online_payment: "Online-Zahlung"
deleted_user: "Gelöschter Nutzer"

View File

@ -213,7 +213,6 @@ en:
start_date: "Start date"
expiration_date: "Expiration date"
amount: "Amount"
payment_method: "Payment method"
local_payment: "Payment at the reception"
online_payment: "Online payment"
deleted_user: "Deleted user"

View File

@ -213,7 +213,6 @@ es:
start_date: "Fecha de comienzo"
expiration_date: "Fecha de fin"
amount: "Cantidad"
payment_method: "Método de pago"
local_payment: "Pago en recepción"
online_payment: "Pago en línea"
deleted_user: "Usario eliminado"

View File

@ -213,7 +213,6 @@ fr:
start_date: "Date de début"
expiration_date: "Date d'expiration"
amount: "Montant"
payment_method: "Méthode de paiement"
local_payment: "Paiement à l'accueil"
online_payment: "Paiement en ligne"
deleted_user: "Utilisateur supprimé"

View File

@ -213,7 +213,6 @@ pt:
start_date: "Data de início"
expiration_date: "Data de expiração"
amount: "Montante"
payment_method: "Método de pagamento"
local_payment: "Pagamento na recepção"
online_payment: "Pagamento online"
deleted_user: "Usuário deletado"

View File

@ -213,7 +213,6 @@ zu:
start_date: "crwdns3519:0crwdne3519:0"
expiration_date: "crwdns3521:0crwdne3521:0"
amount: "crwdns3523:0crwdne3523:0"
payment_method: "crwdns3525:0crwdne3525:0"
local_payment: "crwdns3527:0crwdne3527:0"
online_payment: "crwdns3529:0crwdne3529:0"
deleted_user: "crwdns20888:0crwdne20888:0"

View File

@ -22,12 +22,14 @@ class MigrateStripeIdsToPaymentGatewayObjects < ActiveRecord::Migration[5.2]
gateway_object_id: i.stp_invoice_id,
gateway_object_type: 'Stripe::Invoice'
)
i.update(payment_method: 'card')
elsif i.stp_payment_intent_id
PaymentGatewayObject.create!(
item: i,
gateway_object_id: i.stp_payment_intent_id,
gateway_object_type: 'Stripe::PaymentIntent'
)
i.update(payment_method: 'card')
end
end
remove_column :invoices, :stp_invoice_id
@ -38,10 +40,11 @@ class MigrateStripeIdsToPaymentGatewayObjects < ActiveRecord::Migration[5.2]
InvoiceItem.order(:id).all.each do |ii|
next unless ii.stp_invoice_item_id
is_subscription = /^sub_/.match? ii.stp_invoice_item_id
PaymentGatewayObject.create!(
item: ii,
gateway_object_id: ii.stp_invoice_item_id,
gateway_object_type: 'Stripe::InvoiceItem'
gateway_object_type: is_subscription ? 'Stripe::Subscription' : 'Stripe::InvoiceItem'
)
end
remove_column :invoice_items, :stp_invoice_item_id
@ -82,6 +85,7 @@ class MigrateStripeIdsToPaymentGatewayObjects < ActiveRecord::Migration[5.2]
gateway_object_id: ps.stp_setup_intent_id,
gateway_object_type: 'Stripe::SetupIntent'
)
ps.update(payment_method: 'card')
end
remove_column :payment_schedules, :stp_subscription_id
remove_column :payment_schedules, :stp_setup_intent_id
@ -165,7 +169,7 @@ class MigrateStripeIdsToPaymentGatewayObjects < ActiveRecord::Migration[5.2]
when 'Stripe::SetupIntent'
'stp_setup_intent_id'
when 'Stripe::Subscription'
'stp_subscription_id'
pgo.item_type == InvoiceItem.name ? 'stp_invoice_item_id' : 'stp_subscription_id'
when 'Stripe::InvoiceItem'
'stp_invoice_item_id'
when 'Stripe::PaymentIntent'

View File

@ -2,7 +2,6 @@
invoice_item_1:
id: 1
invoice_id: 1
stp_invoice_item_id: sub_8DGB4ErIc2asOv
amount: 10000
created_at: 2012-03-12 11:03:31.651441000 Z
updated_at: 2012-03-12 11:03:31.651441000 Z
@ -14,7 +13,6 @@ invoice_item_1:
invoice_item_2:
id: 2
invoice_id: 2
stp_invoice_item_id:
amount: 2000
created_at: 2012-03-12 13:40:22.342717000 Z
updated_at: 2012-03-12 13:40:22.342717000 Z
@ -27,7 +25,6 @@ invoice_item_2:
invoice_item_3:
id: 3
invoice_id: 3
stp_invoice_item_id:
amount: 3000
created_at: 2015-06-10 11:20:01.341130000 Z
updated_at: 2015-06-10 11:20:01.341130000 Z
@ -39,7 +36,6 @@ invoice_item_3:
invoice_item_4:
id: 4
invoice_id: 4
stp_invoice_item_id:
amount: 0
created_at: 2016-04-05 08:35:52.934725000 Z
updated_at: 2016-04-05 08:35:52.934725000 Z
@ -51,7 +47,6 @@ invoice_item_4:
invoice_item_5:
id: 5
invoice_id: 5
stp_invoice_item_id:
amount: 1500
created_at: 2016-04-05 08:36:46.856021000 Z
updated_at: 2016-04-05 08:36:46.856021000 Z
@ -63,7 +58,6 @@ invoice_item_5:
invoice_item_6:
id: 6
invoice_id: 6
stp_invoice_item_id:
amount: 3000
created_at: 2016-04-05 08:36:46.856021000 Z
updated_at: 2016-04-05 08:36:46.856021000 Z

View File

@ -0,0 +1,11 @@
pgo_1:
item_type: 'InvoiceItem'
item_id: 1
gateway_object_type: 'Stripe::Subscription'
gateway_object_id: 'sub_8DGB4ErIc2asOv'
pgo2:
item_type: 'Subscription'
item_id: 1
gateway_object_type: 'Stripe::Subscription'
gateway_object_id: 'sub_8DGB4ErIc2asOv'

View File

@ -3,7 +3,6 @@ subscription_1:
id: 1
plan_id: 2
statistic_profile_id: 3
stp_subscription_id: sub_8DGB4ErIc2asOv
created_at: <%= 10.days.ago.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
updated_at: <%= 10.days.ago.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
expiration_date: <%= (1.month.from_now - 11.days).utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
@ -13,7 +12,6 @@ subscription_2:
id: 2
plan_id: 3
statistic_profile_id: 4
stp_subscription_id:
created_at: <%= 10.days.ago.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
updated_at: <%= 10.days.ago.utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
expiration_date: <%= (1.month.from_now - 11.days).utc.strftime('%Y-%m-%d %H:%M:%S.%9N Z') %>
@ -24,7 +22,6 @@ subscription_3:
id: 3
plan_id: 1
statistic_profile_id: 7
stp_subscription_id:
created_at: 2012-03-12 11:03:31.651441000 Z
updated_at: 2012-03-12 11:03:31.651441000 Z
expiration_date: 2012-04-12 11:03:31.648274000 Z
@ -35,7 +32,6 @@ subscription_4:
id: 4
plan_id: 1
statistic_profile_id: 8
stp_subscription_id:
created_at: 2018-06-11 14:27:12.427521000 Z
updated_at: 2018-06-11 14:27:12.427521000 Z
expiration_date: 2018-07-11 14:27:12.427521000 Z

View File

@ -514,7 +514,7 @@ class Reservations::CreateAsAdminTest < ActionDispatch::IntegrationTest
assert_not_nil payment_schedule.reference
assert_equal 'check', payment_schedule.payment_method
assert_nil payment_schedule.stp_subscription_id
assert_nil payment_schedule.stp_setup_intent_id
assert_nil payment_schedule.stp_setup_intent_id # FIXME
assert_nil payment_schedule.wallet_transaction
assert_nil payment_schedule.wallet_amount
assert_nil payment_schedule.coupon_id

View File

@ -840,7 +840,7 @@ class Reservations::CreateTest < ActionDispatch::IntegrationTest
assert_not_nil payment_schedule.reference
assert_equal 'stripe', payment_schedule.payment_method
assert_not_nil payment_schedule.stp_subscription_id
assert_not_nil payment_schedule.stp_setup_intent_id
assert_not_nil payment_schedule.stp_setup_intent_id # FIXME
assert_not_nil payment_schedule.wallet_transaction
assert_equal payment_schedule.ordered_items.first.amount, payment_schedule.wallet_amount
assert_equal Coupon.find_by(code: 'GIME3EUR').id, payment_schedule.coupon_id