Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e101afb25b | |||
| 36569d3260 | |||
| 0181bdbdfc |
69
README.md
69
README.md
@@ -171,6 +171,75 @@ dimigrasi. Hentikan stack, restore database dan filestore dari backup Odoo 17
|
|||||||
ke volume/database terpisah, ubah image kembali ke `odoo:17.0`, lalu validasi
|
ke volume/database terpisah, ubah image kembali ke `odoo:17.0`, lalu validasi
|
||||||
aplikasi sebelum cutover ulang.
|
aplikasi sebelum cutover ulang.
|
||||||
|
|
||||||
|
## Cara menyelesaikan merge conflict Git
|
||||||
|
|
||||||
|
Contoh berikut menggabungkan branch `odoo18` ke `master`. Pastikan perubahan
|
||||||
|
lokal sudah disimpan atau di-commit sebelum memulai:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git status
|
||||||
|
git fetch origin
|
||||||
|
git switch master
|
||||||
|
git pull --ff-only origin master
|
||||||
|
git merge --no-ff odoo18
|
||||||
|
```
|
||||||
|
|
||||||
|
Jika merge conflict terjadi, lihat file yang belum terselesaikan:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git status
|
||||||
|
git diff --name-only --diff-filter=U
|
||||||
|
```
|
||||||
|
|
||||||
|
Buka setiap file tersebut dan cari marker berikut:
|
||||||
|
|
||||||
|
```text
|
||||||
|
[marker pembuka] perubahan dari branch saat ini
|
||||||
|
[marker pemisah] perubahan dari branch yang sedang di-merge
|
||||||
|
[marker penutup]
|
||||||
|
```
|
||||||
|
|
||||||
|
Hapus marker dan gabungkan isi yang benar secara manual. Jangan langsung
|
||||||
|
memilih seluruh file dari salah satu branch jika kedua perubahan diperlukan.
|
||||||
|
Untuk memilih satu sisi secara sengaja, gunakan:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Pilih isi dari branch saat ini
|
||||||
|
git checkout --ours -- path/to/file
|
||||||
|
|
||||||
|
# Pilih isi dari branch yang sedang di-merge
|
||||||
|
git checkout --theirs -- path/to/file
|
||||||
|
```
|
||||||
|
|
||||||
|
Setelah semua conflict diperbaiki, validasi proyek sebelum commit:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git diff --check
|
||||||
|
docker compose config
|
||||||
|
git diff --name-only --diff-filter=U
|
||||||
|
```
|
||||||
|
|
||||||
|
Perintah terakhir harus menghasilkan output kosong. Kemudian stage file yang
|
||||||
|
sudah diselesaikan dan buat merge commit:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git add path/to/resolved-file
|
||||||
|
git add -u
|
||||||
|
git commit -m "Merge odoo18 branch into master"
|
||||||
|
git status --short --branch
|
||||||
|
git push origin master
|
||||||
|
```
|
||||||
|
|
||||||
|
Jika ingin membatalkan merge sebelum commit:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git merge --abort
|
||||||
|
```
|
||||||
|
|
||||||
|
Jangan commit `.env`, backup database, password, atau token ketika menyelesaikan
|
||||||
|
conflict. Periksa `git diff --cached` sebelum commit untuk memastikan rahasia
|
||||||
|
tidak ikut ter-stage.
|
||||||
|
|
||||||
## API untuk Flutter (via JSON-RPC `execute_kw`)
|
## API untuk Flutter (via JSON-RPC `execute_kw`)
|
||||||
Semua melalui `POST /jsonrpc` dengan `{service:'object', method:'execute_kw'}`.
|
Semua melalui `POST /jsonrpc` dengan `{service:'object', method:'execute_kw'}`.
|
||||||
Login: `common.authenticate(db, user, pass)` → `uid`.
|
Login: `common.authenticate(db, user, pass)` → `uid`.
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class SaatPortofolio(models.Model):
|
|||||||
def action_recalculate(self):
|
def action_recalculate(self):
|
||||||
"""Rekalkulasi semua posisi portofolio dari transaksi. Return dict ringkas."""
|
"""Rekalkulasi semua posisi portofolio dari transaksi. Return dict ringkas."""
|
||||||
self.env['saat.portofolio'].search([]).unlink()
|
self.env['saat.portofolio'].search([]).unlink()
|
||||||
trans = self.env['saat.transaksi'].search([('state', '=', 'done')], order='tanggal, id')
|
trans = self.env['saat.transaksi'].search([], order='tanggal, id')
|
||||||
per_saham = {}
|
per_saham = {}
|
||||||
for t in trans:
|
for t in trans:
|
||||||
a = per_saham.setdefault(t.saham_id.id, {
|
a = per_saham.setdefault(t.saham_id.id, {
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ class SaatTransaksi(models.Model):
|
|||||||
# IDR
|
# IDR
|
||||||
return self.env.ref('base.IDR', raise_if_not_found=False) or self.env.company.currency_id
|
return self.env.ref('base.IDR', raise_if_not_found=False) or self.env.company.currency_id
|
||||||
|
|
||||||
state = fields.Selection([
|
|
||||||
('done', 'Selesai'),
|
|
||||||
('cancel', 'Dibatalkan'),
|
|
||||||
], string="Status", default='done', required=True, copy=False)
|
|
||||||
|
|
||||||
@api.depends('tanggal', 'tipe', 'saham_id')
|
@api.depends('tanggal', 'tipe', 'saham_id')
|
||||||
def _compute_name(self):
|
def _compute_name(self):
|
||||||
for r in self:
|
for r in self:
|
||||||
@@ -55,14 +50,6 @@ class SaatTransaksi(models.Model):
|
|||||||
if r.harga < 0:
|
if r.harga < 0:
|
||||||
raise models.ValidationError("Harga tidak boleh negatif.")
|
raise models.ValidationError("Harga tidak boleh negatif.")
|
||||||
|
|
||||||
def action_cancel(self):
|
|
||||||
self.write({'state': 'cancel'})
|
|
||||||
return True
|
|
||||||
|
|
||||||
def action_set_to_done(self):
|
|
||||||
self.write({'state': 'done'})
|
|
||||||
return True
|
|
||||||
|
|
||||||
# --- auto-sync portofolio: setiap transaksi berubah, portofolio diperbarui ---
|
# --- auto-sync portofolio: setiap transaksi berubah, portofolio diperbarui ---
|
||||||
def _resync_portofolio(self):
|
def _resync_portofolio(self):
|
||||||
"""Rekalkulasi portofolio dari seluruh transaksi (idempoten)."""
|
"""Rekalkulasi portofolio dari seluruh transaksi (idempoten)."""
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<field name="name">saat.transaksi.list</field>
|
<field name="name">saat.transaksi.list</field>
|
||||||
<field name="model">saat.transaksi</field>
|
<field name="model">saat.transaksi</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Transaksi Jual/Beli" create="true" decoration-muted="state == 'cancel'">
|
<tree string="Transaksi Jual/Beli" create="true">
|
||||||
<field name="tanggal"/>
|
<field name="tanggal"/>
|
||||||
<field name="tipe"/>
|
<field name="tipe"/>
|
||||||
<field name="saham_id"/>
|
<field name="saham_id"/>
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
<field name="harga"/>
|
<field name="harga"/>
|
||||||
<field name="fee"/>
|
<field name="fee"/>
|
||||||
<field name="total"/>
|
<field name="total"/>
|
||||||
<field name="state" widget="badge" decoration-success="state == 'done'" decoration-danger="state == 'cancel'"/>
|
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -22,11 +21,6 @@
|
|||||||
<field name="model">saat.transaksi</field>
|
<field name="model">saat.transaksi</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Transaksi">
|
<form string="Transaksi">
|
||||||
<header>
|
|
||||||
<button name="action_cancel" string="Batalkan Transaksi" type="object" class="btn-danger" invisible="state == 'cancel'"/>
|
|
||||||
<button name="action_set_to_done" string="Set Selesai" type="object" invisible="state != 'cancel'"/>
|
|
||||||
<field name="state" widget="statusbar" statusbar_visible="done,cancel"/>
|
|
||||||
</header>
|
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
|
|||||||
@@ -304,44 +304,6 @@ class _TransaksiTabState extends State<_TransaksiTab> {
|
|||||||
|
|
||||||
void _reload() => setState(() => _fut = widget.service.listTransaksi());
|
void _reload() => setState(() => _fut = widget.service.listTransaksi());
|
||||||
|
|
||||||
Future<void> _cancelTransaksi(Transaksi t) async {
|
|
||||||
final confirm = await showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
builder: (ctx) => AlertDialog(
|
|
||||||
title: const Text('Batalkan Transaksi'),
|
|
||||||
content: Text(
|
|
||||||
'Apakah Anda yakin ingin membatalkan transaksi ${t.sahamTicker} (${t.volume} lembar)?'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(ctx).pop(false),
|
|
||||||
child: const Text('Batal'),
|
|
||||||
),
|
|
||||||
FilledButton(
|
|
||||||
style: FilledButton.styleFrom(backgroundColor: Colors.red),
|
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
|
||||||
child: const Text('Ya, Batalkan'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (confirm == true) {
|
|
||||||
try {
|
|
||||||
await widget.service.cancelTransaksi(t.id);
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('Transaksi berhasil dibatalkan')),
|
|
||||||
);
|
|
||||||
_reload();
|
|
||||||
} catch (e) {
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Gagal membatalkan transaksi: $e')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder<List<Transaksi>>(
|
return FutureBuilder<List<Transaksi>>(
|
||||||
@@ -365,76 +327,15 @@ class _TransaksiTabState extends State<_TransaksiTab> {
|
|||||||
itemBuilder: (c, i) {
|
itemBuilder: (c, i) {
|
||||||
final t = list[i];
|
final t = list[i];
|
||||||
final buy = t.isBuy;
|
final buy = t.isBuy;
|
||||||
final isCancelled = t.isCancelled;
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
backgroundColor: isCancelled
|
backgroundColor:
|
||||||
? Colors.grey
|
buy ? Colors.green : Colors.red,
|
||||||
: (buy ? Colors.green : Colors.red),
|
|
||||||
child: Text(buy ? 'B' : 'J',
|
child: Text(buy ? 'B' : 'J',
|
||||||
style: const TextStyle(color: Colors.white))),
|
style: const TextStyle(color: Colors.white))),
|
||||||
title: Row(
|
title: Text('${t.sahamTicker} · ${t.volume} lbr'),
|
||||||
children: [
|
subtitle: Text('${t.tanggal} @ ${_fmt(t.harga)} · fee ${_fmt(t.fee)}'),
|
||||||
Text(
|
trailing: Text(_fmt(t.total)),
|
||||||
'${t.sahamTicker} · ${t.volume} lbr',
|
|
||||||
style: TextStyle(
|
|
||||||
decoration: isCancelled
|
|
||||||
? TextDecoration.lineThrough
|
|
||||||
: null,
|
|
||||||
color: isCancelled ? Colors.grey : null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (isCancelled) ...[
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 6, vertical: 2),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.red.shade100,
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
'Dibatalkan',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
color: Colors.red.shade900,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
'${t.tanggal} @ ${_fmt(t.harga)} · fee ${_fmt(t.fee)}',
|
|
||||||
style: TextStyle(
|
|
||||||
decoration: isCancelled
|
|
||||||
? TextDecoration.lineThrough
|
|
||||||
: null,
|
|
||||||
color: isCancelled ? Colors.grey : null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
_fmt(t.total),
|
|
||||||
style: TextStyle(
|
|
||||||
decoration: isCancelled
|
|
||||||
? TextDecoration.lineThrough
|
|
||||||
: null,
|
|
||||||
color: isCancelled ? Colors.grey : null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!isCancelled)
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.cancel_outlined,
|
|
||||||
color: Colors.redAccent, size: 20),
|
|
||||||
tooltip: 'Batalkan transaksi',
|
|
||||||
onPressed: () => _cancelTransaksi(t),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class Transaksi {
|
|||||||
final double harga;
|
final double harga;
|
||||||
final double fee;
|
final double fee;
|
||||||
final double total;
|
final double total;
|
||||||
final String state; // done | cancel
|
|
||||||
|
|
||||||
Transaksi({
|
Transaksi({
|
||||||
required this.id,
|
required this.id,
|
||||||
@@ -38,11 +37,9 @@ class Transaksi {
|
|||||||
required this.harga,
|
required this.harga,
|
||||||
required this.fee,
|
required this.fee,
|
||||||
required this.total,
|
required this.total,
|
||||||
this.state = 'done',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
bool get isBuy => tipe == 'buy';
|
bool get isBuy => tipe == 'buy';
|
||||||
bool get isCancelled => state == 'cancel';
|
|
||||||
|
|
||||||
factory Transaksi.fromOdoo(Map<String, dynamic> m) {
|
factory Transaksi.fromOdoo(Map<String, dynamic> m) {
|
||||||
String ticker = '';
|
String ticker = '';
|
||||||
@@ -61,7 +58,6 @@ class Transaksi {
|
|||||||
harga: (m['harga'] as num?)?.toDouble() ?? 0,
|
harga: (m['harga'] as num?)?.toDouble() ?? 0,
|
||||||
fee: (m['fee'] as num?)?.toDouble() ?? 0,
|
fee: (m['fee'] as num?)?.toDouble() ?? 0,
|
||||||
total: (m['total'] as num?)?.toDouble() ?? 0,
|
total: (m['total'] as num?)?.toDouble() ?? 0,
|
||||||
state: (m['state'] as String?) ?? 'done',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class StockService {
|
|||||||
|
|
||||||
// ---- Transaksi ----
|
// ---- Transaksi ----
|
||||||
Future<List<Transaksi>> listTransaksi() async {
|
Future<List<Transaksi>> listTransaksi() async {
|
||||||
final fields = ['tanggal', 'tipe', 'saham_id', 'volume', 'harga', 'fee', 'total', 'state'];
|
final fields = ['tanggal', 'tipe', 'saham_id', 'volume', 'harga', 'fee', 'total'];
|
||||||
final res = await client.executeSearchReadPayload("saat.transaksi", fields);
|
final res = await client.executeSearchReadPayload("saat.transaksi", fields);
|
||||||
return (res as List).map((e) => Transaksi.fromOdoo(e as Map<String, dynamic>)).toList();
|
return (res as List).map((e) => Transaksi.fromOdoo(e as Map<String, dynamic>)).toList();
|
||||||
}
|
}
|
||||||
@@ -81,10 +81,6 @@ class StockService {
|
|||||||
return (res as num).toInt();
|
return (res as num).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> cancelTransaksi(int id) async {
|
|
||||||
await client.executeKwd('saat.transaksi', 'action_cancel', args: [[id]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> hapusTransaksi(List<int> ids) async {
|
Future<void> hapusTransaksi(List<int> ids) async {
|
||||||
await client.executeKwd('saat.transaksi', 'unlink', args: [ids]);
|
await client.executeKwd('saat.transaksi', 'unlink', args: [ids]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ import 'package:saat_invest_mobile/main.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
testWidgets('App boot shows Saat Invest login', (tester) async {
|
testWidgets('App boot shows Saat Invest login', (tester) async {
|
||||||
await tester.pumpWidget(const SaatInvestApp());
|
await tester.pumpWidget(const SaatInvestApp());
|
||||||
await tester.pump();
|
await tester.pumpAndSettle();
|
||||||
await tester.pump();
|
|
||||||
await tester.pump(const Duration(seconds: 1));
|
|
||||||
expect(find.text('Masuk'), findsOneWidget);
|
expect(find.text('Masuk'), findsOneWidget);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user