Files
saat-app/README.md
Alex Ardhian b53406791f Harga live otomatis via cron: Yahoo Finance tiap 6 menit saat jam bursa IDX
- saat.saham: field harga_terakhir, harga_update_at + method _cron_fetch_live_prices()
- _in_trading_window() pakai timezone Asia/Jakarta eksplisit (container UTC) 08:45-16:00 WIB
- Data ir.cron (6 menit): ambil harga saham aktif, update KALAU berubah,
  sinkronkan ke saat.portofolio.harga_sekarang utk hitung equity
- Terverifikasi: 8 saham ter-fetch & ter-update (07:01 UTC / 14:01 WIB)
2026-09-02 14:02:01 +07:00

84 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Aplikasi Catat Jual-Beli Saham — Odoo 17 + Flutter
Backend Odoo ERP (Community 17) untuk mencatat pembelian & penjualan saham,
diakses dari aplikasi **Flutter** (Android).
## Arsitektur
```
Flutter app (Android) ──JSON-RPC──► Odoo 17 (Python)
│ custom addon: saat_invest
▼
PostgreSQL 16
```
## Stack
| Layer | Teknologi | Port |
|---|---|---|
| Backend | Odoo 17 Community (`odoo:17.0`) | `18069` (host) |
| Database | PostgreSQL 16 (`postgres:16`) | internal (5432, tdk di-publish) |
| Mobile | Flutter (Android) | — |
## Struktur proyek
```
saat-app/
├── docker-compose.yml # Odoo 17 + PostgreSQL 16
├── .env # RAHASIA: password (jangan commit)
├── addons/ # custom addon buatan sendiri (saat_invest)
└── README.md
```
## Cara menjalankan
```bash
cd /home/ardhi/Application/saat-app
docker compose config # validasi
docker compose up -d # start
```
Akses UI: http://localhost:18069 — login `admin` / `admin`
(`ADMIN_PASSWORD` untuk Database Management di `.env`).
## Status
- ✅ Odoo 17 container jalan (port 18069), DB PostgreSQL 16 healthy
- ✅ JSON-RPC aktif (uid `admin` verified) — endpoint yang akan dipakai Flutter
- ✅ **Addon `saat_invest` terinstal** (model saham, transaksi, portofolio + seed 5 saham IDX)
- ✅ **Portofolio auto-sync**: otomatis diperbarui tiap transaksi ditambah/ubah/hapus
(tidak perlu tombol manual; buka menu Portofolio selalu datanya segar)
- ✅ **Live harga pasar (cron)**: ambil & update harga dari Yahoo Finance (.JK)
tiap 6 menit SAAT jam bursa IDX (08:45–16:00 WIB). Update hanya bila berubah.
- ✅ End-to-end teruji: buat beli/jual → portofolio ter-update → hitung avg cost & realized/unrealized P/L
- ⏳ Aplikasi Flutter (login, catat jual/beli, portfolio, P/L)
## Install / upgrade addon saat_invest
```bash
cd /home/ardhi/Application/saat-app
set -a && source .env && set +a
# install pertama kali
docker exec -e PASSWORD="$POSTGRES_PASSWORD" saat-odoo odoo \
-d "$POSTGRES_DB" --db_host=db --db_user="$POSTGRES_USER" \
--db_password="$POSTGRES_PASSWORD" --no-http --stop-after-init -i saat_invest
# upgrade setelah ubah kode
docker exec -e PASSWORD="$POSTGRES_PASSWORD" saat-odoo odoo \
-d "$POSTGRES_DB" --db_host=db --db_user="$POSTGRES_USER" \
--db_password="$POSTGRES_PASSWORD" --no-http --stop-after-init -u saat_invest
docker restart saat-odoo
```
> Catatan Odoo: `<list>` view di Odoo 17 kadang bermasalah, pakai `<tree>`
> (kompatibel lintas versi) seperti yang sudah dilakukan.
## API untuk Flutter (via JSON-RPC `execute_kw`)
Semua melalui `POST /jsonrpc` dengan `{service:'object', method:'execute_kw'}`.
Login: `common.authenticate(db, user, pass)` → `uid`.
- List saham: `saat.saham search_read [domain] {fields}`
- Catat transaksi: `saat.transaksi create [{vals}]`
- List transaksi: `saat.transaksi search_read [domain] {fields}`
- **Rekalkulasi portofolio**: `saat.portofolio action_recalculate [[]]`
- Baca portofolio: `saat.portofolio search_read [domain] {fields}`
(sisa_lembar, avg_cost, total_beli_biaya, realized_pl, unrealized_pl, nilai_sekarang)
## Catatan keamanan
- `.env` berisi rahasia → **tidak boleh di-commit** (sudah di `.gitignore`)
- PostgreSQL tidak di-publish ke host, hanya akses antar-container
- Ganti `ADMIN_PASSWD` segera setelah setup awal