mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(feat) show payment info in order
This commit is contained in:
parent
0ee45f8404
commit
42f7320e63
@ -65,7 +65,7 @@ export const OrderItem: React.FC<OrderItemProps> = ({ order, currentUser }) => {
|
||||
<p className="date">{FormatLib.date(order.created_at)}</p>
|
||||
<div className='price'>
|
||||
<span>{t('app.shared.store.order_item.total')}</span>
|
||||
<p>{FormatLib.price(order?.total)}</p>
|
||||
<p>{FormatLib.price(order?.paid_total)}</p>
|
||||
</div>
|
||||
<FabButton onClick={() => showOrder(order)} icon={<i className="fas fa-eye" />} className="is-black" />
|
||||
</div>
|
||||
|
@ -100,6 +100,36 @@ export const ShowOrder: React.FC<ShowOrderProps> = ({ orderId, currentUser, onEr
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns order's payment info
|
||||
*/
|
||||
const paymentInfo = (): string => {
|
||||
let paymentVerbose = '';
|
||||
if (order.payment_method === 'card') {
|
||||
paymentVerbose = t('app.shared.store.show_order.payment.settlement_by_debit_card');
|
||||
} else if (order.payment_method === 'wallet') {
|
||||
paymentVerbose = t('app.shared.store.show_order.payment.settlement_by_wallet');
|
||||
} else {
|
||||
paymentVerbose = t('app.shared.store.show_order.payment.settlement_done_at_the_reception');
|
||||
}
|
||||
paymentVerbose += ' ' + t('app.shared.store.show_order.payment.on_DATE_at_TIME', {
|
||||
DATE: FormatLib.date(order.payment_date),
|
||||
TIME: FormatLib.time(order.payment_date)
|
||||
});
|
||||
if (order.payment_method !== 'wallet') {
|
||||
paymentVerbose += ' ' + t('app.shared.store.show_order.payment.for_an_amount_of_AMOUNT', { AMOUNT: FormatLib.price(order.paid_total) });
|
||||
}
|
||||
if (order.wallet_amount) {
|
||||
if (order.payment_method === 'wallet') {
|
||||
paymentVerbose += ' ' + t('app.shared.store.show_order.payment.for_an_amount_of_AMOUNT', { AMOUNT: FormatLib.price(order.wallet_amount) });
|
||||
} else {
|
||||
paymentVerbose += ' ' + t('app.shared.store.show_order.payment.and') + ' ' + t('app.shared.store.show_order.payment.by_wallet') + ' ' +
|
||||
t('app.shared.store.show_order.payment.for_an_amount_of_AMOUNT', { AMOUNT: FormatLib.price(order.wallet_amount) });
|
||||
}
|
||||
}
|
||||
return paymentVerbose;
|
||||
};
|
||||
|
||||
if (!order) {
|
||||
return null;
|
||||
}
|
||||
@ -183,7 +213,7 @@ export const ShowOrder: React.FC<ShowOrderProps> = ({ orderId, currentUser, onEr
|
||||
<div className="subgrid">
|
||||
<div className="payment-info">
|
||||
<label>{t('app.shared.store.show_order.payment_informations')}</label>
|
||||
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum rerum commodi quaerat possimus! Odit, harum.</p>
|
||||
{order.invoice_id && <p>{paymentInfo()}</p>}
|
||||
</div>
|
||||
<div className="amount">
|
||||
<label>{t('app.shared.store.show_order.amount')}</label>
|
||||
|
@ -22,6 +22,10 @@ export interface Order {
|
||||
created_at?: TDateISO,
|
||||
updated_at?: TDateISO,
|
||||
invoice_id?: number,
|
||||
payment_method?: string,
|
||||
payment_date?: TDateISO,
|
||||
wallet_amount?: number,
|
||||
paid_total?: number,
|
||||
order_items_attributes: Array<{
|
||||
id: number,
|
||||
orderable_type: string,
|
||||
|
@ -17,7 +17,7 @@ class Orders::OrderService
|
||||
orders = orders.where(statistic_profile_id: current_user.statistic_profile.id)
|
||||
end
|
||||
orders = orders.where.not(state: 'cart') if current_user.member?
|
||||
orders = orders.order(created_at: filters[:page].present? ? filters[:sort] : 'DESC')
|
||||
orders = orders.order(updated_at: filters[:page].present? ? filters[:sort] : 'DESC')
|
||||
orders = orders.page(filters[:page]).per(ORDERS_PER_PAGE) if filters[:page].present?
|
||||
{
|
||||
data: orders,
|
||||
|
@ -3,6 +3,9 @@
|
||||
json.extract! order, :id, :token, :statistic_profile_id, :operator_profile_id, :reference, :state, :created_at, :updated_at, :invoice_id,
|
||||
:payment_method
|
||||
json.total order.total / 100.0 if order.total.present?
|
||||
json.payment_date order.invoice.created_at if order.invoice_id.present?
|
||||
json.wallet_amount order.wallet_amount / 100.0 if order.wallet_amount.present?
|
||||
json.paid_total order.paid_total / 100.0 if order.paid_total.present?
|
||||
if order.coupon_id
|
||||
json.coupon do
|
||||
json.extract! order.coupon, :id, :code, :type, :percent_off, :validity_per_user
|
||||
|
@ -7,6 +7,7 @@ json.total_count @result[:total_count]
|
||||
json.data @result[:data] do |order|
|
||||
json.extract! order, :id, :statistic_profile_id, :reference, :state, :created_at
|
||||
json.total order.total / 100.0 if order.total.present?
|
||||
json.paid_total order.paid_total / 100.0 if order.paid_total.present?
|
||||
if order&.statistic_profile&.user
|
||||
json.user do
|
||||
json.id order.statistic_profile.user.id
|
||||
|
@ -595,3 +595,11 @@ en:
|
||||
ready: "Ready"
|
||||
collected: "Collected"
|
||||
refunded: "Refunded"
|
||||
payment:
|
||||
by_wallet: "by wallet"
|
||||
settlement_by_debit_card: "Settlement by debit card"
|
||||
settlement_done_at_the_reception: "Settlement done at the reception"
|
||||
settlement_by_wallet: "Settlement by wallet"
|
||||
on_DATE_at_TIME: "on {DATE} at {TIME},"
|
||||
for_an_amount_of_AMOUNT: "for an amount of {AMOUNT}"
|
||||
and: 'and'
|
||||
|
Loading…
x
Reference in New Issue
Block a user