Skip to content

Commit 154aa97

Browse files
committed
Merge branch 'dev' for release 6.3.12
2 parents f5d8278 + d897d05 commit 154aa97

27 files changed

+1604
-1525
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Next release
44

5+
## v6.3.12 2024 February 12
6+
7+
- improvement: Allow the admin to update payment method only the overdue subscription item without cancel PayZen subscription
8+
- improvement: add payment transfer/check to accounting settings
9+
- updates translations
10+
511
## v6.3.11 2024 February 2
612

713
- Fix a bug: if there is a reservation with a deleted user, it is not possible to delete the event

app/controllers/api/payment_schedules_controller.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ def cancel
8989
def update
9090
authorize PaymentSchedule
9191

92-
if PaymentScheduleService.new.update_payment_mean(@payment_schedule, update_params)
92+
payment_schedule_item = PaymentScheduleItem.find(update_params[:payment_schedule_item_id])
93+
if PaymentScheduleService.new.update_payment_mean(payment_schedule_item, update_params[:payment_method])
9394
render :show, status: :ok, location: @payment_schedule
9495
else
95-
render json: @payment_schedule.errors, status: :unprocessable_entity
96+
render json: payment_schedule_item.errors, status: :unprocessable_entity
9697
end
9798
end
9899

@@ -107,6 +108,6 @@ def set_payment_schedule_item
107108
end
108109

109110
def update_params
110-
params.require(:payment_schedule).permit(:payment_method)
111+
params.permit(:payment_method, :payment_schedule_item_id)
111112
end
112113
end

app/controllers/open_api/v1/accounting_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def index
1313
@codes = {
1414
card: Setting.get('accounting_payment_card_code'),
1515
wallet: Setting.get('accounting_payment_wallet_code'),
16+
transfer: Setting.get('accounting_payment_transfer_code'),
17+
check: Setting.get('accounting_payment_check_code'),
1618
other: Setting.get('accounting_payment_other_code')
1719
}
1820

app/frontend/src/javascript/api/payment-schedule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export default class PaymentScheduleAPI {
4848
return res?.data;
4949
}
5050

51-
static async update (paymentSchedule: PaymentSchedule): Promise<PaymentSchedule> {
52-
const res:AxiosResponse<PaymentSchedule> = await apiClient.patch(`/api/payment_schedules/${paymentSchedule.id}`, paymentSchedule);
51+
static async update (paymentScheduleId: number, paymentScheduleItemId: number, paymentMethod: string): Promise<PaymentSchedule> {
52+
const res:AxiosResponse<PaymentSchedule> = await apiClient.patch(`/api/payment_schedules/${paymentScheduleId}`, { payment_method: paymentMethod, payment_schedule_item_id: paymentScheduleItemId });
5353
return res?.data;
5454
}
5555
}

