FixedDepositSummaryViewController.swift 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // FixedDepositSummaryViewController.swift
  3. // Product Calculator
  4. //
  5. // Created by Suraj Kumar Mandal on 23/11/21.
  6. //
  7. import UIKit
  8. class FixedDepositSummaryViewController: UIViewController {
  9. @IBOutlet var interestReceivedMonthlyTF: UITextField!
  10. @IBOutlet var overallInterestReceivedTF: UITextField!
  11. @IBOutlet var depositMaturityDateTF: UITextField!
  12. @IBOutlet var viewDetailedButton: UIButton!
  13. @IBOutlet var detailedProjectionTableView: UITableView!
  14. var fdtdrDetails:FDTDRDetailsModel?
  15. var fdStdrDetails:FDSTDRDetailsModel?
  16. var fdType = String()
  17. override func viewDidLoad() {
  18. super.viewDidLoad()
  19. // Do any additional setup after loading the view.
  20. setupUI()
  21. setupData()
  22. }
  23. func setupUI() {
  24. viewDetailedButton.isHidden = false
  25. detailedProjectionTableView.isHidden = true
  26. }
  27. func setupData() {
  28. if fdType == "FDTDR" {
  29. interestReceivedMonthlyTF.text = "\(fdtdrDetails!.interestReceived!)"
  30. overallInterestReceivedTF.text = "\(String(describing: fdtdrDetails!.totalInterestReceived!))"
  31. let date = fdtdrDetails!.maturityDate
  32. let dateString = date?.stringBefore("T")
  33. depositMaturityDateTF.text = convertDateFormat(inputDate: dateString!)
  34. } else {
  35. interestReceivedMonthlyTF.text = "\(fdStdrDetails!.interestReceived!)"
  36. overallInterestReceivedTF.text = "\(String(describing: fdStdrDetails!.totalInterestReceived!))"
  37. let date = fdStdrDetails!.maturityDate
  38. let dateString = date?.stringBefore("T")
  39. depositMaturityDateTF.text = convertDateFormat(inputDate: dateString!)
  40. }
  41. }
  42. /*
  43. // MARK: - Navigation
  44. // In a storyboard-based application, you will often want to do a little preparation before navigation
  45. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  46. // Get the new view controller using segue.destination.
  47. // Pass the selected object to the new view controller.
  48. }
  49. */
  50. @IBAction func viewDetailedProjectionAction(_ sender: Any) {
  51. viewDetailedButton.isHidden = true
  52. detailedProjectionTableView.isHidden = false
  53. }
  54. }
  55. extension FixedDepositSummaryViewController : UITableViewDelegate, UITableViewDataSource {
  56. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  57. var count = Int()
  58. if fdType == "FDTDR" {
  59. count = fdtdrDetails?.bankFdTdrLookupList.count ?? 0
  60. } else {
  61. count = fdStdrDetails?.bankFdStdrLookupList.count ?? 0
  62. }
  63. return count
  64. }
  65. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  66. let cell = tableView.dequeueReusableCell(withIdentifier: "DetailedProjectionTableViewCell", for: indexPath) as? DetailedProjectionTableViewCell
  67. if fdType == "FDTDR" {
  68. cell?.monthLabel.text = fdtdrDetails?.bankFdTdrLookupList[indexPath.row].referenceMonth
  69. cell?.amountDepositedLabel.text = String(fdtdrDetails!.bankFdTdrLookupList[indexPath.row].amountDeposited!)
  70. cell?.interestAccuredLabel.text = String(fdtdrDetails!.bankFdTdrLookupList[indexPath.row].interestAccrued!)
  71. cell?.totalInterestAccuredLabel.text = String(fdtdrDetails!.bankFdTdrLookupList[indexPath.row].totalInterestAccrued!)
  72. cell?.interestReceivedLabel.text = String(fdtdrDetails!.bankFdTdrLookupList[indexPath.row].interestReceived!)
  73. } else {
  74. cell?.monthLabel.text = fdStdrDetails?.bankFdStdrLookupList[indexPath.row].referenceMonth
  75. cell?.amountDepositedLabel.text = String(fdStdrDetails!.bankFdStdrLookupList[indexPath.row].amountDeposited!)
  76. cell?.interestAccuredLabel.text = String(fdStdrDetails!.bankFdStdrLookupList[indexPath.row].interestAccrued!)
  77. cell?.totalInterestAccuredLabel.text = String(fdStdrDetails!.bankFdStdrLookupList[indexPath.row].totalInterestReceived!)
  78. cell?.interestReceivedLabel.text = String(fdStdrDetails!.bankFdStdrLookupList[indexPath.row].interestCredited!)
  79. }
  80. return cell!
  81. }
  82. }