diff --git a/src/stores/payment/index.ts b/src/stores/payment/index.ts index 8dc433d0..d6108c2f 100644 --- a/src/stores/payment/index.ts +++ b/src/stores/payment/index.ts @@ -2,7 +2,7 @@ import { ref } from 'vue'; import { defineStore } from 'pinia'; import { api } from 'src/boot/axios'; import { PaginationResult } from 'src/types'; -import { Invoice, InvoicePayload, Payment } from './types'; +import { Invoice, InvoicePayload, Payment, Receipt } from './types'; export const usePayment = defineStore('payment-store', () => { const data = ref<{}[]>([]); @@ -17,6 +17,7 @@ export const usePayment = defineStore('payment-store', () => { return res.data; } + async function getPaymentList(opts?: { page?: number; pageSize?: number; @@ -32,6 +33,23 @@ export const usePayment = defineStore('payment-store', () => { return res.data; } + async function updatePayment(paymentId: string, payload: Payment) { + const res = await api.put( + `/payment/${paymentId}`, + payload, + ); + if (res.status >= 400) return null; + return res.data; + } + + async function deletePayment(paymentId: string) { + const res = await api.delete( + `/payment/${paymentId}`, + ); + if (res.status >= 400) return null; + return res.data; + } + return { data, page, @@ -40,6 +58,48 @@ export const usePayment = defineStore('payment-store', () => { getPayment, getPaymentList, + updatePayment, + deletePayment, + }; +}); + +export const useReceipt = defineStore('receipt-store', () => { + const data = ref<{}[]>([]); + const page = ref(1); + const pageMax = ref(1); + const pageSize = ref(30); + + async function getReceipt(id: string) { + const res = await api.get(`/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>('/receipt', { + params: opts, + }); + + if (res.status >= 400) return null; + + return res.data; + } + + return { + data, + page, + pageSize, + pageMax, + + getReceipt, + getReceiptList, }; }); diff --git a/src/stores/payment/types.ts b/src/stores/payment/types.ts index eebe3a89..549bb904 100644 --- a/src/stores/payment/types.ts +++ b/src/stores/payment/types.ts @@ -24,4 +24,10 @@ export type InvoicePayload = { installmentNo?: number[]; }; -export type Payment = Invoice; +export type Payment = { + paymentStatus: string; + date: Date; + amount: number; +}; + +export type Receipt = Payment;