feat: update payment stores
This commit is contained in:
parent
71a273f7f0
commit
b6242c199f
2 changed files with 68 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ import { ref } from 'vue';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { api } from 'src/boot/axios';
|
import { api } from 'src/boot/axios';
|
||||||
import { PaginationResult } from 'src/types';
|
import { PaginationResult } from 'src/types';
|
||||||
import { Invoice, InvoicePayload, Payment } from './types';
|
import { Invoice, InvoicePayload, Payment, Receipt } from './types';
|
||||||
|
|
||||||
export const usePayment = defineStore('payment-store', () => {
|
export const usePayment = defineStore('payment-store', () => {
|
||||||
const data = ref<{}[]>([]);
|
const data = ref<{}[]>([]);
|
||||||
|
|
@ -17,6 +17,7 @@ export const usePayment = defineStore('payment-store', () => {
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPaymentList(opts?: {
|
async function getPaymentList(opts?: {
|
||||||
page?: number;
|
page?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
|
|
@ -32,6 +33,23 @@ export const usePayment = defineStore('payment-store', () => {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updatePayment(paymentId: string, payload: Payment) {
|
||||||
|
const res = await api.put<Payment & { id: string }>(
|
||||||
|
`/payment/${paymentId}`,
|
||||||
|
payload,
|
||||||
|
);
|
||||||
|
if (res.status >= 400) return null;
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deletePayment(paymentId: string) {
|
||||||
|
const res = await api.delete<Payment & { id: string }>(
|
||||||
|
`/payment/${paymentId}`,
|
||||||
|
);
|
||||||
|
if (res.status >= 400) return null;
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
page,
|
page,
|
||||||
|
|
@ -40,6 +58,48 @@ export const usePayment = defineStore('payment-store', () => {
|
||||||
|
|
||||||
getPayment,
|
getPayment,
|
||||||
getPaymentList,
|
getPaymentList,
|
||||||
|
updatePayment,
|
||||||
|
deletePayment,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
export const useReceipt = defineStore('receipt-store', () => {
|
||||||
|
const data = ref<{}[]>([]);
|
||||||
|
const page = ref<number>(1);
|
||||||
|
const pageMax = ref<number>(1);
|
||||||
|
const pageSize = ref<number>(30);
|
||||||
|
|
||||||
|
async function getReceipt(id: string) {
|
||||||
|
const res = await api.get<Receipt>(`/receipt/${id}`);
|
||||||
|
|
||||||
|
if (res.status >= 400) return null;
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getReceiptList(opts?: {
|
||||||
|
page?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
query?: string;
|
||||||
|
quotationId?: string;
|
||||||
|
}) {
|
||||||
|
const res = await api.get<PaginationResult<Receipt>>('/receipt', {
|
||||||
|
params: opts,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.status >= 400) return null;
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
pageMax,
|
||||||
|
|
||||||
|
getReceipt,
|
||||||
|
getReceiptList,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,10 @@ export type InvoicePayload = {
|
||||||
installmentNo?: number[];
|
installmentNo?: number[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Payment = Invoice;
|
export type Payment = {
|
||||||
|
paymentStatus: string;
|
||||||
|
date: Date;
|
||||||
|
amount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Receipt = Payment;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue