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/01 Subscription/upload_subscription_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> data = [ [transactionType: "1", saCode: "BPTPR", investorFundUnitACNo: "BPTPR0CZGMHF0129", fundCode: "BPTPRDTCPMPKON01", amountNominal: "10000", amountUnit: "", amountAllUnits: "", feeNominal: "100", feeUnit: "", feePercent: "", redmPaymentSequentialCode: "", redmPaymentBankBicCode: "", redmPaymentBankBiMemberCode: "", redmPaymentAcNo: "", paymentDate: "", transferType: "2", saReferenceNo: "REF001"], [transactionType: "1", saCode: "BPTPR", investorFundUnitACNo: "BPTPR0CZGMHF0129", fundCode: "BPTPRDTCPMFKON01", amountNominal: "10000", amountUnit: "", amountAllUnits: "", feeNominal: "100", feeUnit: "", feePercent: "", redmPaymentSequentialCode: "", redmPaymentBankBicCode: "", redmPaymentBankBiMemberCode: "", redmPaymentAcNo: "", paymentDate: "", transferType: "2", saReferenceNo: "REF002"] ] // 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)