app/frontend/src/javascript/components/accounting/accounting-codes-settings.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ export const AccountingCodesSettings: React.FC<AccountingCodesSettingsProps> = (
6969
<FormInput register={register} id="accounting_payment_wallet_code" label={t('app.admin.accounting_codes_settings.code')} />
7070
<FormInput register={register} id="accounting_payment_wallet_label" label={t('app.admin.accounting_codes_settings.label')} />
7171
</div>
72+
<h5>{t('app.admin.accounting_codes_settings.transfer')}</h5>
73+
<div className="others">
74+
<FormInput register={register} id="accounting_payment_transfer_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
75+
<FormInput register={register} id="accounting_payment_transfer_code" label={t('app.admin.accounting_codes_settings.code')} />
76+
<FormInput register={register} id="accounting_payment_transfer_label" label={t('app.admin.accounting_codes_settings.label')} />
77+
</div>
78+
<h5>{t('app.admin.accounting_codes_settings.check')}</h5>
79+
<div className="others">
80+
<FormInput register={register} id="accounting_payment_check_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
81+
<FormInput register={register} id="accounting_payment_check_code" label={t('app.admin.accounting_codes_settings.code')} />
82+
<FormInput register={register} id="accounting_payment_check_label" label={t('app.admin.accounting_codes_settings.label')} />
83+
</div>
7284
<h5>{t('app.admin.accounting_codes_settings.other')}</h5>
7385
<div className="others">
7486
<FormInput register={register} id="accounting_payment_other_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />

app/frontend/src/javascript/components/payment-schedule/payment-schedule-item-actions.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ export const PaymentScheduleItemActions: React.FC<PaymentScheduleItemActionsProp
169169
*/
170170
const pendingActions = (): ReactElement => {
171171
if (isPrivileged()) {
172-
if (paymentSchedule.payment_method === PaymentMethod.Transfer) {
172+
if (paymentSchedule.payment_method === PaymentMethod.Transfer || paymentScheduleItem.payment_method === PaymentMethod.Transfer) {
173173
return confirmTransferButton();
174174
}
175-
if (paymentSchedule.payment_method === PaymentMethod.Check) {
175+
if (paymentSchedule.payment_method === PaymentMethod.Check || paymentScheduleItem.payment_method === PaymentMethod.Check) {
176176
return confirmCheckButton();
177177
}
178178
} else {
@@ -202,7 +202,7 @@ export const PaymentScheduleItemActions: React.FC<PaymentScheduleItemActionsProp
202202
*/
203203
const newActions = (): Array<ReactElement> => {
204204
const buttons = [];
205-
if (paymentSchedule.payment_method === PaymentMethod.Card) {
205+
if (paymentSchedule.payment_method === PaymentMethod.Card && !paymentScheduleItem.payment_method) {
206206
buttons.push(updateCardButton());
207207
}
208208
if (isPrivileged()) {
@@ -400,7 +400,9 @@ export const PaymentScheduleItemActions: React.FC<PaymentScheduleItemActionsProp
400400
toggleModal={toggleUpdatePaymentMeanModal}
401401
onError={onError}
402402
afterSuccess={onPaymentMeanUpdateSuccess}
403-
paymentSchedule={paymentSchedule} />
403+
paymentSchedule={paymentSchedule}
404+
paymentScheduleItemId={paymentScheduleItem.id}
405+
/>
404406
</div>
405407
</span>
406408
);

app/frontend/src/javascript/components/payment-schedule/payment-schedules-table.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ const PaymentSchedulesTable: React.FC<PaymentSchedulesTableProps> = ({ paymentSc
104104
* Return the human-readable string for the status of the provided deadline.
105105
*/
106106
const formatState = (item: PaymentScheduleItem, schedule: PaymentSchedule): JSX.Element => {
107-
let res = t(`app.shared.payment_schedules_table.state_${item.state}${item.state === 'pending' ? '_' + schedule.payment_method : ''}`);
107+
const paymentMethod = item.payment_method || schedule.payment_method;
108+
let res = t(`app.shared.payment_schedules_table.state_${item.state}${item.state === 'pending' ? '_' + paymentMethod : ''}`);
108109
if (item.state === 'paid') {
109110
const key = `app.shared.payment_schedules_table.method_${item.payment_method}`;
110111
res += ` (${t(key)})`;

app/frontend/src/javascript/components/payment-schedule/update-payment-mean-modal.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ interface UpdatePaymentMeanModalProps {
1212
onError: (message: string) => void,
1313
afterSuccess: () => void,
1414
paymentSchedule: PaymentSchedule
15+
paymentScheduleItemId: number,
1516
}
1617

1718
/**
1819
* Component to allow the member to change his payment mean for the given payment schedule (e.g. from card to transfer)
1920
*/
20-
export const UpdatePaymentMeanModal: React.FC<UpdatePaymentMeanModalProps> = ({ isOpen, toggleModal, onError, afterSuccess, paymentSchedule }) => {
21+
export const UpdatePaymentMeanModal: React.FC<UpdatePaymentMeanModalProps> = ({ isOpen, toggleModal, onError, afterSuccess, paymentSchedule, paymentScheduleItemId }) => {
2122
const { t } = useTranslation('admin');
2223

2324
const [paymentMean, setPaymentMean] = React.useState<PaymentMethod>();
@@ -42,10 +43,11 @@ export const UpdatePaymentMeanModal: React.FC<UpdatePaymentMeanModalProps> = ({
4243
* When the user clicks on the update button, update the default payment mean for the given payment schedule
4344
*/
4445
const handlePaymentMeanUpdate = (): void => {
45-
PaymentScheduleAPI.update({
46-
id: paymentSchedule.id,
47-
payment_method: paymentMean
48-
}).then(() => {
46+
PaymentScheduleAPI.update(
47+
paymentSchedule.id,
48+
paymentScheduleItemId,
49+
paymentMean
50+
).then(() => {
4951
afterSuccess();
5052
}).catch(error => {
5153
onError(error.message);

app/frontend/src/javascript/models/setting.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ export const accountingSettings = [
113113
'accounting_payment_other_code',
114114
'accounting_payment_other_label',
115115
'accounting_payment_other_journal_code',
116+
'accounting_payment_transfer_code',
117+
'accounting_payment_transfer_label',
118+
'accounting_payment_transfer_journal_code',
119+
'accounting_payment_check_code',
120+
'accounting_payment_check_label',
121+
'accounting_payment_check_journal_code',
116122
'accounting_wallet_code',
117123
'accounting_wallet_label',
118124
'accounting_wallet_journal_code',

app/helpers/settings_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ module SettingsHelper
7474
accounting_payment_other_code
7575
accounting_payment_other_label
7676
accounting_payment_other_journal_code
77+
accounting_payment_transfer_code
78+
accounting_payment_transfer_label
79+
accounting_payment_transfer_journal_code
80+
accounting_payment_check_code
81+
accounting_payment_check_label
82+
accounting_payment_check_journal_code
7783
accounting_wallet_code
7884
accounting_wallet_label
7985
accounting_wallet_journal_code

app/models/accounting_line.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def invoice_payment_method
1313
# else
1414
if invoice.paid_by_card?
1515
'card'
16+
elsif invoice.paid_by_transfer?
17+
'transfer'
18+
elsif invoice.paid_by_check?
19+
'check'
1620
else
1721
'other'
1822
end

app/models/invoice.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ def payment_means
167167
res.push(means: :card, amount: amount_paid)
168168
elsif paid_by_wallet?
169169
res.push(means: :wallet, amount: amount_paid)
170+
elsif paid_by_transfer?
171+
res.push(means: :transfer, amount: amount_paid)
172+
elsif paid_by_check?
173+
res.push(means: :check, amount: amount_paid)
170174
else
171175
res.push(means: :other, amount: amount_paid)
172176
end
@@ -202,6 +206,14 @@ def paid_by_wallet?
202206
(wallet_transaction && wallet_amount.positive?) || payment_method == 'wallet'
203207
end
204208

209+
def paid_by_transfer?
210+
payment_method == 'transfer'
211+
end
212+
213+
def paid_by_check?
214+
payment_method == 'check'
215+
end
216+
205217
def render_resource
206218
{ partial: 'api/invoices/invoice', locals: { invoice: self } }
207219
end

app/services/payment_schedule_service.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@ def self.cancel(payment_schedule)
177177
##
178178
# Update the payment mean associated with the given PaymentSchedule and reset the erroneous items
179179
##
180-
def update_payment_mean(payment_schedule, payment_mean)
181-
PaymentGatewayService.new.cancel_subscription(payment_schedule)
182-
payment_schedule.update(payment_mean) && reset_erroneous_payment_schedule_items(payment_schedule)
180+
def update_payment_mean(payment_schedule_item, payment_method)
181+
payment_schedule_item.update(payment_method: payment_method, state: payment_schedule_item.due_date < Time.current ? 'pending' : 'new')
183182
end
184183

185184
private

app/workers/payment_schedule_item_worker.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def perform(record_id = nil)
1919
# @param psi [PaymentScheduleItem]
2020
def check_item(psi)
2121
# the following depends on the payment method (card/check)
22-
if psi.payment_schedule.payment_method == 'card'
22+
if psi.payment_schedule.payment_method == 'card' && psi.payment_method.nil?
2323
### Cards
2424
PaymentGatewayService.new.process_payment_schedule_item(psi)
2525
elsif psi.state == 'new'
2626
### Check/Bank transfer (only new deadlines, to prevent spamming)
27-
NotificationCenter.call type: "notify_admin_payment_schedule_#{psi.payment_schedule.payment_method}_deadline",
27+
NotificationCenter.call type: "notify_admin_payment_schedule_#{psi.payment_method || psi.payment_schedule.payment_method}_deadline",
2828
receiver: User.admins_and_managers,
2929
attached_object: psi
3030
psi.update(state: 'pending')

config/locales/app.admin.de.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ de:
276276
card: "Card payments"
277277
wallet_debit: "Virtual wallet payments"
278278
other: "Other payment means"
279+
transfer: "Transfer"
280+
check: "Check"
279281
wallet_credit: "Virtual wallet credit"
280282
VAT: "VAT"
281283
sales: "Sales"
@@ -1147,7 +1149,7 @@ de:
11471149
date: "Datum"
11481150
update_payment_mean_modal:
11491151
title: "Zahlungsmittel aktualisieren"
1150-
update_info: "Bitte geben Sie unten das neue Zahlungsmittel an, damit der Zahlungszeitplan fortgesetzt werden kann."
1152+
update_info: "Please specify below the payment method to update this payment schedule."
11511153
select_payment_mean: "Neues Zahlungsmittel auswählen"
11521154
method_Transfer: "Per Banküberweisung"
11531155
method_Check: "Per Scheck"

config/locales/app.admin.en.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ en:
276276
card: "Card payments"
277277
wallet_debit: "Virtual wallet payments"
278278
other: "Other payment means"
279+
transfer: "Transfer"
280+
check: "Check"
279281
wallet_credit: "Virtual wallet credit"
280282
VAT: "VAT"
281283
sales: "Sales"
@@ -1147,7 +1149,7 @@ en:
11471149
date: "Date"
11481150
update_payment_mean_modal:
11491151
title: "Update the payment mean"
1150-
update_info: "Please specify below the new payment mean for this payment schedule to continue."
1152+
update_info: "Please specify below the payment method to update this payment schedule."
11511153
select_payment_mean: "Select a new payment mean"
11521154
method_Transfer: "By bank transfer"
11531155
method_Check: "By check"

config/locales/app.admin.es-MX.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ es-MX:
276276
card: "Pagos con tarjeta"
277277
wallet_debit: "Pagos con cartera virtual"
278278
other: "Otros medios de pago"
279+
transfer: "Transfer"
280+
check: "Check"
279281
wallet_credit: "Crédito de cartera virtual"
280282
VAT: "IVA"
281283
sales: "Ventas"
@@ -1147,7 +1149,7 @@ es-MX:
11471149
date: "Fecha"
11481150
update_payment_mean_modal:
11491151
title: "Actualizar el medio de pago"
1150-
update_info: "Por favor, especifique a continuación el nuevo medio de pago para que este calendario de pagos continúe."
1152+
update_info: "Please specify below the payment method to update this payment schedule."
11511153
select_payment_mean: "Seleccione un nuevo medio de pago"
11521154
method_Transfer: "Por transferencia bancaria"
11531155
method_Check: "Por cheque"

config/locales/app.admin.es.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ es:
276276
card: "Pagos con tarjeta"
277277
wallet_debit: "Pagos con cartera virtual"
278278
other: "Otros medios de pago"
279+
transfer: "Transfer"
280+
check: "Check"
279281
wallet_credit: "Crédito de cartera virtual"
280282
VAT: "IVA"
281283
sales: "Ventas"
@@ -1147,7 +1149,7 @@ es:
11471149
date: "Fecha"
11481150
update_payment_mean_modal:
11491151
title: "Actualizar el medio de pago"
1150-
update_info: "Por favor, especifique a continuación el nuevo medio de pago para que este calendario de pagos continúe."
1152+
update_info: "Please specify below the payment method to update this payment schedule."
11511153
select_payment_mean: "Seleccione un nuevo medio de pago"
11521154
method_Transfer: "Por transferencia bancaria"
11531155
method_Check: "Por cheque"

config/locales/app.admin.fr.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ fr:
276276
card: "Paiements par carte"
277277
wallet_debit: "Paiements par porte-monnaie virtuel"
278278
other: "Autres moyens de paiement"
279+
transfer: "Paiements par virement"
280+
check: "Paiements par chèque"
279281
wallet_credit: "Crédit du porte-monnaie virtuel"
280282
VAT: "TVA"
281283
sales: "Ventes"
@@ -1147,7 +1149,7 @@ fr:
11471149
date: "Date"
11481150
update_payment_mean_modal:
11491151
title: "Mettre à jour le moyen de paiement"
1150-
update_info: "Veuillez indiquer ci-dessous le nouveau moyen de paiement pour que cet échéancier de paiement puisse continuer."
1152+
update_info: "Veuillez indiquer ci-dessous le moyen de paiement pour mettre à jour cette échéance."
11511153
select_payment_mean: "Sélectionner un nouveau moyen de paiement"
11521154
method_Transfer: "Par virement bancaire"
11531155
method_Check: "Par chèques"

config/locales/app.admin.it.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ it:
276276
card: "Pagamenti con carta"
277277
wallet_debit: "Pagamenti del portafoglio virtuale"
278278
other: "Altri mezzi di pagamento"
279+
transfer: "Transfer"
280+
check: "Check"
279281
wallet_credit: "Credito portafoglio virtuale"
280282
VAT: "IVA"
281283
sales: "Vendite"
@@ -1147,7 +1149,7 @@ it:
11471149
date: "Data"
11481150
update_payment_mean_modal:
11491151
title: "Aggiorna il metodo di pagamento"
1150-
update_info: "Si prega di specificare di seguito il nuovo mezzo di pagamento per questo programma di pagamenti per continuare."
1152+
update_info: "Please specify below the payment method to update this payment schedule."
11511153
select_payment_mean: "Selezionare un nuovo metodo di pagamento"
11521154
method_Transfer: "Con bonifico bancario"
11531155
method_Check: "Con assegno"

config/locales/app.admin.no.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@
276276
card: "Card payments"
277277
wallet_debit: "Virtual wallet payments"
278278
other: "Other payment means"
279+
transfer: "Transfer"
280+
check: "Check"
279281
wallet_credit: "Virtual wallet credit"
280282
VAT: "VAT"
281283
sales: "Sales"
@@ -1147,7 +1149,7 @@
11471149
date: "Dato"
11481150
update_payment_mean_modal:
11491151
title: "Update the payment mean"
1150-
update_info: "Please specify below the new payment mean for this payment schedule to continue."
1152+
update_info: "Please specify below the payment method to update this payment schedule."
11511153
select_payment_mean: "Select a new payment mean"
11521154
method_Transfer: "By bank transfer"
11531155
method_Check: "By check"

config/locales/app.admin.pt.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ pt:
276276
card: "Card payments"
277277
wallet_debit: "Virtual wallet payments"
278278
other: "Other payment means"
279+
transfer: "Transfer"
280+
check: "Check"
279281
wallet_credit: "Virtual wallet credit"
280282
VAT: "VAT"
281283
sales: "Sales"
@@ -1147,7 +1149,7 @@ pt:
11471149
date: "Data"
11481150
update_payment_mean_modal:
11491151
title: "Atualizar o método de pagamento"
1150-
update_info: "Por favor especifique abaixo o novo método de pagamento para este calendário de pagamentos continuar."
1152+
update_info: "Please specify below the payment method to update this payment schedule."
11511153
select_payment_mean: "Selecione um novo método de pagamento"
11521154
method_Transfer: "Por transferência bancária"
11531155
method_Check: "Por cheque"

0 commit comments

Comments
 (0)