Skip to content

Commit

Permalink
Merge branch 'dev' for release 6.3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
gnepud committed Feb 12, 2024
2 parents f5d8278 + d897d05 commit 154aa97
Show file tree
Hide file tree
Showing 27 changed files with 1,604 additions and 1,525 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Next release

## v6.3.12 2024 February 12

- improvement: Allow the admin to update payment method only the overdue subscription item without cancel PayZen subscription
- improvement: add payment transfer/check to accounting settings
- updates translations

## v6.3.11 2024 February 2

- Fix a bug: if there is a reservation with a deleted user, it is not possible to delete the event
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/api/payment_schedules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ def cancel
def update
authorize PaymentSchedule

if PaymentScheduleService.new.update_payment_mean(@payment_schedule, update_params)
payment_schedule_item = PaymentScheduleItem.find(update_params[:payment_schedule_item_id])
if PaymentScheduleService.new.update_payment_mean(payment_schedule_item, update_params[:payment_method])
render :show, status: :ok, location: @payment_schedule
else
render json: @payment_schedule.errors, status: :unprocessable_entity
render json: payment_schedule_item.errors, status: :unprocessable_entity
end
end

Expand All @@ -107,6 +108,6 @@ def set_payment_schedule_item
end

def update_params
params.require(:payment_schedule).permit(:payment_method)
params.permit(:payment_method, :payment_schedule_item_id)
end
end
2 changes: 2 additions & 0 deletions app/controllers/open_api/v1/accounting_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def index
@codes = {
card: Setting.get('accounting_payment_card_code'),
wallet: Setting.get('accounting_payment_wallet_code'),
transfer: Setting.get('accounting_payment_transfer_code'),
check: Setting.get('accounting_payment_check_code'),
other: Setting.get('accounting_payment_other_code')
}

Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/javascript/api/payment-schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default class PaymentScheduleAPI {
return res?.data;
}

