mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
Merge branch 'monthly-payment' into staging
This commit is contained in:
commit
3bd8803346
@ -18,7 +18,7 @@ import stripeLogo from '../../../images/powered_by_stripe.png';
|
|||||||
import mastercardLogo from '../../../images/mastercard.png';
|
import mastercardLogo from '../../../images/mastercard.png';
|
||||||
import visaLogo from '../../../images/visa.png';
|
import visaLogo from '../../../images/visa.png';
|
||||||
import { StripeCardUpdate } from './stripe-card-update';
|
import { StripeCardUpdate } from './stripe-card-update';
|
||||||
import { User } from '../models/user';
|
import { User, UserRole } from '../models/user';
|
||||||
|
|
||||||
declare var Fablab: IFablab;
|
declare var Fablab: IFablab;
|
||||||
|
|
||||||
@ -131,6 +131,13 @@ const PaymentSchedulesTableComponent: React.FC<PaymentSchedulesTableProps> = ({
|
|||||||
return <span className={`state-${item.state}`}>{res}</span>;
|
return <span className={`state-${item.state}`}>{res}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current operator has administrative rights or is a normal member
|
||||||
|
*/
|
||||||
|
const isPrivileged = (): boolean => {
|
||||||
|
return (operator.role === UserRole.Admin || operator.role == UserRole.Manager);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the action button(s) for the given deadline
|
* Return the action button(s) for the given deadline
|
||||||
*/
|
*/
|
||||||
@ -139,12 +146,16 @@ const PaymentSchedulesTableComponent: React.FC<PaymentSchedulesTableProps> = ({
|
|||||||
case PaymentScheduleItemState.Paid:
|
case PaymentScheduleItemState.Paid:
|
||||||
return downloadButton(TargetType.Invoice, item.invoice_id);
|
return downloadButton(TargetType.Invoice, item.invoice_id);
|
||||||
case PaymentScheduleItemState.Pending:
|
case PaymentScheduleItemState.Pending:
|
||||||
|
if (isPrivileged()) {
|
||||||
return (
|
return (
|
||||||
<FabButton onClick={handleConfirmCheckPayment(item)}
|
<FabButton onClick={handleConfirmCheckPayment(item)}
|
||||||
icon={<i className="fas fa-money-check" />}>
|
icon={<i className="fas fa-money-check" />}>
|
||||||
{t('app.admin.invoices.schedules_table.confirm_payment')}
|
{t('app.admin.invoices.schedules_table.confirm_payment')}
|
||||||
</FabButton>
|
</FabButton>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return <span>{t('app.admin.invoices.schedules_table.please_ask_reception')}</span>
|
||||||
|
}
|
||||||
case PaymentScheduleItemState.RequireAction:
|
case PaymentScheduleItemState.RequireAction:
|
||||||
return (
|
return (
|
||||||
<FabButton onClick={handleSolveAction(item)}
|
<FabButton onClick={handleSolveAction(item)}
|
||||||
@ -160,12 +171,16 @@ const PaymentSchedulesTableComponent: React.FC<PaymentSchedulesTableProps> = ({
|
|||||||
</FabButton>
|
</FabButton>
|
||||||
);
|
);
|
||||||
case PaymentScheduleItemState.Error:
|
case PaymentScheduleItemState.Error:
|
||||||
|
if (isPrivileged()) {
|
||||||
return (
|
return (
|
||||||
<FabButton onClick={handleCancelSubscription(schedule)}
|
<FabButton onClick={handleCancelSubscription(schedule)}
|
||||||
icon={<i className="fas fa-times" />}>
|
icon={<i className="fas fa-times" />}>
|
||||||
{t('app.admin.invoices.schedules_table.cancel_subscription')}
|
{t('app.admin.invoices.schedules_table.cancel_subscription')}
|
||||||
</FabButton>
|
</FabButton>
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
return <span>{t('app.admin.invoices.schedules_table.please_ask_reception')}</span>
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return <span />
|
return <span />
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,6 @@ class Subscription < ApplicationRecord
|
|||||||
generate_invoice(operator_profile_id).save
|
generate_invoice(operator_profile_id).save
|
||||||
end
|
end
|
||||||
|
|
||||||
def cancel
|
|
||||||
update_columns(canceled_at: DateTime.current)
|
|
||||||
end
|
|
||||||
|
|
||||||
def expire(time)
|
def expire(time)
|
||||||
if !expired?
|
if !expired?
|
||||||
update_columns(expiration_date: time, canceled_at: time)
|
update_columns(expiration_date: time, canceled_at: time)
|
||||||
|
@ -147,7 +147,7 @@ class PaymentScheduleService
|
|||||||
end
|
end
|
||||||
# cancel subscription
|
# cancel subscription
|
||||||
subscription = Subscription.find(payment_schedule.payment_schedule_items.first.details['subscription_id'])
|
subscription = Subscription.find(payment_schedule.payment_schedule_items.first.details['subscription_id'])
|
||||||
subscription.cancel
|
subscription.expire(DateTime.current)
|
||||||
|
|
||||||
subscription.canceled_at
|
subscription.canceled_at
|
||||||
end
|
end
|
||||||
|
@ -673,6 +673,7 @@ en:
|
|||||||
validate_button: "Validate the new card"
|
validate_button: "Validate the new card"
|
||||||
cancel_subscription: "Cancel the subscription"
|
cancel_subscription: "Cancel the subscription"
|
||||||
confirm_cancel_subscription: "You're about to cancel this payment schedule and the related subscription. Are you sure?"
|
confirm_cancel_subscription: "You're about to cancel this payment schedule and the related subscription. Are you sure?"
|
||||||
|
please_ask_reception: "For any questions, please contact the FabLab's reception."
|
||||||
document_filters:
|
document_filters:
|
||||||
reference: "Reference"
|
reference: "Reference"
|
||||||
customer: "Customer"
|
customer: "Customer"
|
||||||
|
@ -673,6 +673,7 @@ fr:
|
|||||||
validate_button: "Valider la nouvelle carte"
|
validate_button: "Valider la nouvelle carte"
|
||||||
cancel_subscription: "Annuler l'abonnement"
|
cancel_subscription: "Annuler l'abonnement"
|
||||||
confirm_cancel_subscription: "Vous êtes sur le point d'annuler cet échéancier de paiement ainsi que l'abonnement lié. Êtes-vous sur ?"
|
confirm_cancel_subscription: "Vous êtes sur le point d'annuler cet échéancier de paiement ainsi que l'abonnement lié. Êtes-vous sur ?"
|
||||||
|
please_ask_reception: "Pour toute question, merci de contacter l'accueil du FabLab."
|
||||||
document_filters:
|
document_filters:
|
||||||
reference: "Référence"
|
reference: "Référence"
|
||||||
customer: "Client"
|
customer: "Client"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user