feat: add stores of report
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 10s

This commit is contained in:
Thanaphon Frappet 2025-03-05 16:07:37 +07:00
parent b892924a18
commit 9aef359291
2 changed files with 112 additions and 0 deletions

View file

@ -0,0 +1,71 @@
import { ref } from 'vue';
import { defineStore } from 'pinia';
import { Pagination, Status } from '../types';
import { api } from 'src/boot/axios';
import { Report, ReportProduct, ReportQuotation, ReportSale } from './types';
const ENDPOINT = 'report';
export async function getReportQuotation() {
const res = await api.get<ReportQuotation[]>(`/${ENDPOINT}/quotation`);
if (res.status < 400) {
res.data;
return res.data;
}
return null;
}
export async function getReportInvoice() {
const res = await api.get<Report[]>(`/${ENDPOINT}/invoice`);
if (res.status < 400) {
return res.data;
}
return null;
}
export async function getReportReceipt() {
const res = await api.get<Report[]>(`/${ENDPOINT}/receipt`);
if (res.status < 400) {
return res.data;
}
return null;
}
export async function getReportSale() {
const res = await api.get<ReportSale>(`/${ENDPOINT}/sale`);
if (res.status < 400) {
return res.data;
}
return null;
}
export async function getReportProduct() {
const res = await api.get<ReportProduct[]>(`/${ENDPOINT}/Product`);
if (res.status < 400) {
return res.data;
}
return null;
}
export const useReportStore = defineStore('report-store', () => {
const dataReportQuotation = ref<ReportQuotation[]>([]);
const dataReportInvoice = ref<Report[]>([]);
const dataReportReceipt = ref<Report[]>([]);
const dataReportSale = ref<ReportSale>();
const dataReportProduct = ref<ReportProduct[]>([]);
return {
dataReportQuotation,
dataReportInvoice,
dataReportReceipt,
dataReportSale,
dataReportProduct,
getReportQuotation,
getReportInvoice,
getReportReceipt,
getReportSale,
getReportProduct,
};
});

View file

@ -0,0 +1,41 @@
import { QuotationStatus } from 'src/stores/quotations/types';
import { ProductGroup } from '../product-service/types';
import { User } from '../user';
import { CustomerBranch } from '../customer';
export type ReportQuotation = {
updatedAt: Date | null;
createdAt: Date | null;
status: QuotationStatus;
code: string;
};
export enum Status {
PaymentInProcess = 'PaymentInProcess',
PaymentSuccess = 'PaymentSuccess',
PaymentWait = 'PaymentWait',
PaymentRetry = 'PaymentRetry',
}
// use with Invoice and Receipt
export type Report = {
createdAt: Date | null;
status: Status;
code: string;
};
export type ReportProduct = {
updatedAt: Date | null;
createdAt: Date | null;
order: number;
did: number;
sale: number;
name: string;
code: string;
};
export type ReportSale = {
byCustomer: (Omit<CustomerBranch, '_count'> & { _count: number })[];
bySale: (User & { _count: number })[];
byProductGroup: (Omit<ProductGroup, '_count'> & { _count: number })[];
};