text: Convert the perl code to python3
  sub _calculate_financing {
  my $self = shift;
  my $obj = shift;
  my $financing_terms = $self->financing_terms();
  $logger->debug("calculate method called on calculator : " . $self->name .
  " for the object " . $obj->key_id());
  $obj->irate($obj->margin() > 0 ?
  $financing_terms->credit_irate :
  $financing_terms->debit_irate);
  my $int_rate = (($obj->margin() > 0) ?
  ($financing_terms->applicable_credit_interest_rate())/
  $financing_terms->credit_accrual_convention :
  ($financing_terms->applicable_debit_interest_rate())/
  $financing_terms->debit_accrual_convention)/100;
  my $dfic = $obj->margin() * $int_rate;
  my $dfi = ($dfic > 0) ? $dfic : 0;
  my $dfc = ($dfic < 0) ? $dfic : 0;
  ($obj->margin() > 0 ) ?
  SD::InterestRate::Util::populate_applied_base_rate_and_spread($financing_terms, $obj,
  SD::InterestRate::Constants::INFOintrt_rate_type_credit_rate) :
  SD::InterestRate::Util::populate_applied_base_rate_and_spread($financing_terms, $obj,
  SD::InterestRate::Constants::INFOintrt_rate_type_debit_rate);
  $self->net_debit($obj->margin());
  $self->daily_finance_income_cost($dfic);
  $self->debit_finance_income_cost($dfic);
  $self->interest(+DEFAULT_VALUE);
  $self->net_daily_finance_income_cost($dfic);
  $self->daily_finance_income($dfi);
  $self->daily_finance_cost($dfc);
  }
  
  sub round_off {
  my $self = shift;
  for (@calculated_fields) {
  $self->$_(SD::Treasury::Util::Util::round($self->$_, $self->numeric_decimal_point))
  if(SD::Treasury::Util::Util::numeric($self->$_));
  }
  }
  1;