From a419f454faeca9ebcf5dc7fff52e0676be1f05a3 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 2 Oct 2025 17:29:50 +0800 Subject: [PATCH 1/2] chore(release): 1.4.44 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e58aeb..65367e4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [1.4.44](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.43...v1.4.44) (2025-10-02) + ## [1.4.43](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.42...v1.4.43) (2025-09-29) ## [1.4.42](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.41...v1.4.42) (2025-09-24) diff --git a/package.json b/package.json index eea3308f..ead40f2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.4.43", + "version": "1.4.44", "private": true, "prisma": { "seed": "bun prisma/seed.ts" From 4ab49854e7a816bf208f0e450eee557b240812f6 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 2 Oct 2025 17:30:28 +0800 Subject: [PATCH 2/2] Invesment Add: - src/app/api/mobile/investment/[id]/invoice/ - src/app/api/mobile/master/bank/ ### No Issue --- .../mobile/investment/[id]/invoice/route.ts | 215 ++++++++++++++++++ src/app/api/mobile/master/bank/route.ts | 34 +++ 2 files changed, 249 insertions(+) create mode 100644 src/app/api/mobile/investment/[id]/invoice/route.ts create mode 100644 src/app/api/mobile/master/bank/route.ts diff --git a/src/app/api/mobile/investment/[id]/invoice/route.ts b/src/app/api/mobile/investment/[id]/invoice/route.ts new file mode 100644 index 00000000..473e3306 --- /dev/null +++ b/src/app/api/mobile/investment/[id]/invoice/route.ts @@ -0,0 +1,215 @@ +import { prisma } from "@/lib"; +import _ from "lodash"; +import { NextResponse } from "next/server"; + +export { POST, GET, PUT }; + +async function POST(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + const { data } = await request.json(); + + try { + console.log("[ID INVOICE]", id); + console.log("[DATA INVOICE]", data); + + const create = await prisma.investasi_Invoice.create({ + data: { + investasiId: id, + authorId: data.authorId, + nominal: "" + data.total, + lembarTerbeli: "" + data.jumlah, + masterBankId: data.bankId, + statusInvoiceId: "3", + }, + }); + + console.log("[CREATE INVOICE]", create); + + return NextResponse.json({ + status: 201, + success: true, + message: "Berhasil membuat invoice", + data: create, + }); + } catch (error) { + console.error("[ERROR CREATE INVOICE]", error); + return NextResponse.json({ + status: 500, + success: false, + message: "Gagal membuat invoice", + reason: (error as Error).message, + }); + } +} + +async function GET(request: Request, { params }: { params: { id: string } }) { + const { id } = params; // << AUTHOR ID + const { searchParams } = new URL(request.url); + const category = searchParams.get("category"); + const authorId = searchParams.get("authorId"); + + let fixData; + + try { + if (category === "invoice") { + const data = await prisma.investasi_Invoice.findFirst({ + where: { + id: id, + }, + include: { + MasterBank: true, + StatusInvoice: true, + Investasi: { + include: { + MasterPembagianDeviden: true, + MasterPencarianInvestor: true, + MasterPeriodeDeviden: true, + ProspektusInvestasi: true, + Investasi_Invoice: { + where: { + statusInvoiceId: "1", + }, + }, + }, + }, + Author: { + include: { + Profile: true, + }, + }, + }, + }); + + const { ...allData } = data; + const Investor = data?.Investasi?.Investasi_Invoice; + fixData = { ...allData, Investor }; + } else if (category == "my-invest") { + const data = await prisma.investasi_Invoice.findMany({ + orderBy: { + updatedAt: "desc", + }, + where: { + authorId: authorId, + statusInvoiceId: "1", + isActive: true, + }, + select: { + id: true, + nominal: true, + lembarTerbeli: true, + Investasi: { + select: { + title: true, + progress: true, + }, + }, + }, + }); + + fixData = data.map((v: any) => ({ + ..._.omit(v, ["Investasi"]), + title: v.Investasi.title, + progress: v.Investasi.progress, + })); + } else if (category == "transaction") { + const data = await prisma.investasi_Invoice.findMany({ + orderBy: { + updatedAt: "desc", + }, + where: { + authorId: authorId, + }, + select: { + id: true, + statusInvoiceId: true, + nominal: true, + createdAt: true, + StatusInvoice: { + select: { + name: true, + }, + }, + Investasi: { + select: { + title: true, + }, + }, + }, + }); + + fixData = data.map((v: any) => ({ + ..._.omit(v, ["Investasi", "StatusInvoice"]), + title: v.Investasi.title, + statusInvoice: v.StatusInvoice.name, + })); + } + + return NextResponse.json({ + status: 200, + success: true, + message: `Berhasil mendapatkan data ${category}`, + data: fixData, + }); + } catch (error) { + console.error(`Error get ${category}`, error); + return NextResponse.json({ + status: 500, + success: false, + message: `Gagal mendapatkan data ${category}`, + reason: (error as Error).message, + }); + } +} + +async function PUT(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + const { data } = await request.json(); + const { searchParams } = new URL(request.url); + const status = searchParams.get("status"); + const fixStatus = _.startCase(status || ""); + + console.log("[FIX STATUS]", fixStatus); + console.log("[DATA]", data); + console.log("[ID]", id); + + try { + const checkStatus = await prisma.investasiMaster_StatusInvoice.findFirst({ + where: { + name: fixStatus, + }, + }); + + console.log("[CHECK STATUS]", checkStatus); + + if (!checkStatus) { + throw new Error("Status invoice tidak ditemukan"); + } + + const update = await prisma.investasi_Invoice.update({ + where: { + id: id, + }, + data: { + statusInvoiceId: checkStatus.id, + imageId: data.imageId, + }, + }); + + console.log("[UPDATE]", update); + + return NextResponse.json({ + status: 200, + success: true, + message: "Berhasil mengubah status invoice", + // data: update, + }); + } catch (error) { + console.error("Error update invoice", error); + return NextResponse.json({ + status: 500, + success: false, + message: "Gagal mengubah status invoice", + reason: (error as Error).message, + }); + } +} diff --git a/src/app/api/mobile/master/bank/route.ts b/src/app/api/mobile/master/bank/route.ts new file mode 100644 index 00000000..7ecd46d5 --- /dev/null +++ b/src/app/api/mobile/master/bank/route.ts @@ -0,0 +1,34 @@ +import { prisma } from "@/lib"; +import { NextResponse } from "next/server"; + +export { GET }; + +async function GET() { + try { + const data = await prisma.masterBank.findMany({ + orderBy: { + updatedAt: "asc", + }, + where: { + isActive: true, + }, + }); + + return NextResponse.json( + { success: true, message: "Berhasil mendapatkan data", data: data }, + { status: 200 } + ); + } catch (error) { + console.error("Error Get Master Bank >>", error); + return NextResponse.json( + { + success: false, + message: "API Error Get Data", + reason: (error as Error).message, + }, + { status: 500 } + ); + } finally { + await prisma.$disconnect(); + } +}