feat: payment view

This commit is contained in:
Methapon Metanipat 2024-10-28 16:44:14 +07:00
parent 639dc36d71
commit d9f8d0f971
4 changed files with 53 additions and 76 deletions

View file

@ -13,7 +13,6 @@ import {
QuotationStatus,
} from './types';
import { PaginationResult } from 'src/types';
import { AxiosProgressEvent } from 'axios';
import { manageAttachment } from '../utils';
@ -140,9 +139,9 @@ export const useQuotationStore = defineStore('quotation-store', () => {
export const useQuotationPayment = defineStore('quotation-payment', () => {
async function getQuotationPayment(quotationId: string) {
const res = await api.get<
Quotation & { quotationPaymentData: QuotationPaymentData[] }
>(`/quotation/${quotationId}/payment`);
const res = await api.get<PaginationResult<QuotationPaymentData>>(
`/payment/${quotationId}`,
);
if (res.status < 400) {
return res.data;
}
@ -150,12 +149,11 @@ export const useQuotationPayment = defineStore('quotation-payment', () => {
}
async function updateQuotationPayment(
quotationId: string,
paymentId: string,
payload: PaymentPayload,
) {
const res = await api.put<PaymentPayload & { id: string }>(
`/quotation/${quotationId}/payment/${paymentId}`,
`/payment/${paymentId}`,
payload,
);
if (res.status < 400) {
@ -164,16 +162,12 @@ export const useQuotationPayment = defineStore('quotation-payment', () => {
return null;
}
function createPaymentFileManager(
quotationId: string,
opts?: { onUploadProgress: (e: AxiosProgressEvent) => void },
) {
return manageAttachment(api, `quotation/${quotationId}/payment`, opts);
}
const fileManager = manageAttachment(api, `payment`);
return {
getQuotationPayment,
createPaymentFileManager,
updateQuotationPayment,
...fileManager,
};
});

View file

@ -270,6 +270,8 @@ export type QuotationFull = {
id: string;
finalPrice: number;
vat: number;
vatExcluded: number;
discount: number;
totalDiscount: number;
totalPrice: number;
urgent: boolean;
@ -283,6 +285,7 @@ export type QuotationFull = {
contactTel: string;
contactName: string;
workName: string;
workerMax: number | null;
code: string;
statusOrder: number;
status: Status;
@ -297,6 +300,7 @@ export type QuotationFull = {
| 'Canceled';
customerBranchId: string;
customerBranch: CustomerBranchRelation;
registeredBranchId: string;
registeredBranch: { id: string; name: string };
@ -372,7 +376,6 @@ export type ProductGroup = {
};
export type QuotationPaymentData = {
quotationId: string;
paymentStatus: string;
amount: number;
remark: string;
@ -393,7 +396,6 @@ export type Details = {
export type PaymentPayload = {
paymentStatus: string;
remark: string;
date: Date;
amount: number;
};