feat: add tab debt
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s

This commit is contained in:
Thanaphon Frappet 2025-03-10 10:44:46 +07:00
parent d428ac3ec5
commit d6fa8e5b4b
6 changed files with 101 additions and 1 deletions

View file

@ -1360,6 +1360,7 @@ export default {
Product: 'Product and Service Report', Product: 'Product and Service Report',
Sale: 'Sales Summary Report', Sale: 'Sales Summary Report',
Profit: 'Profit and Loss Report', Profit: 'Profit and Loss Report',
Debt: 'Overdue Customer Report',
}, },
document: { document: {
code: 'Code', code: 'Code',
@ -1395,6 +1396,12 @@ export default {
expenses: 'Expenses', expenses: 'Expenses',
income: 'Income', income: 'Income',
}, },
debtReport: {
title: 'Overdue Customer Report',
customerName: 'Customer Name',
unpaid: 'Unpaid',
paid: 'Paid',
},
}, },
dashboard: { dashboard: {
title: 'Dashboard', title: 'Dashboard',

View file

@ -1340,6 +1340,7 @@ export default {
Product: 'รายงานสินค้าและบริการ', Product: 'รายงานสินค้าและบริการ',
Sale: 'รายงานสรุปยอดขาย', Sale: 'รายงานสรุปยอดขาย',
Profit: 'รายงานกำไรและขาดทุน', Profit: 'รายงานกำไรและขาดทุน',
Debt: 'รายงานลูกค้าที่มีหนี้ค้างชำระ',
}, },
document: { document: {
code: 'รหัส', code: 'รหัส',
@ -1376,6 +1377,12 @@ export default {
expenses: 'ต้นทุน', expenses: 'ต้นทุน',
income: 'รายได้', income: 'รายได้',
}, },
debtReport: {
title: 'รายงานลูกค้าที่มีหนี้ค้างชำระ ',
customerName: 'ชื่อลูกค้า',
unpaid: 'ยังไม่ได้ชำระ',
paid: 'ชำระแล้ว',
},
}, },
dashboard: { dashboard: {
title: 'Dashboard', title: 'Dashboard',

View file

@ -22,6 +22,7 @@ import {
colProfit, colProfit,
colProfitByMoth, colProfitByMoth,
colProfitByYear, colProfitByYear,
colProfitDebtReport,
} from './constants'; } from './constants';
import useFlowStore from 'src/stores/flow'; import useFlowStore from 'src/stores/flow';
import { useReportStore } from 'src/stores/report'; import { useReportStore } from 'src/stores/report';
@ -46,6 +47,7 @@ const {
dataReportSale, dataReportSale,
dataReportProduct, dataReportProduct,
dataReportProfit, dataReportProfit,
detaReportDept,
} = storeToRefs(reportStore); } = storeToRefs(reportStore);
const userRoles = computed(() => getRole() || []); const userRoles = computed(() => getRole() || []);
@ -98,6 +100,10 @@ async function fetchReportProfitByYears(years: number) {
dataReportProfitByYears.value = res?.dataset || []; dataReportProfitByYears.value = res?.dataset || [];
} }
async function fetchReportDept() {
detaReportDept.value = (await reportStore.getReportDept()) || [];
}
onMounted(async () => { onMounted(async () => {
navigatorStore.current.title = 'report.title'; navigatorStore.current.title = 'report.title';
navigatorStore.current.path = [{ text: '' }]; navigatorStore.current.path = [{ text: '' }];
@ -146,6 +152,10 @@ async function fetchReportTab() {
await fetchReportProfit(); await fetchReportProfit();
break; break;
} }
case ViewMode.DebtReport: {
await fetchReportDept();
break;
}
} }
} }
@ -636,6 +646,36 @@ watch([() => pastYears.value], async () => {
</Expansion> </Expansion>
</div> </div>
</template> </template>
<template v-if="pageState.currentTab === ViewMode.DebtReport">
<Expansion default-opened>
<template #header>
<div class="flex full-width items-center">
{{ $t('report.debtReport.title') }}
</div>
</template>
<template #main>
<TableReport
:row="
detaReportDept.map((v) => ({
customerName:
v.customerBranch.customer.customerType === 'CORP'
? $i18n.locale === 'eng'
? v.customerBranch.registerNameEN
: v.customerBranch.registerName
: $i18n.locale === 'eng'
? `${v.customerBranch.firstNameEN} ${v.customerBranch.lastNameEN}`
: `${v.customerBranch.firstName} ${v.customerBranch.lastName}`,
unpaid: v.unpaid,
paid: v.paid,
}))
"
:columns="colProfitDebtReport"
></TableReport>
</template>
</Expansion>
</template>
</article> </article>
</div> </div>
</section> </section>

View file

@ -1,6 +1,6 @@
import { QTableProps } from 'quasar'; import { QTableProps } from 'quasar';
import { Invoice, Receipt } from 'src/stores/payment/types';
import { import {
CustomerDept,
Report, Report,
ReportProduct, ReportProduct,
ReportQuotation, ReportQuotation,
@ -15,6 +15,7 @@ export enum ViewMode {
Product = 'product', Product = 'product',
Sale = 'sale', Sale = 'sale',
Profit = 'profit', Profit = 'profit',
DebtReport = 'debtReport',
} }
type ColumnsSale = { type ColumnsSale = {
@ -48,6 +49,10 @@ type ColumnsProfixByYear = Omit<ColumnsProfixByMonth, 'moth'> & {
income: number; income: number;
}; };
type ColumnsDebt = Omit<CustomerDept, 'customerBranch'> & {
customerName: string;
};
export const colReportQuotation = [ export const colReportQuotation = [
{ {
name: 'code', name: 'code',
@ -260,10 +265,33 @@ export const colProfitByYear = [
field: (data: ColumnsProfixByYear) => formatNumberDecimal(data.income, 2), field: (data: ColumnsProfixByYear) => formatNumberDecimal(data.income, 2),
}, },
] as const satisfies QTableProps['columns']; ] as const satisfies QTableProps['columns'];
export const colProfitDebtReport = [
{
name: 'customerName',
align: 'left',
label: 'report.debtReport.customerName',
field: (data: ColumnsDebt) => data.customerName,
},
{
name: 'unpaid',
align: 'left',
label: 'report.debtReport.unpaid',
field: (data: ColumnsDebt) => data.unpaid,
},
{
name: 'paid',
align: 'left',
label: 'report.debtReport.paid',
field: (data: ColumnsDebt) => data.paid,
},
] as const satisfies QTableProps['columns'];
export const pageTabs = [ export const pageTabs = [
{ label: 'Document', value: ViewMode.Document, by: ['user'] }, { label: 'Document', value: ViewMode.Document, by: ['user'] },
{ label: 'Invoice', value: ViewMode.Invoice, by: ['user'] }, { label: 'Invoice', value: ViewMode.Invoice, by: ['user'] },
{ label: 'Product', value: ViewMode.Product, by: ['user'] }, { label: 'Product', value: ViewMode.Product, by: ['user'] },
{ label: 'Sale', value: ViewMode.Sale, by: ['admin'] }, { label: 'Sale', value: ViewMode.Sale, by: ['admin'] },
{ label: 'Profit', value: ViewMode.Profit, by: ['admin'] }, { label: 'Profit', value: ViewMode.Profit, by: ['admin'] },
{ label: 'Debt', value: ViewMode.DebtReport, by: ['admin'] },
]; ];

View file

@ -8,6 +8,7 @@ import {
ReportQuotation, ReportQuotation,
ReportSale, ReportSale,
ReportProfit, ReportProfit,
CustomerDept,
} from './types'; } from './types';
import { baseUrl } from '../utils'; import { baseUrl } from '../utils';
import { getToken } from 'src/services/keycloak'; import { getToken } from 'src/services/keycloak';
@ -146,6 +147,14 @@ export async function getReportProfit(params?: {
return null; return null;
} }
export async function getReportDept() {
const res = await api.get<CustomerDept[]>(`/${ENDPOINT}/customer-dept`);
if (res.status < 400) {
return res.data;
}
return null;
}
export const useReportStore = defineStore('report-store', () => { export const useReportStore = defineStore('report-store', () => {
const dataReportQuotation = ref<ReportQuotation[]>([]); const dataReportQuotation = ref<ReportQuotation[]>([]);
const dataReportInvoice = ref<Report[]>([]); const dataReportInvoice = ref<Report[]>([]);
@ -154,6 +163,7 @@ export const useReportStore = defineStore('report-store', () => {
const dataReportProduct = ref<ReportProduct[]>([]); const dataReportProduct = ref<ReportProduct[]>([]);
const dataReportPayment = ref<ReportPayment[]>([]); const dataReportPayment = ref<ReportPayment[]>([]);
const dataReportProfit = ref<ReportProfit>(); const dataReportProfit = ref<ReportProfit>();
const detaReportDept = ref<CustomerDept[]>([]);
return { return {
dataReportQuotation, dataReportQuotation,
@ -163,6 +173,7 @@ export const useReportStore = defineStore('report-store', () => {
dataReportProduct, dataReportProduct,
dataReportPayment, dataReportPayment,
dataReportProfit, dataReportProfit,
detaReportDept,
downloadReportQuotation, downloadReportQuotation,
getReportQuotation, getReportQuotation,
@ -176,5 +187,6 @@ export const useReportStore = defineStore('report-store', () => {
getReportProduct, getReportProduct,
getReportPayment, getReportPayment,
getReportProfit, getReportProfit,
getReportDept,
}; };
}); });

View file

@ -63,3 +63,9 @@ export type ReportProfit = {
expenses: number; expenses: number;
income: number; income: number;
}; };
export type CustomerDept = {
customerBranch: CustomerBranch;
unpaid: number;
paid: number;
};