From 91c7db7c7b3dea54785f0cf84a6fe9e92496728b Mon Sep 17 00:00:00 2001 From: puriphatt Date: Mon, 24 Feb 2025 16:20:47 +0700 Subject: [PATCH] feat: add support for credit note status and acceptance functionality --- src/i18n/eng.ts | 5 +---- src/i18n/tha.ts | 5 +---- src/pages/11_credit-note/constants.ts | 1 + src/stores/credit-note/index.ts | 8 ++++++++ src/stores/credit-note/types.ts | 1 + src/stores/quotations/types.ts | 1 + 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/i18n/eng.ts b/src/i18n/eng.ts index 10188913..63508253 100644 --- a/src/i18n/eng.ts +++ b/src/i18n/eng.ts @@ -1257,6 +1257,7 @@ export default { refundSuccess: 'Refund Success', }, status: { + Waiting: 'Credit Note', Pending: 'Pending Refund', Success: 'Refund Completed', Canceled: 'Canceled', @@ -1266,10 +1267,6 @@ export default { Done: 'Done', }, }, - stats: { - Pending: 'Pending Refund', - Success: 'Refund Completed', - }, }, invoice: { diff --git a/src/i18n/tha.ts b/src/i18n/tha.ts index 01b8b16d..d60b0045 100644 --- a/src/i18n/tha.ts +++ b/src/i18n/tha.ts @@ -1237,6 +1237,7 @@ export default { refundSuccess: 'คืนเงินเสร็จเรียบร้อย', }, status: { + Waiting: 'ใบลดหนี้', Pending: 'รอคืนเงิน', Success: 'คืนเงินเสร็จสิ้น', Canceled: 'ยกเลิกรายการ', @@ -1246,10 +1247,6 @@ export default { Done: 'คืนเงินเรียบร้อย', }, }, - stats: { - Pending: 'รอคืนเงิน', - Success: 'คืนเงินเสร็จสิ้น', - }, }, invoice: { diff --git a/src/pages/11_credit-note/constants.ts b/src/pages/11_credit-note/constants.ts index e69f5e6c..4042661e 100644 --- a/src/pages/11_credit-note/constants.ts +++ b/src/pages/11_credit-note/constants.ts @@ -14,6 +14,7 @@ export const taskStatusOpts = [ ]; export const pageTabs = [ + { label: CreditNoteStatus.Waiting, value: CreditNoteStatus.Waiting }, { label: CreditNoteStatus.Pending, value: CreditNoteStatus.Pending }, { label: CreditNoteStatus.Success, value: CreditNoteStatus.Success }, ]; diff --git a/src/stores/credit-note/index.ts b/src/stores/credit-note/index.ts index d057c4a4..72ae3977 100644 --- a/src/stores/credit-note/index.ts +++ b/src/stores/credit-note/index.ts @@ -71,12 +71,19 @@ export async function updatePaybackStatus( return null; } +export async function acceptCreditNote(id: string) { + const res = await api.post(`/${ENDPOINT}/${id}/accept`); + if (res.status < 400) return res.data; + return null; +} + export const useCreditNote = defineStore('credit-note-store', () => { const data = ref([]); const page = ref(1); const pageMax = ref(1); const pageSize = ref(30); const stats = ref>({ + [Status.Waiting]: 0, [Status.Pending]: 0, [Status.Success]: 0, }); @@ -94,6 +101,7 @@ export const useCreditNote = defineStore('credit-note-store', () => { createCreditNote, updateCreditNote, deleteCreditNote, + acceptCreditNote, ...manageAttachment(api, ENDPOINT), ...manageFile<'slip'>(api, ENDPOINT), diff --git a/src/stores/credit-note/types.ts b/src/stores/credit-note/types.ts index 46267c36..bccec871 100644 --- a/src/stores/credit-note/types.ts +++ b/src/stores/credit-note/types.ts @@ -42,6 +42,7 @@ export type CreditNote = { }; export enum CreditNoteStatus { + Waiting = 'Waiting', Pending = 'Pending', Success = 'Success', } diff --git a/src/stores/quotations/types.ts b/src/stores/quotations/types.ts index be855586..b5f362d7 100644 --- a/src/stores/quotations/types.ts +++ b/src/stores/quotations/types.ts @@ -343,6 +343,7 @@ export type QuotationFull = { updatedBy: UpdatedBy; agentPrice?: boolean; + isDebitNote?: boolean; }; export type QuotationPayload = {