static async update (paymentSchedule: PaymentSchedule): Promise<PaymentSchedule> {
const res:AxiosResponse<PaymentSchedule> = await apiClient.patch(`/api/payment_schedules/${paymentSchedule.id}`, paymentSchedule);
static async update (paymentScheduleId: number, paymentScheduleItemId: number, paymentMethod: string): Promise<PaymentSchedule> {
const res:AxiosResponse<PaymentSchedule> = await apiClient.patch(`/api/payment_schedules/${paymentScheduleId}`, { payment_method: paymentMethod, payment_schedule_item_id: paymentScheduleItemId });
return res?.data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ export const AccountingCodesSettings: React.FC<AccountingCodesSettingsProps> = (
<FormInput register={register} id="accounting_payment_wallet_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_payment_wallet_label" label={t('app.admin.accounting_codes_settings.label')} />
</div>
<h5>{t('app.admin.accounting_codes_settings.transfer')}</h5>
<div className="others">
<FormInput register={register} id="accounting_payment_transfer_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_payment_transfer_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_payment_transfer_label" label={t('app.admin.accounting_codes_settings.label')} />
</div>
<h5>{t('app.admin.accounting_codes_settings.check')}</h5>
<div className="others">
<FormInput register={register} id="accounting_payment_check_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
<FormInput register={register} id="accounting_payment_check_code" label={t('app.admin.accounting_codes_settings.code')} />
<FormInput register={register} id="accounting_payment_check_label" label={t('app.admin.accounting_codes_settings.label')} />
</div>
<h5>{t('app.admin.accounting_codes_settings.other')}</h5>
<div className="others">
<FormInput register={register} id="accounting_payment_other_journal_code" label={t('app.admin.accounting_codes_settings.journal_code')} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ export const PaymentScheduleItemActions: React.FC<PaymentScheduleItemActionsProp
*/
const pendingActions = (): ReactElement => {
if (isPrivileged()) {
if (paymentSchedule.payment_method === PaymentMethod.Transfer) {
if (paymentSchedule.payment_method === PaymentMethod.Transfer || paymentScheduleItem.payment_method === PaymentMethod.Transfer) {
return confirmTransferButton();
}
if (paymentSchedule.payment_method === PaymentMethod.Check) {
if (paymentSchedule.payment_method === PaymentMethod.Check || paymentScheduleItem.payment_method === PaymentMethod.Check) {
return confirmCheckButton();
}
} else {
Expand Down Expand Up @@ -202,7 +202,7 @@ export const PaymentScheduleItemActions: React.FC<PaymentScheduleItemActionsProp
*/
const newActions = (): Array<ReactElement> => {
const buttons = [];
if (paymentSchedule.payment_method === PaymentMethod.Card) {
if (paymentSchedule.payment_method === PaymentMethod.Card && !paymentScheduleItem.payment_method) {
buttons.push(updateCardButton());
}
if (isPrivileged()) {
Expand Down Expand Up @@ -400,7 +400,9 @@ export const PaymentScheduleItemActions: React.FC<PaymentScheduleItemActionsProp
toggleModal={toggleUpdatePaymentMeanModal}
onError={onError}
afterSuccess={onPaymentMeanUpdateSuccess}
paymentSchedule={paymentSchedule} />
paymentSchedule={paymentSchedule}
paymentScheduleItemId={paymentScheduleItem.id}
/>
</div>
</span>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ const PaymentSchedulesTable: React.FC<PaymentSchedulesTableProps> = ({ paymentSc
* Return the human-readable string for the status of the provided deadline.
*/
const formatState = (item: PaymentScheduleItem, schedule: PaymentSchedule): JSX.Element => {
let res = t(`app.shared.payment_schedules_table.state_${item.state}${item.state === 'pending' ? '_' + schedule.payment_method : ''}`);
const paymentMethod = item.payment_method || schedule.payment_method;
let res = t(`app.shared.payment_schedules_table.state_${item.state}${item.state === 'pending' ? '_' + paymentMethod : ''}`);
if (item.state === 'paid') {
const key = `app.shared.payment_schedules_table.method_${item.payment_method}`;
res += ` (${t(key)})`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ interface UpdatePaymentMeanModalProps {
onError: (message: string) => void,
afterSuccess: () => void,
paymentSchedule: PaymentSchedule
paymentScheduleItemId: number,
}

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

const [paymentMean, setPaymentMean] = React.useState<PaymentMethod>();
Expand All @@ -42,10 +43,11 @@ export const UpdatePaymentMeanModal: React.FC<UpdatePaymentMeanModalProps> = ({
* When the user clicks on the update button, update the default payment mean for the given payment schedule
*/
const handlePaymentMeanUpdate = (): void => {
PaymentScheduleAPI.update({
id: paymentSchedule.id,
payment_method: paymentMean
}).then(() => {
PaymentScheduleAPI.update(
paymentSchedule.id,
paymentScheduleItemId,
paymentMean
).then(() => {
afterSuccess();
}).catch(error => {
onError(error.message);
Expand Down
6 changes: 6 additions & 0 deletions app/frontend/src/javascript/models/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export const accountingSettings = [
'accounting_payment_other_code',
'accounting_payment_other_label',
'accounting_payment_other_journal_code',
'accounting_payment_transfer_code',
'accounting_payment_transfer_label',
'accounting_payment_transfer_journal_code',
'accounting_payment_check_code',
'accounting_payment_check_label',
'accounting_payment_check_journal_code',
'accounting_wallet_code',
'accounting_wallet_label',
'accounting_wallet_journal_code',
Expand Down
6 changes: 6 additions & 0 deletions app/helpers/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ module SettingsHelper
accounting_payment_other_code
accounting_payment_other_label
accounting_payment_other_journal_code
accounting_payment_transfer_code
accounting_payment_transfer_label
accounting_payment_transfer_journal_code
accounting_payment_check_code
accounting_payment_check_label
accounting_payment_check_journal_code
accounting_wallet_code
accounting_wallet_label
accounting_wallet_journal_code
Expand Down
4 changes: 4 additions & 0 deletions app/models/accounting_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def invoice_payment_method
# else
if invoice.paid_by_card?
'card'
elsif invoice.paid_by_transfer?
'transfer'
elsif invoice.paid_by_check?
'check'
else
'other'
end
Expand Down
12 changes: 12 additions & 0 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def payment_means
res.push(means: :card, amount: amount_paid)
elsif paid_by_wallet?
res.push(means: :wallet, amount: amount_paid)
elsif paid_by_transfer?
res.push(means: :transfer, amount: amount_paid)
elsif paid_by_check?
res.push(means: :check, amount: amount_paid)
else
res.push(means: :other, amount: amount_paid)
end
Expand Down Expand Up @@ -202,6 +206,14 @@ def paid_by_wallet?
(wallet_transaction && wallet_amount.positive?) || payment_method == 'wallet'
end

def paid_by_transfer?
payment_method == 'transfer'
end

def paid_by_check?
payment_method == 'check'
end

def render_resource
{ partial: 'api/invoices/invoice', locals: { invoice: self } }
end
Expand Down
5 changes: 2 additions & 3 deletions app/services/payment_schedule_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ def self.cancel(payment_schedule)
##
# Update the payment mean associated with the given PaymentSchedule and reset the erroneous items
##
def update_payment_mean(payment_schedule, payment_mean)
PaymentGatewayService.new.cancel_subscription(payment_schedule)
payment_schedule.update(payment_mean) && reset_erroneous_payment_schedule_items(payment_schedule)
def update_payment_mean(payment_schedule_item, payment_method)
payment_schedule_item.update(payment_method: payment_method, state: payment_schedule_item.due_date < Time.current ? 'pending' : 'new')
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/workers/payment_schedule_item_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def perform(record_id = nil)
# @param psi [PaymentScheduleItem]
def check_item(psi)
# the following depends on the payment method (card/check)
if psi.payment_schedule.payment_method == 'card'
if psi.payment_schedule.payment_method == 'card' && psi.payment_method.nil?
### Cards
PaymentGatewayService.new.process_payment_schedule_item(psi)
elsif psi.state == 'new'
### Check/Bank transfer (only new deadlines, to prevent spamming)
NotificationCenter.call type: "notify_admin_payment_schedule_#{psi.payment_schedule.payment_method}_deadline",
NotificationCenter.call type: "notify_admin_payment_schedule_#{psi.payment_method || psi.payment_schedule.payment_method}_deadline",
receiver: User.admins_and_managers,
attached_object: psi
psi.update(state: 'pending')
Expand Down
4 changes: 3 additions & 1 deletion config/locales/app.admin.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ de:
card: "Card payments"
wallet_debit: "Virtual wallet payments"
other: "Other payment means"
transfer: "Transfer"
check: "Check"
wallet_credit: "Virtual wallet credit"
VAT: "VAT"
sales: "Sales"
Expand Down Expand Up @@ -1147,7 +1149,7 @@ de:
date: "Datum"
update_payment_mean_modal:
title: "Zahlungsmittel aktualisieren"
update_info: "Bitte geben Sie unten das neue Zahlungsmittel an, damit der Zahlungszeitplan fortgesetzt werden kann."
update_info: "Please specify below the payment method to update this payment schedule."
select_payment_mean: "Neues Zahlungsmittel auswählen"
method_Transfer: "Per Banküberweisung"
method_Check: "Per Scheck"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/app.admin.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ en:
card: "Card payments"
wallet_debit: "Virtual wallet payments"
other: "Other payment means"
transfer: "Transfer"
check: "Check"
wallet_credit: "Virtual wallet credit"
VAT: "VAT"
sales: "Sales"
Expand Down Expand Up @@ -1147,7 +1149,7 @@ en:
date: "Date"
update_payment_mean_modal:
title: "Update the payment mean"
update_info: "Please specify below the new payment mean for this payment schedule to continue."
update_info: "Please specify below the payment method to update this payment schedule."
select_payment_mean: "Select a new payment mean"
method_Transfer: "By bank transfer"
method_Check: "By check"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/app.admin.es-MX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ es-MX:
card: "Pagos con tarjeta"
wallet_debit: "Pagos con cartera virtual"
other: "Otros medios de pago"
transfer: "Transfer"
check: "Check"
wallet_credit: "Crédito de cartera virtual"
VAT: "IVA"
sales: "Ventas"
Expand Down Expand Up @@ -1147,7 +1149,7 @@ es-MX:
date: "Fecha"
update_payment_mean_modal:
title: "Actualizar el medio de pago"
update_info: "Por favor, especifique a continuación el nuevo medio de pago para que este calendario de pagos continúe."
update_info: "Please specify below the payment method to update this payment schedule."
select_payment_mean: "Seleccione un nuevo medio de pago"
method_Transfer: "Por transferencia bancaria"
method_Check: "Por cheque"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/app.admin.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ es:
card: "Pagos con tarjeta"
wallet_debit: "Pagos con cartera virtual"
other: "Otros medios de pago"
transfer: "Transfer"
check: "Check"
wallet_credit: "Crédito de cartera virtual"
VAT: "IVA"
sales: "Ventas"
Expand Down Expand Up @@ -1147,7 +1149,7 @@ es:
date: "Fecha"
update_payment_mean_modal:
title: "Actualizar el medio de pago"
update_info: "Por favor, especifique a continuación el nuevo medio de pago para que este calendario de pagos continúe."
update_info: "Please specify below the payment method to update this payment schedule."
select_payment_mean: "Seleccione un nuevo medio de pago"
method_Transfer: "Por transferencia bancaria"
method_Check: "Por cheque"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/app.admin.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ fr:
card: "Paiements par carte"
wallet_debit: "Paiements par porte-monnaie virtuel"
other: "Autres moyens de paiement"
transfer: "Paiements par virement"
check: "Paiements par chèque"
wallet_credit: "Crédit du porte-monnaie virtuel"
VAT: "TVA"
sales: "Ventes"
Expand Down Expand Up @@ -1147,7 +1149,7 @@ fr:
date: "Date"
update_payment_mean_modal:
title: "Mettre à jour le moyen de paiement"
update_info: "Veuillez indiquer ci-dessous le nouveau moyen de paiement pour que cet échéancier de paiement puisse continuer."
update_info: "Veuillez indiquer ci-dessous le moyen de paiement pour mettre à jour cette échéance."
select_payment_mean: "Sélectionner un nouveau moyen de paiement"
method_Transfer: "Par virement bancaire"
method_Check: "Par chèques"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/app.admin.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ it:
card: "Pagamenti con carta"
wallet_debit: "Pagamenti del portafoglio virtuale"
other: "Altri mezzi di pagamento"
transfer: "Transfer"
check: "Check"
wallet_credit: "Credito portafoglio virtuale"
VAT: "IVA"
sales: "Vendite"
Expand Down Expand Up @@ -1147,7 +1149,7 @@ it:
date: "Data"
update_payment_mean_modal:
title: "Aggiorna il metodo di pagamento"
update_info: "Si prega di specificare di seguito il nuovo mezzo di pagamento per questo programma di pagamenti per continuare."
update_info: "Please specify below the payment method to update this payment schedule."
select_payment_mean: "Selezionare un nuovo metodo di pagamento"
method_Transfer: "Con bonifico bancario"
method_Check: "Con assegno"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/app.admin.no.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@
card: "Card payments"
wallet_debit: "Virtual wallet payments"
other: "Other payment means"
transfer: "Transfer"
check: "Check"
wallet_credit: "Virtual wallet credit"
VAT: "VAT"
sales: "Sales"
Expand Down Expand Up @@ -1147,7 +1149,7 @@
date: "Dato"
update_payment_mean_modal:
title: "Update the payment mean"
update_info: "Please specify below the new payment mean for this payment schedule to continue."
update_info: "Please specify below the payment method to update this payment schedule."
select_payment_mean: "Select a new payment mean"
method_Transfer: "By bank transfer"
method_Check: "By check"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/app.admin.pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ pt:
card: "Card payments"
wallet_debit: "Virtual wallet payments"
other: "Other payment means"
transfer: "Transfer"
check: "Check"
wallet_credit: "Virtual wallet credit"
VAT: "VAT"
sales: "Sales"
Expand Down Expand Up @@ -1147,7 +1149,7 @@ pt:
date: "Data"
update_payment_mean_modal:
title: "Atualizar o método de pagamento"
update_info: "Por favor especifique abaixo o novo método de pagamento para este calendário de pagamentos continuar."
update_info: "Please specify below the payment method to update this payment schedule."
select_payment_mean: "Selecione um novo método de pagamento"
method_Transfer: "Por transferência bancária"
method_Check: "Por cheque"
Expand Down
Loading

0 comments on commit 154aa97

Please sign in to comment.