first commit

This commit is contained in:
dwindown
2025-10-09 12:52:41 +07:00
commit 0da6071eb3
205 changed files with 30980 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
import { WalletsService } from './wallets.service';
import { TransactionsService } from '../transactions/transactions.service';
export declare class WalletsController {
private readonly wallets;
private readonly transactions;
constructor(wallets: WalletsService, transactions: TransactionsService);
list(): import("@prisma/client").Prisma.PrismaPromise<{
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
userId: string;
kind: string;
currency: string | null;
unit: string | null;
initialAmount: import("@prisma/client/runtime/library").Decimal | null;
pricePerUnit: import("@prisma/client/runtime/library").Decimal | null;
deletedAt: Date | null;
}[]>;
getAllTransactions(): Promise<{
category: string | null;
id: string;
createdAt: Date;
userId: string;
amount: import("@prisma/client/runtime/library").Decimal;
direction: string;
date: Date;
memo: string | null;
walletId: string;
recurrenceId: string | null;
}[]>;
create(body: {
name: string;
currency?: string;
kind?: 'money' | 'asset';
unit?: string;
initialAmount?: number;
pricePerUnit?: number;
}): import("@prisma/client").Prisma.Prisma__WalletClient<{
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
userId: string;
kind: string;
currency: string | null;
unit: string | null;
initialAmount: import("@prisma/client/runtime/library").Decimal | null;
pricePerUnit: import("@prisma/client/runtime/library").Decimal | null;
deletedAt: Date | null;
}, never, import("@prisma/client/runtime/library").DefaultArgs, import("@prisma/client").Prisma.PrismaClientOptions> | {
error: string;
};
update(id: string, body: {
name?: string;
currency?: string;
kind?: 'money' | 'asset';
unit?: string;
initialAmount?: number;
pricePerUnit?: number;
}): import("@prisma/client").Prisma.Prisma__WalletClient<{
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
userId: string;
kind: string;
currency: string | null;
unit: string | null;
initialAmount: import("@prisma/client/runtime/library").Decimal | null;
pricePerUnit: import("@prisma/client/runtime/library").Decimal | null;
deletedAt: Date | null;
}, never, import("@prisma/client/runtime/library").DefaultArgs, import("@prisma/client").Prisma.PrismaClientOptions>;
delete(id: string): import("@prisma/client").Prisma.Prisma__WalletClient<{
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
userId: string;
kind: string;
currency: string | null;
unit: string | null;
initialAmount: import("@prisma/client/runtime/library").Decimal | null;
pricePerUnit: import("@prisma/client/runtime/library").Decimal | null;
deletedAt: Date | null;
}, never, import("@prisma/client/runtime/library").DefaultArgs, import("@prisma/client").Prisma.PrismaClientOptions>;
}

View File

