12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import java.io.File
- import java.io.FileWriter
- import java.io.BufferedWriter
- import java.text.SimpleDateFormat
- import java.util.Date
- import java.util.Random
- // Definisikan nama file dan path
- String fileName = 'Data Files/Data Upload/02 Redemption/upload_redemption_transaction.txt'
- File file = new File(fileName)
- // Cek apakah file sudah ada, jika ada hapus file tersebut
- if (file.exists()) {
- file.delete()
- println("File lama telah dihapus: " + fileName)
- }
- // Buat writer untuk menulis ke file
- BufferedWriter writer = new BufferedWriter(new FileWriter(file))
- // Tulis header CSV dengan format baru
- writer.write("TransactionDate|TransactionType|SACode|InvestorFundUnitACNo|FundCode|Amount(Nominal)|Amount(Unit)|Amount(AllUnits)|Fee(Nominal)|Fee(Unit)|Fee|REDMPaymentA/CSequentialCode|REDMPaymentBankBICCode|REDMPaymentBankBIMemberCode|REDMPaymentA/CNo|PaymentDate|TransferType|SAReferenceNo")
- writer.newLine()
- // Inisialisasi format tanggal dan generator nomor acak
- //SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd")
- //String currentDate = dateFormat.format(new Date()) // Menghasilkan tanggal saat ini
- // Inisialisasi format tanggal dengan format yyyyMMdd
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd")
- String currentDate = dateFormat.format(new Date()) // Menghasilkan tanggal saat ini dalam format yyyyMMdd
- // Data dummy yang ingin ditulis
- List<Map<String, String>> data = [
- [transactionType: "2", saCode: "BPTPR", investorFundUnitACNo: "BPTPR0CZGMHF0129", fundCode: "BPTPRDTCPMPKON01", amountNominal: "10000", amountUnit: "", amountAllUnits: "", feeNominal: "100", feeUnit: "", feePercent: "", redmPaymentSequentialCode: "", redmPaymentBankBicCode: "", redmPaymentBankBiMemberCode: "", redmPaymentAcNo: "", paymentDate: "", transferType: "2", saReferenceNo: "REF003"],
- [transactionType: "2", saCode: "BPTPR", investorFundUnitACNo: "BPTPR0CZGMHF0129", fundCode: "BPTPRDTCPMFKON01", amountNominal: "10000", amountUnit: "", amountAllUnits: "", feeNominal: "100", feeUnit: "", feePercent: "", redmPaymentSequentialCode: "", redmPaymentBankBicCode: "", redmPaymentBankBiMemberCode: "", redmPaymentAcNo: "", paymentDate: "", transferType: "2", saReferenceNo: "REF004"]
- ]
- // Tulis data ke file CSV dengan menambahkan tanggal dan nomor acak untuk UnitBalanceComparison
- data.each { record ->
- writer.write("${currentDate}|${record.transactionType}|${record.saCode}|${record.investorFundUnitACNo}|${record.fundCode}|${record.amountNominal}|${record.amountUnit}|${record.amountAllUnits}|${record.feeNominal}|${record.feeUnit}|${record.feePercent}|${record.redmPaymentSequentialCode}|${record.redmPaymentBankBicCode}|${record.redmPaymentBankBiMemberCode}|${record.redmPaymentAcNo}|${record.paymentDate}|${record.transferType}|${record.saReferenceNo}")
- writer.newLine()
- }
- // Tutup writer
- writer.close()
- println("File CSV telah dibuat di: " + fileName)
|