mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
use explicit payment method for check in paymentSchedules and do not include the payment method in the footprint
This commit is contained in:
parent
a91610f530
commit
a38d3e31b1
@ -7,7 +7,12 @@ import { FabModal } from '../base/fab-modal';
|
||||
import { UpdateCardModal } from '../payment/update-card-modal';
|
||||
import { StripeElements } from '../payment/stripe/stripe-elements';
|
||||
import { User, UserRole } from '../../models/user';
|
||||
import { PaymentSchedule, PaymentScheduleItem, PaymentScheduleItemState } from '../../models/payment-schedule';
|
||||
import {
|
||||
PaymentMethod,
|
||||
PaymentSchedule,
|
||||
PaymentScheduleItem,
|
||||
PaymentScheduleItemState
|
||||
} from '../../models/payment-schedule';
|
||||
import PaymentScheduleAPI from '../../api/payment-schedule';
|
||||
import FormatLib from '../../lib/format';
|
||||
import { StripeConfirmModal } from '../payment/stripe/stripe-confirm-modal';
|
||||
@ -157,7 +162,7 @@ const PaymentSchedulesTableComponent: React.FC<PaymentSchedulesTableProps> = ({
|
||||
return downloadButton(TargetType.Invoice, item.invoice_id);
|
||||
case PaymentScheduleItemState.Pending:
|
||||
if (isPrivileged()) {
|
||||
if (schedule.payment_method === 'transfer') {
|
||||
if (schedule.payment_method === PaymentMethod.Transfer) {
|
||||
return (
|
||||
<FabButton onClick={handleConfirmTransferPayment(item)}
|
||||
icon={<i className="fas fa-university"/>}>
|
||||
@ -199,7 +204,7 @@ const PaymentSchedulesTableComponent: React.FC<PaymentSchedulesTableProps> = ({
|
||||
}
|
||||
return cancelSubscriptionButton(schedule);
|
||||
case PaymentScheduleItemState.New:
|
||||
if (!cardUpdateButton.get(schedule.id) && schedule.payment_method === 'card') {
|
||||
if (!cardUpdateButton.get(schedule.id) && schedule.payment_method === PaymentMethod.Card) {
|
||||
cardUpdateButton.set(schedule.id, true);
|
||||
return (
|
||||
<span>
|
||||
|
@ -9,9 +9,11 @@ export enum PaymentScheduleItemState {
|
||||
}
|
||||
|
||||
export enum PaymentMethod {
|
||||
Stripe = 'stripe',
|
||||
Card = 'card',
|
||||
Transfer = 'transfer',
|
||||
Check = 'check'
|
||||
}
|
||||
|
||||
export interface PaymentScheduleItem {
|
||||
id: number,
|
||||
amount: number,
|
||||
@ -27,7 +29,7 @@ export interface PaymentSchedule {
|
||||
id: number,
|
||||
total: number,
|
||||
reference: string,
|
||||
payment_method: 'card' | 'transfer' | '',
|
||||
payment_method: PaymentMethod,
|
||||
items: Array<PaymentScheduleItem>,
|
||||
created_at: Date,
|
||||
chained_footprint: boolean,
|
||||
|
@ -75,6 +75,10 @@ class PaymentSchedule < PaymentDocument
|
||||
payment_schedule_items
|
||||
end
|
||||
|
||||
def self.columns_out_of_footprint
|
||||
%w[payment_method]
|
||||
end
|
||||
|
||||
def post_save(*args)
|
||||
return unless payment_method == 'card'
|
||||
|
||||
|
@ -13,7 +13,7 @@ class UpdatePgTrgm < ActiveRecord::Migration[5.2]
|
||||
end
|
||||
|
||||
def down
|
||||
# we cannot downgrade a postgresSQL extension, so we do notinf
|
||||
# we cannot downgrade a postgresSQL extension, so we do nothing
|
||||
execute <<~SQL
|
||||
ALTER EXTENSION pg_trgm UPDATE;
|
||||
SQL
|
||||
|
@ -0,0 +1,45 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'integrity/archive_helper'
|
||||
|
||||
# From this migration, blank payment methods for payment schedules will be removed and replaced by 'check'
|
||||
class MigratePaymentSchedulePaymentMethodCheck < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
# first, check the footprints
|
||||
Integrity::ArchiveHelper.check_footprints
|
||||
|
||||
# if everything is ok, proceed with migration
|
||||
# remove and save periods in memory
|
||||
periods = Integrity::ArchiveHelper.backup_and_remove_periods
|
||||
|
||||
# migrate the payment schedules
|
||||
PaymentSchedule.where(payment_method: '').order(:id).find_each do |ps|
|
||||
ps.update(payment_method: 'check')
|
||||
end
|
||||
|
||||
# chain all records
|
||||
puts 'Chaining all record. This may take a while...'
|
||||
PaymentSchedule.order(:id).find_each(&:chain_record)
|
||||
|
||||
# re-create all archives from the memory dump
|
||||
Integrity::ArchiveHelper.restore_periods(periods)
|
||||
end
|
||||
|
||||
def down
|
||||
# here we don't check footprints to save processing time and because this is pointless when reverting the migrations
|
||||
|
||||
# remove and save periods in memory
|
||||
periods = Integrity::ArchiveHelper.backup_and_remove_periods
|
||||
|
||||
# migrate the payment schedules
|
||||
PaymentSchedule.where(payment_method: 'check').order(:id).find_each do |ps|
|
||||
ps.update(payment_method: '')
|
||||
end
|
||||
|
||||
# chain all records
|
||||
PaymentSchedule.order(:id).all.each(&:chain_record)
|
||||
|
||||
# re-create all archives from the memory dump
|
||||
Integrity::ArchiveHelper.restore_periods(periods)
|
||||
end
|
||||
end
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_12_20_143400) do
|
||||
ActiveRecord::Schema.define(version: 2022_01_11_134253) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "fuzzystrmatch"
|
||||
|
@ -79,7 +79,7 @@ class PayZen::Service < Payment::Service
|
||||
|
||||
def process_payment_schedule_item(payment_schedule_item)
|
||||
pz_subscription = payment_schedule_item.payment_schedule.gateway_subscription.retrieve
|
||||
if pz_subscription['answer']['cancelDate'] && DateTime.parse(pz_subscription['answer']['cancelDate']) < DateTime.current
|
||||
if pz_subscription['answer']['cancelDate'] && DateTime.parse(pz_subscription['answer']['cancelDate']) <= DateTime.current
|
||||
# the subscription was canceled by the gateway => notify & update the status
|
||||
notify_payment_schedule_gateway_canceled(payment_schedule_item)
|
||||
payment_schedule_item.update_attributes(state: 'gateway_canceled')
|
||||
|
Loading…
Reference in New Issue
Block a user