@@ -0,0 +1,85 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletsController = void 0;
const common_1 = require("@nestjs/common");
const wallets_service_1 = require("./wallets.service");
const transactions_service_1 = require("../transactions/transactions.service");
let WalletsController = class WalletsController {
wallets;
transactions;
constructor(wallets, transactions) {
this.wallets = wallets;
this.transactions = transactions;
}
list() {
return this.wallets.list();
}
async getAllTransactions() {
return this.transactions.listAll();
}
create(body) {
if (!body?.name) {
return { error: 'name is required' };
}
return this.wallets.create(body);
}
update(id, body) {
return this.wallets.update(id, body);
}
delete(id) {
return this.wallets.delete(id);
}
};
exports.WalletsController = WalletsController;
__decorate([
(0, common_1.Get)(),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], WalletsController.prototype, "list", null);
__decorate([
(0, common_1.Get)('transactions'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], WalletsController.prototype, "getAllTransactions", null);
__decorate([
(0, common_1.Post)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], WalletsController.prototype, "create", null);
__decorate([
(0, common_1.Put)(':id'),
__param(0, (0, common_1.Param)('id')),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Object]),
__metadata("design:returntype", void 0)
], WalletsController.prototype, "update", null);
__decorate([
(0, common_1.Delete)(':id'),
__param(0, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], WalletsController.prototype, "delete", null);
exports.WalletsController = WalletsController = __decorate([
(0, common_1.Controller)('wallets'),
__metadata("design:paramtypes", [wallets_service_1.WalletsService,
transactions_service_1.TransactionsService])
], WalletsController);
//# sourceMappingURL=wallets.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"wallets.controller.js","sourceRoot":"","sources":["../../src/wallets/wallets.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiF;AACjF,uDAAmD;AACnD,+EAA2E;AAGpE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAET;IACA;IAFnB,YACmB,OAAuB,EACvB,YAAiC;QADjC,YAAO,GAAP,OAAO,CAAgB;QACvB,iBAAY,GAAZ,YAAY,CAAqB;IACjD,CAAC;IAGJ,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAGK,AAAN,KAAK,CAAC,kBAAkB;QACtB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC;IAGD,MAAM,CAAS,IAAiI;QAC9I,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;YAChB,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAGD,MAAM,CAAc,EAAU,EAAU,IAAkI;QACxK,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAGD,MAAM,CAAc,EAAU;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAA;AAjCY,8CAAiB;AAO5B;IADC,IAAA,YAAG,GAAE;;;;6CAGL;AAGK;IADL,IAAA,YAAG,EAAC,cAAc,CAAC;;;;2DAGnB;AAGD;IADC,IAAA,aAAI,GAAE;IACC,WAAA,IAAA,aAAI,GAAE,CAAA;;;;+CAKb;AAGD;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;IACH,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;;;+CAEtC;AAGD;IADC,IAAA,eAAM,EAAC,KAAK,CAAC;IACN,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;+CAElB;4BAhCU,iBAAiB;IAD7B,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAGQ,gCAAc;QACT,0CAAmB;GAHzC,iBAAiB,CAiC7B"}

View File

@@ -0,0 +1,2 @@
export declare class WalletsModule {
}

26
apps/api/dist/wallets/wallets.module.js vendored Normal file
View File

@@ -0,0 +1,26 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletsModule = void 0;
const common_1 = require("@nestjs/common");
const wallets_service_1 = require("./wallets.service");
const wallets_controller_1 = require("./wallets.controller");
const transactions_service_1 = require("../transactions/transactions.service");
const prisma_module_1 = require("../prisma/prisma.module");
let WalletsModule = class WalletsModule {
};
exports.WalletsModule = WalletsModule;
exports.WalletsModule = WalletsModule = __decorate([
(0, common_1.Module)({
imports: [prisma_module_1.PrismaModule],
providers: [wallets_service_1.WalletsService, transactions_service_1.TransactionsService],
controllers: [wallets_controller_1.WalletsController],
exports: [wallets_service_1.WalletsService],
})
], WalletsModule);
//# sourceMappingURL=wallets.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"wallets.module.js","sourceRoot":"","sources":["../../src/wallets/wallets.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,uDAAmD;AACnD,6DAAyD;AACzD,+EAA2E;AAC3E,2DAAuD;AAQhD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IANzB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,SAAS,EAAE,CAAC,gCAAc,EAAE,0CAAmB,CAAC;QAChD,WAAW,EAAE,CAAC,sCAAiB,CAAC;QAChC,OAAO,EAAE,CAAC,gCAAc,CAAC;KAC1B,CAAC;GACW,aAAa,CAAG"}

View File

@@ -0,0 +1,72 @@
import { PrismaService } from '../prisma/prisma.service';
export declare class WalletsService {
private prisma;
constructor(prisma: PrismaService);
private userId;
list(): import("@prisma/client").Prisma.PrismaPromise<{
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
userId: string;
kind: string;
currency: string | null;
unit: string | null;
initialAmount: import("@prisma/client/runtime/library").Decimal | null;
pricePerUnit: import("@prisma/client/runtime/library").Decimal | null;
deletedAt: Date | null;
}[]>;
create(input: {
name: string;
currency?: string;
kind?: 'money' | 'asset';
unit?: string;
initialAmount?: number;
pricePerUnit?: number;
}): import("@prisma/client").Prisma.Prisma__WalletClient<{
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
userId: string;
kind: string;
currency: string | null;
unit: string | null;
initialAmount: import("@prisma/client/runtime/library").Decimal | null;
pricePerUnit: import("@prisma/client/runtime/library").Decimal | null;
deletedAt: Date | null;
}, never, import("@prisma/client/runtime/library").DefaultArgs, import("@prisma/client").Prisma.PrismaClientOptions>;
update(id: string, input: {
name?: string;
currency?: string;
kind?: 'money' | 'asset';
unit?: string;
initialAmount?: number;
pricePerUnit?: number;
}): import("@prisma/client").Prisma.Prisma__WalletClient<{
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
userId: string;
kind: string;
currency: string | null;
unit: string | null;
initialAmount: import("@prisma/client/runtime/library").Decimal | null;
pricePerUnit: import("@prisma/client/runtime/library").Decimal | null;
deletedAt: Date | null;
}, never, import("@prisma/client/runtime/library").DefaultArgs, import("@prisma/client").Prisma.PrismaClientOptions>;
delete(id: string): import("@prisma/client").Prisma.Prisma__WalletClient<{
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
userId: string;
kind: string;
currency: string | null;
unit: string | null;
initialAmount: import("@prisma/client/runtime/library").Decimal | null;
pricePerUnit: import("@prisma/client/runtime/library").Decimal | null;
deletedAt: Date | null;
}, never, import("@prisma/client/runtime/library").DefaultArgs, import("@prisma/client").Prisma.PrismaClientOptions>;
}

View File

@@ -0,0 +1,86 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletsService = void 0;
const common_1 = require("@nestjs/common");
const prisma_service_1 = require("../prisma/prisma.service");
const user_util_1 = require("../common/user.util");
let WalletsService = class WalletsService {
prisma;
constructor(prisma) {
this.prisma = prisma;
}
userId() {
return (0, user_util_1.getTempUserId)();
}
list() {
return this.prisma.wallet.findMany({
where: { userId: this.userId(), deletedAt: null },
orderBy: { createdAt: 'asc' },
});
}
create(input) {
const kind = input.kind ?? 'money';
return this.prisma.wallet.create({
data: {
userId: this.userId(),
name: input.name,
kind,
currency: kind === 'money' ? (input.currency ?? 'IDR') : null,
unit: kind === 'asset' ? (input.unit ?? null) : null,
initialAmount: input.initialAmount || null,
pricePerUnit: kind === 'asset' ? (input.pricePerUnit || null) : null,
},
});
}
update(id, input) {
const updateData = {};
if (input.name !== undefined)
updateData.name = input.name;
if (input.kind !== undefined) {
updateData.kind = input.kind;
if (input.kind === 'money') {
updateData.currency = input.currency ?? 'IDR';
updateData.unit = null;
}
else {
updateData.unit = input.unit ?? null;
updateData.currency = null;
}
}
else {
if (input.currency !== undefined)
updateData.currency = input.currency;
if (input.unit !== undefined)
updateData.unit = input.unit;
}
if (input.initialAmount !== undefined)
updateData.initialAmount = input.initialAmount || null;
if (input.pricePerUnit !== undefined)
updateData.pricePerUnit = input.pricePerUnit || null;
return this.prisma.wallet.update({
where: { id, userId: this.userId() },
data: updateData,
});
}
delete(id) {
return this.prisma.wallet.update({
where: { id, userId: this.userId() },
data: { deletedAt: new Date() },
});
}
};
exports.WalletsService = WalletsService;
exports.WalletsService = WalletsService = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
], WalletsService);
//# sourceMappingURL=wallets.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"wallets.service.js","sourceRoot":"","sources":["../../src/wallets/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