Skip to content

Instantly share code, notes, and snippets.

@endymuhardin
Last active July 10, 2019 10:09
Show Gist options
  • Save endymuhardin/f77e111262df73890c835622b5d89523 to your computer and use it in GitHub Desktop.
Save endymuhardin/f77e111262df73890c835622b5d89523 to your computer and use it in GitHub Desktop.
Konfigurasi Mapping COA ke Jurnal Transaksi
String kode = "transaksi-ppob";
List<BigDecimal> nilai = new ArrayList<>();
nilai.add(new BigDecimal(100000)); // pulsa
nilai.add(new BigDecimal(1000)); // fee ks
nilai.add(new BigDecimal(400)); // fee biller
nilai.add(new BigDecimal(600); // fee bank
nilai.add(new BigDecimal(102000)); // pengurangan saldo anggota
postingJurnal(kode, nilai);
public class GeneralLedgerService {
public void postingJurnal(String kodeKonfig, List<BigDecimal> daftarNilai) {
// lookup konfig jurnal
KonfigJurnalHeader konfigHeader = dao.findByKode(kodeKonfig);
// validasi apakah jumlah konfigDetail == jumlah daftarNilai
// buat jurnal sesuai konfig
JurnalHeader jh = new JurnalHeader();
// isi detailnya
int urutanNilai = 0;
for(KonfigJurnalDetail kd : konfigHeader.getDetail()) {
JurnalDetail jd = new JurnalDetail();
jd.setAkun(kd.getAkun);
jd.setDebetKredit(kd.getDebetKredit());
jd.setNilai(daftarNilai.get(urutanNilai));
urutanNilai++;
jh.getDaftarJurnalDetail().add(jd);
}
// validasi apakah total debet == total kredit
// save ke db
dao.save(jh);
}
}
public class JurnalDetail {
private String id;
private JurnalHeader header;
private Akun akun;
private DebetKredit debetKredit;
private BigDecimal nilai;
}
public class JurnalHeader {
private String id;
private String kode;
private LocalDateTime waktuTransaksi = LocalDateTime.now();
}
insert into konfig_jurnal_header (id, kode, nama) values ('abc123', 'transaksi-ppob', 'Mapping Jurnal Transaksi PPOB');
insert into konfig_jurnal_detail(id, id_header, id_akun, debet_kredit, urutan)
values ('abc123001', 'abc123', 'hutang-biller', 'KREDIT', 1);
insert into konfig_jurnal_detail(id, id_header, id_akun, debet_kredit, urutan)
values ('abc123002', 'abc123', 'pendapatan-ppob', 'KREDIT', 2);
insert into konfig_jurnal_detail(id, id_header, id_akun, debet_kredit, urutan)
values ('abc123003', 'abc123', 'hutang-biller', 'KREDIT', 3);
insert into konfig_jurnal_detail(id, id_header, id_akun, debet_kredit, urutan)
values ('abc123004', 'abc123', 'hutang-bank-ppob', 'KREDIT', 4);
insert into konfig_jurnal_detail(id, id_header, id_akun, debet_kredit, urutan)
values ('abc123005', 'abc123', 'saldo-anggota', 'DEBET', 5);
create table akun (
id varchar(36),
kode varchar(100) not null,
nama varchar(255) not null,
saldo_normal varchar (10) not null,
primary key (id),
unique (kode)
);
create table jurnal_header (
id varchar(36),
kode varchar(100) not null,
waktu_transaksi datetime not null,
primary key (id),
unique (kode)
);
create table jurnal_detail (
id varchar(36),
id_header varchar(36) not null,
id_akun varchar(36) not null,
nilai decimal(19,2) not null,
primary key (id)
);
create table konfig_jurnal_header (
id varchar(36),
kode varchar(100) not null,
primary key (id),
unique (kode)
);
create table konfig_jurnal_detail (
id varchar(36),
id_header varchar(36) not null,
id_akun varchar(36) not null,
debet_kredit varchar(10) not null,
urutan int not null,
primary key (id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment