- Add Floating Action Button (FAB) with 3 quick actions - Implement Asset Price Update dialog for bulk price updates - Add bulk price update API endpoint with transaction support - Optimize multiselect, calendar, and dropdown options for mobile (44px touch targets) - Add custom date range popover to save space in Overview header - Localize number format suffixes (k/m/b for EN, rb/jt/m for ID) - Localize date format in Financial Trend (Oct 8 vs 8 Okt) - Fix negative values in trend line chart (domain auto) - Improve Asset Price Update dialog layout (compact horizontal) - Add mobile-optimized calendar with responsive cells - Fix FAB overlay and close button position - Add translations for FAB and asset price updates
93 lines
3.6 KiB
JavaScript
93 lines
3.6 KiB
JavaScript
"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");
|
|
let WalletsService = class WalletsService {
|
|
prisma;
|
|
constructor(prisma) {
|
|
this.prisma = prisma;
|
|
}
|
|
list(userId) {
|
|
return this.prisma.wallet.findMany({
|
|
where: { userId, deletedAt: null },
|
|
orderBy: { createdAt: 'asc' },
|
|
});
|
|
}
|
|
create(userId, input) {
|
|
const kind = input.kind ?? 'money';
|
|
return this.prisma.wallet.create({
|
|
data: {
|
|
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(userId, 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 },
|
|
data: updateData,
|
|
});
|
|
}
|
|
async bulkUpdatePrices(userId, updates) {
|
|
const results = await this.prisma.$transaction(updates.map((update) => this.prisma.wallet.update({
|
|
where: { id: update.walletId, userId, kind: 'asset' },
|
|
data: { pricePerUnit: update.pricePerUnit },
|
|
})));
|
|
return {
|
|
success: true,
|
|
updated: results.length,
|
|
wallets: results,
|
|
};
|
|
}
|
|
delete(userId, id) {
|
|
return this.prisma.wallet.update({
|
|
where: { id, 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
|