mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-04-12 02:02:31 +02:00
enlight api for cashing checks
This commit is contained in:
parent
b5cdea513d
commit
58af40b8b9
@ -27,12 +27,12 @@ class API::PaymentSchedulesController < API::ApiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cash_check
|
def cash_check
|
||||||
schedule = @payment_schedule_item.payment_schedule
|
authorize @payment_schedule_item.payment_schedule
|
||||||
authorize schedule
|
|
||||||
PaymentScheduleService.new.generate_invoice(@payment_schedule_item)
|
PaymentScheduleService.new.generate_invoice(@payment_schedule_item)
|
||||||
@payment_schedule_item.update_attributes(state: 'paid', payment_method: 'check')
|
attrs = { state: 'paid', payment_method: 'check' }
|
||||||
|
@payment_schedule_item.update_attributes(attrs)
|
||||||
|
|
||||||
render :show, status: :ok, location: schedule
|
render json: attrs, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import apiClient from './api-client';
|
import apiClient from './api-client';
|
||||||
import { AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
import { PaymentSchedule, PaymentScheduleIndexRequest, PaymentScheduleItem } from '../models/payment-schedule';
|
import {
|
||||||
|
CashCheckResponse,
|
||||||
|
PaymentSchedule,
|
||||||
|
PaymentScheduleIndexRequest,
|
||||||
|
} from '../models/payment-schedule';
|
||||||
import wrapPromise, { IWrapPromise } from '../lib/wrap-promise';
|
import wrapPromise, { IWrapPromise } from '../lib/wrap-promise';
|
||||||
|
|
||||||
export default class PaymentScheduleAPI {
|
export default class PaymentScheduleAPI {
|
||||||
@ -9,7 +13,7 @@ export default class PaymentScheduleAPI {
|
|||||||
return res?.data;
|
return res?.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async cashCheck(paymentScheduleItemId: number) {
|
async cashCheck(paymentScheduleItemId: number): Promise<CashCheckResponse> {
|
||||||
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/items/${paymentScheduleItemId}/cash_check`);
|
const res: AxiosResponse = await apiClient.post(`/api/payment_schedules/items/${paymentScheduleItemId}/cash_check`);
|
||||||
return res?.data;
|
return res?.data;
|
||||||
}
|
}
|
||||||
|
@ -158,9 +158,11 @@ const PaymentSchedulesTableComponent: React.FC<PaymentSchedulesTableProps> = ({
|
|||||||
|
|
||||||
const onCheckCashingConfirmed = (): void => {
|
const onCheckCashingConfirmed = (): void => {
|
||||||
const api = new PaymentScheduleAPI();
|
const api = new PaymentScheduleAPI();
|
||||||
api.cashCheck(tempDeadline.id).then(() => {
|
api.cashCheck(tempDeadline.id).then((res) => {
|
||||||
refreshList();
|
if (res.state === PaymentScheduleItemState.Paid) {
|
||||||
toggleConfirmCashingModal();
|
refreshList();
|
||||||
|
toggleConfirmCashingModal();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,3 +58,8 @@ export interface PaymentScheduleIndexRequest {
|
|||||||
size: number
|
size: number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CashCheckResponse {
|
||||||
|
state: PaymentScheduleItemState,
|
||||||
|
payment_method: PaymentMethod
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user