Script1723010672079.groovy 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import java.io.File
  2. import java.io.FileWriter
  3. import java.io.BufferedWriter
  4. import java.text.SimpleDateFormat
  5. import java.util.Date
  6. import java.util.Random
  7. // Definisikan nama file dan path
  8. String fileName = 'Data Files/Data Upload/02 Redemption/upload_redemption_transaction.txt'
  9. File file = new File(fileName)
  10. // Cek apakah file sudah ada, jika ada hapus file tersebut
  11. if (file.exists()) {
  12. file.delete()
  13. println("File lama telah dihapus: " + fileName)
  14. }
  15. // Buat writer untuk menulis ke file
  16. BufferedWriter writer = new BufferedWriter(new FileWriter(file))
  17. // Tulis header CSV dengan format baru
  18. 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")
  19. writer.newLine()
  20. // Inisialisasi format tanggal dan generator nomor acak
  21. //SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd")
  22. //String currentDate = dateFormat.format(new Date()) // Menghasilkan tanggal saat ini
  23. // Inisialisasi format tanggal dengan format yyyyMMdd
  24. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd")
  25. String currentDate = dateFormat.format(new Date()) // Menghasilkan tanggal saat ini dalam format yyyyMMdd
  26. // Data dummy yang ingin ditulis
  27. List<Map<String, String>> data = [
  28. [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"],
  29. [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"]
  30. ]
  31. // Tulis data ke file CSV dengan menambahkan tanggal dan nomor acak untuk UnitBalanceComparison
  32. data.each { record ->
  33. 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}")
  34. writer.newLine()
  35. }
  36. // Tutup writer
  37. writer.close()
  38. println("File CSV telah dibuat di: " + fileName)