override fun onCreateDialog()

in app/src/main/java/org/apache/fineract/ui/online/customers/customerpayroll/editcustomerpayroll/editpayrollbottomsheet/EditPayrollBottomSheet.kt [19:70]


    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val bottomSheetDialog = super.onCreateDialog(savedInstanceState)
        val rootView = View.inflate(context, R.layout.bottom_sheet_edit_payroll_allocations, null)
        bottomSheetDialog.setContentView(rootView)

        rootView.btnCancel.setOnClickListener {
            dismiss()
        }

        rootView.btnAddAllocation.setOnClickListener {

            if (!rootView.etAccount.text.isBlank()
                    && !rootView.etAmount.text.isBlank()) {

                val updatedPayrollAllocation = PayrollAllocation(accountNumber =
                rootView.etAccount.text.toString(),
                        amount = BigDecimal(rootView.etAmount.text.toString()),
                        proportional = rootView.cbProportional.isChecked)

                when (payrollSource) {

                    PayrollSource.ADD -> onBottomSheetDialogListener
                            .addPayrollAllocation(updatedPayrollAllocation)

                    PayrollSource.EDIT -> onBottomSheetDialogListener
                            .editPayrollAllocation(updatedPayrollAllocation, position)
                }

                dismiss()
            }
        }

        when (payrollSource) {

            PayrollSource.EDIT -> {
                rootView.btnAddAllocation.text = getString(R.string.edit)
                rootView.etAmount.setText("${payrollAllocation.amount}")
                rootView.etAccount.setText(payrollAllocation.accountNumber)
                rootView.cbProportional.isChecked = payrollAllocation.proportional
            }

            PayrollSource.ADD -> {
                rootView.btnAddAllocation.text = getString(R.string.add)
                rootView.etAmount.setText("0")
                rootView.etAccount.setText("")
                rootView.cbProportional.isChecked = false
            }
        }


        return bottomSheetDialog
    }