Advertisement
RibaSoft

Pagar várias parcelas com juros proporcional

Jan 31st, 2023
1,664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.02 KB | None | 0 0
  1. DataSourceDados.DataSet.First;
  2. while not DataSourceDados.DataSet.EOF do
  3. begin
  4.   auxSelecionado := DataSourceDados.DataSet.FieldByName('SELECIONADO').AsBoolean;
  5.   auxID_Parcela := DataSourceDados.DataSet.FieldByName('ID').AsInteger;
  6.   auxJuros := DataSourceDados.DataSet.FieldByName('JUROS').AsCurrency;
  7.   auxValor := DataSourceDados.DataSet.FieldByName('RESTANTE').AsCurrency;
  8.  
  9.   if (auxSelecionado) then
  10.   begin
  11.     auxValorPago -= (auxValor + auxJuros);
  12.  
  13.     if (auxValorPago < 0) then
  14.     begin
  15.       //auxProporcaoJuros e auxProporcaoValor do tipo Float para maior precisão
  16.       auxProporcaoJuros := auxJuros / (auxValor + auxJuros);
  17.       auxProporcaoValor := auxValor / (auxValor + auxJuros);
  18.       auxJuros += Riba.Arredonda(auxValorPago * auxProporcaoJuros);
  19.       auxValor += Riba.Arredonda(auxValorPago * auxProporcaoValor);
  20.     end;
  21.  
  22.     if (auxValor < 0) then
  23.       Break;
  24.  
  25.     auxPag.Iserir(integer(auxTipoPag), ID_Servico, auxID_Parcela, auxValor, auxJuros);
  26.   end;
  27.  
  28.   DataSourceDados.DataSet.Next;
  29. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement