Accueil > > > CALCUL INTERETS : AMORTISSEMENT CONSTANT ET VARIABLE AVEC DIFFERE OU NON
CALCUL INTERETS : AMORTISSEMENT CONSTANT ET VARIABLE AVEC DIFFERE OU NON
Information sur la source
Description
c'est mon premier prog! indulgence ce petit prog permet de calculer l'amortissement constant ou variable d'un prêt et prend en compte le delai de differé ou pas. le fichier "TECHEANCE_CREDIT" du dossier interets est le fichier de DB; creer un alias "interet" pour la connexion. encore une fois de plus votre indulgence quant à la qualité du prog
Source
- unit Calcul_Interet;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, Grids, DBGrids, Menus, DB, DBTables, Buttons, StdCtrls, Mask,
- ExtCtrls, Math, IniFiles;
-
- type
- TF_Calcul_Interet = class(TForm)
- Label24: TLabel;
- Label20: TLabel;
- Label58: TLabel;
- Label25: TLabel;
- Bevel5: TBevel;
- Label1: TLabel;
- SpeedButton1: TSpeedButton;
- RadioGroupTypeAmort: TRadioGroup;
- RadioGroup2: TRadioGroup;
- EditMontant: TEdit;
- MaskEditDateDde: TMaskEdit;
- EditDureeDiffere: TEdit;
- EditDuree: TEdit;
- MaskEditTaux: TMaskEdit;
- ButtonSaisies: TButton;
- BitBtnCalcul: TBitBtn;
- DataSource2: TDataSource;
- Table1: TTable;
- Table1PECHEANCE: TIntegerField;
- Table1DATEECHEANCE: TDateField;
- Table1MENSUALITE: TFloatField;
- Table1CAPITALE_REST: TFloatField;
- Table1INTERETS: TFloatField;
- Table1AMORTISSEMENT: TFloatField;
- Table1MONTANTTVA: TFloatField;
- Table1MENSUALITE_TOTALE: TFloatField;
- Database1: TDatabase;
- DBGrid4: TDBGrid;
- procedure BitBtnCalculClick(Sender: TObject);
- procedure ButtonSaisiesClick(Sender: TObject);
- procedure EditMontantKeyPress(Sender: TObject; var Key: Char);
- procedure EditDureeKeyPress(Sender: TObject; var Key: Char);
- procedure EditDureeDiffereKeyPress(Sender: TObject; var Key: Char);
- procedure MaskEditDateDdeKeyPress(Sender: TObject; var Key: Char);
- procedure SpeedButton1Click(Sender: TObject);
- procedure RadioGroupTypeAmortClick(Sender: TObject);
- procedure RadioGroup2Click(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure FormKeyPress(Sender: TObject; var Key: Char);
- procedure CreationAlias(NomAlias,DataDir:String);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- F_Calcul_Interet: TF_Calcul_Interet;
-
- MontantLigne, Pduree, Amortissement,duree, MontantInterets, MontantP, TVA, Annuite :double;
- TauxP, TauxTVA, DelaiP, differe :double;
-
- Year, Month, Day: Word;
-
- periode,Temps, temps1, Lemois, Annees, Lejour, an, mois, jour, i:integer;
-
- TypeAmort, etat, Interet_Alias :string;
- debut, fin, DPEcheance :Tdate;
- implementation
-
- uses Apropos;
-
- {$R *.dfm}
-
- procedure TF_Calcul_Interet.BitBtnCalculClick(Sender: TObject);
- Var cumul :double;
- begin
-
- RadioGroup2Click(Sender);
- RadioGroupTypeAmortClick(Sender);
-
- if RadioGroup2.ItemIndex <> -1 then
- begin
- if RadioGroupTypeAmort.ItemIndex <> -1 then
- begin
- if EditMontant.Text <>'' then
- begin
- if EditDuree.Text <>'' then
- begin
- if MaskEditDateDde.Text <>' / / ' then
- begin
- if MaskEditTaux.Text <>' , ' then
- begin
- TauxTVA :=18.25;
-
- if RadioGroupTypeAmort.ItemIndex =0 then
- begin
- //Cas amortissement constant
- Table1.Close;
- Table1.EmptyTable;
- Table1.Open;
-
- If RadioGroup2.ItemIndex =1 then
- begin
- //Cas amortisssement constant sans differé
- DecodeDate(strtodate(MaskEditDateDde.Text), Year, Month, Day);
-
- Annees := Year;
- Lemois := Month;
- Lejour := Day;
-
- MontantP:=strtofloat(Editmontant.Text);
- Tauxp:= strtofloat(MaskEditTaux.Text);
- temps:=round(strtofloat(editduree.Text));
-
-
- mois:=Lemois;
- an:=annees;
- jour:=Lejour;
-
- periode:=1;
- CUMUL :=0;
- while (periode<=temps) do
- begin
- Amortissement:=round(MontantP/temps);
- MontantInterets:=round((MontantP-CUMUL)* tauxp/100);
- Annuite:=Amortissement+MontantInterets;
- TVA:=round(MontantInterets*tauxtva/100);
-
- Table1.Append;
- Table1PECHEANCE.Value :=periode;
- Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
- Table1MENSUALITE.Value :=Annuite;
- Table1CAPITALE_REST.Value :=MontantP-CUMUL;
- Table1AMORTISSEMENT.Value :=Amortissement;
- Table1INTERETS.Value :=MontantInterets;
- Table1MONTANTTVA.Value :=TVA;
- Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
-
- Table1.Post;
-
- if mois=12 then
- begin
- inc(an);
- mois:=1;
- end
- else
- begin
- inc(mois);
- end;
-
- if mois=2 then
- begin
- If jour=29 then
- begin
- if IsLeapYear(an) then Jour:=jour else Jour := 28;
- end
- else if jour=30 then
- begin
- if IsLeapYear(an) then Jour:=29 else Jour := 28;
- end
- else if jour=31 then
- begin
- if IsLeapYear(an) then Jour:=29 else Jour := 28;
- end
- else jour:=Lejour;
- end
- else if ((mois=4) or (mois=6) or (mois=9) or (mois=11)) and (jour=31) then
- begin
- jour:=30;
- end
- else jour:=lejour;
-
- periode:=periode+1;
- cumul:=cumul+Amortissement;
- end;
- end
- else
- begin
- //Cas amortissement constant avec differé
- DecodeDate(strtodate(MaskEditDateDde.Text), Year, Month, Day);
-
- Annees := Year;
- Lemois := Month;
- Lejour := Day;
-
-
- MontantP:=strtofloat(Editmontant.Text);
- tauxp :=strtofloat(MaskEditTaux.Text);
- differe :=round(strtofloat(EditDureeDiffere.Text));
- temps :=round(strtofloat(editduree.Text)+differe);
-
-
- mois :=Lemois;
- jour :=lejour;
- an :=annees;
- periode:=1;
- CUMUL :=0;
-
- while periode<=temps do
- begin
- if periode<=differe then
- begin
- //Amortissement:=round(MontantP/strtofloat(editduree.Text));
- MontantInterets:=round((MontantP* tauxp)/100);
- //Annuite:=Amortissement+interet;
- TVA:=round(MontantInterets*tauxtva/100);
-
- Table1.Append;
- Table1PECHEANCE.Value :=periode;
- Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
- Table1MENSUALITE.Value :=MontantInterets;
- Table1CAPITALE_REST.Value :=MontantP;
- Table1AMORTISSEMENT.Value :=Amortissement;
- Table1INTERETS.Value :=MontantInterets;
- Table1MONTANTTVA.Value :=TVA;
- Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
-
- Table1.Post;
- end
- Else
- begin
- Amortissement:=round(MontantP/strtofloat(editduree.Text));
- MontantInterets:=round((MontantP-CUMUL)* tauxp/100);
- Annuite:=Amortissement+MontantInterets;
- TVA:=round(MontantInterets*TauxTVA/100);
-
- Table1.Append;
- Table1PECHEANCE.Value :=periode;
- Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
- Table1MENSUALITE.Value :=Annuite;
- Table1CAPITALE_REST.Value :=MontantP-CUMUL;
- Table1AMORTISSEMENT.Value :=Amortissement;
- Table1INTERETS.Value :=MontantInterets;
- Table1MONTANTTVA.Value :=TVA;
- Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
-
- Table1.Post;
- end;
-
- if mois=12 then
- begin
- inc(an);
- mois:=1;
- // Lejour:=lejour;
- end
- else
- begin
- inc(mois);
- end;
-
- if mois=2 then
- begin
- If jour=29 then
- begin
- if IsLeapYear(an) then Jour:=jour else Jour := 28;
- end
- else if jour=30 then
- begin
- if IsLeapYear(an) then Jour:=29 else Jour := 28;
- end
- else if jour=31 then
- begin
- if IsLeapYear(an) then Jour:=29 else Jour := 28;
- end
- else jour:=Lejour;
- end
- else if ((mois=4) or (mois=6) or (mois=9) or (mois=11)) and (jour=31) then
- begin
- jour:=30;
- end
- else jour:=lejour;
-
- periode:=periode+1;
- cumul:=cumul+Amortissement;
-
- end;
- end;
-
- end
- else
- begin
- //CAs amortissement variable
- Table1.Close;
- Table1.EmptyTable;
- Table1.Open;
-
- If RadioGroup2.ItemIndex =1 then
- begin
- //CAs amortissement variable sans differé
- DecodeDate(strtodate(MaskEditDateDde.Text), Year, Month, Day);
-
- Annees := Year;
- Lemois := Month;
- Lejour := Day;
-
- MontantP:=strtofloat(Editmontant.Text);
- tauxP:=strtofloat(MaskEditTaux.Text);
- temps:=round(strtofloat(editduree.Text));
-
- mois:=Lemois;
- an:=annees;
- jour:=lejour;
- periode:=1;
- CUMUL :=0;
- while (periode<=temps) do
- begin
- Annuite:=round((MontantP*tauxp/100)/(1-power((1+tauxp/100),-temps)));
- MontantInterets:=round((MontantP-CUMUL)* TAUXP/100);
- Amortissement:=Annuite-MontantInterets;
- TVA:=round(MontantInterets*TauxTVA/100);
-
- Table1.Append;
- Table1PECHEANCE.Value :=periode;
- Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
- Table1MENSUALITE.Value :=Annuite;
- Table1CAPITALE_REST.Value :=MontantP-CUMUL;
- Table1AMORTISSEMENT.Value :=Amortissement;
- Table1INTERETS.Value :=MontantInterets;
- Table1MONTANTTVA.Value :=TVA;
- Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
-
- Table1.Post;
-
- if mois=12 then
- begin
- inc(an);
- mois:=1;
- // Lejour:=lejour;
- end
- else
- begin
- inc(mois);
- end;
-
- if mois=2 then
- begin
- If jour=29 then
- begin
- if IsLeapYear(an) then Jour:=jour else Jour := 28;
- end
- else if jour=30 then
- begin
- if IsLeapYear(an) then Jour:=29 else Jour := 28;
- end
- else if jour=31 then
- begin
- if IsLeapYear(an) then Jour:=29 else Jour := 28;
- end
- else jour:=Lejour;
- end
- else if ((mois=4) or (mois=6) or (mois=9) or (mois=11)) and (jour=31) then
- begin
- jour:=30;
- end
- else jour:=lejour;
-
- periode:=periode+1;
- cumul:=cumul+Amortissement;
- end;
- end
- else
- begin
- //Cas amortissement variable avec differé
- DecodeDate(strtodate(MaskEditDateDde.Text), Year, Month, Day);
-
- Annees := Year;
- Lemois := Month;
- Lejour := Day;
-
- MontantP:=strtofloat(Editmontant.Text);
- tauxP:=strtofloat(MaskEditTaux.Text);
- differe:=round(strtofloat(EditDureeDiffere.Text));
- temps:=round(strtofloat(editduree.Text));
- temps1:=round(strtofloat(editduree.Text)+differe);
-
- mois:=Lemois;
- an:=annees;
- jour:=Lejour;
- periode:=1;
- CUMUL :=0;
- while (periode<=temps1) do
- begin
- if periode<=differe then
- begin
- //Amortissement:=round(MontantP/strtofloat(editduree.Text));
- MontantInterets:=round((MontantP)* TAUXP/100);
- //Annuite:=Amortissement+interet;
- TVA:=round(MontantInterets*TauxTVA/100);
-
- Table1.Append;
- Table1PECHEANCE.Value :=periode;
- Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
- Table1MENSUALITE.Value :=Annuite;
- Table1CAPITALE_REST.Value :=MontantP-CUMUL;
- Table1AMORTISSEMENT.Value :=Amortissement;
- Table1INTERETS.Value :=MontantInterets;
- Table1MONTANTTVA.Value :=TVA;
- Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
-
- Table1.Post;
- end
- Else
- begin
- Annuite:=round((MontantP*tauxp/100)/(1-power((1+tauxp/100),-temps)));
- MontantInterets:=round((MontantP-CUMUL)* TAUXP/100);
- Amortissement:=Annuite-MontantInterets;
- TVA:=round(MontantInterets*TauxTVA/100);
-
- Table1.Append;
- Table1PECHEANCE.Value :=periode;
- Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
- Table1MENSUALITE.Value :=Annuite;
- Table1CAPITALE_REST.Value :=MontantP-CUMUL;
- Table1AMORTISSEMENT.Value :=Amortissement;
- Table1INTERETS.Value :=MontantInterets;
- Table1MONTANTTVA.Value :=TVA;
- Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
-
- Table1.Post;
- end;
-
- if mois=12 then
- begin
- inc(an);
- mois:=1;
- // Lejour:=lejour;
- end
- else
- begin
- inc(mois);
- end;
-
- if mois=2 then
- begin
- If jour=29 then
- begin
- if IsLeapYear(an) then Jour:=jour else Jour := 28;
- end
- else if jour=30 then
- begin
- if IsLeapYear(an) then Jour:=29 else Jour := 28;
- end
- else if jour=31 then
- begin
- if IsLeapYear(an) then Jour:=29 else Jour := 28;
- end
- else jour:=Lejour;
- end
- else if ((mois=4) or (mois=6) or (mois=9) or (mois=11)) and (jour=31) then
- begin
- jour:=30;
- end
- else jour:=lejour;
-
- periode:=periode+1;
- cumul:=cumul+Amortissement;
- end;
- end;
- ButtonSaisies.SetFocus;
- end;
- end
- else
- begin
- showmessage('Préciser le taux d''intérêt SVP.');
- MaskEditTaux.SetFocus;
- end;
- end
- else
- begin
- showmessage('Préciser la date de la première écheance SVP.');
- MaskEditDateDde.SetFocus;
- end;
- end
- else
- begin
- showmessage('Préciser la durée du crédit SVP.');
- EditDuree.SetFocus;
- end;
- end
- else
- begin
- showmessage('Préciser le capital du crédit SVP.');
- EditMontant.SetFocus;
- end;
- end
- else
- begin
- showmessage('Préciser le type d''amortissement SVP.');
- end;
- end
- else
- begin
- showmessage('Préciser s''il y a différé ou non.');
- end;
- BitBtnCalcul.Enabled :=false;
- ButtonSaisies.Enabled :=true;
- ButtonSaisies.SetFocus;
- end;
-
- procedure TF_Calcul_Interet.ButtonSaisiesClick(Sender: TObject);
- begin
- RadioGroupTypeAmort.ItemIndex :=-1;
- RadioGroup2.ItemIndex :=-1;
-
- EditMontant.SetFocus;
- EditMontant.Clear;
- EditDuree.Clear;
- EditDureeDiffere.Clear;
- MaskEditDateDde.Text :='';
- MaskEditTaux.Text :='';
-
- BitBtnCalcul.Enabled :=true;
- ButtonSaisies.Enabled :=false;
-
- //Vider la table
- Table1.Close;
- Table1.EmptyTable;
- Table1.Open;
- end;
-
- procedure TF_Calcul_Interet.EditMontantKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if not (Key in ['0'..'9', DecimalSeparator, Chr(VK_BACK), Chr(VK_DELETE), Chr(VK_RETURN)])then
- Key := #0;
- if Key = DecimalSeparator then
- if Pos(DecimalSeparator, EditMontant.Text) <> 0 then
- Key := #0;
-
- if key=#13 then MaskEditDateDde.SetFocus;
- end;
-
- procedure TF_Calcul_Interet.EditDureeKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if not (Key in ['0'..'9', DecimalSeparator, Chr(VK_BACK), Chr(VK_DELETE), Chr(VK_RETURN)])then
- Key := #0;
- if Key = DecimalSeparator then
- if Pos(DecimalSeparator, EditDuree.Text) <> 0 then
- Key := #0;
-
- if key=#13 then MaskEditTaux.SetFocus;
- end;
-
- procedure TF_Calcul_Interet.EditDureeDiffereKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if not (Key in ['0'..'9', DecimalSeparator, Chr(VK_BACK), Chr(VK_DELETE), Chr(VK_RETURN)])then
- Key := #0;
- if Key = DecimalSeparator then
- if Pos(DecimalSeparator, EditDureeDiffere.Text) <> 0 then
- Key := #0;
- if key=#13 then BitBtnCalcul.SetFocus;
- end;
-
- procedure TF_Calcul_Interet.MaskEditDateDdeKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if key=#13 then EditDuree.SetFocus;
- end;
-
- procedure TF_Calcul_Interet.SpeedButton1Click(Sender: TObject);
- begin
- F_APropos.Show;
- end;
-
- procedure TF_Calcul_Interet.RadioGroupTypeAmortClick(Sender: TObject);
- begin
- if RadioGroupTypeAmort.ItemIndex =0 then typeamort:='C'
- else typeamort:='V';
- end;
-
- procedure TF_Calcul_Interet.RadioGroup2Click(Sender: TObject);
- begin
- If RadioGroup2.ItemIndex =1 then
- begin
- EditDureeDiffere.Enabled :=false;
- EditDureeDiffere.Clear;
- end
- else
- begin
- EditDureeDiffere.Enabled :=true;
- EditDureeDiffere.SetFocus;
- end;
- end;
- //MISE A JOUR
- procedure TF_Calcul_Interet.FormShow(Sender: TObject);
- Var DataDir,NomAlias:string;
- I:Integer;
- begin
- Top := 90;
- Left := 168;
- // appel de la procedure creation alias
-
- dataDir:='C:\Interets';
- CreateDir(DataDir);
- NomAlias:='Interet_Alias';
- CreationAlias(NomAlias,datadir);
-
- database1.Close;
- database1.DatabaseName :='Gestion';
- database1.AliasName := NomAlias;
- database1.Open;
- database1.Connected :=true;
-
- Table1.Close;
- Table1.DatabaseName :='Gestion';
- Table1.TableName :='TECHEANCE_CREDIT';
- Table1.TableType :=ttParadox;
- Table1.EmptyTable;
- Table1.Open;
- end;
-
- procedure TF_Calcul_Interet.FormKeyPress(Sender: TObject; var Key: Char);
- begin
- if Key = #27 then Close;
- end;
-
- //MISE A JOUR POUR LA Création de l''alias AUTOMATIQUE
- // Ici la procedur creation alias paradox
- procedure TF_Calcul_Interet.CreationAlias(NomAlias,DataDir:String);
- begin
- if not Session.IsAlias(NomAlias) then
- session.AddStandardAlias(NomAlias,DataDir,'PARADOX');
- end;
-
- end.
unit Calcul_Interet;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, Menus, DB, DBTables, Buttons, StdCtrls, Mask,
ExtCtrls, Math, IniFiles;
type
TF_Calcul_Interet = class(TForm)
Label24: TLabel;
Label20: TLabel;
Label58: TLabel;
Label25: TLabel;
Bevel5: TBevel;
Label1: TLabel;
SpeedButton1: TSpeedButton;
RadioGroupTypeAmort: TRadioGroup;
RadioGroup2: TRadioGroup;
EditMontant: TEdit;
MaskEditDateDde: TMaskEdit;
EditDureeDiffere: TEdit;
EditDuree: TEdit;
MaskEditTaux: TMaskEdit;
ButtonSaisies: TButton;
BitBtnCalcul: TBitBtn;
DataSource2: TDataSource;
Table1: TTable;
Table1PECHEANCE: TIntegerField;
Table1DATEECHEANCE: TDateField;
Table1MENSUALITE: TFloatField;
Table1CAPITALE_REST: TFloatField;
Table1INTERETS: TFloatField;
Table1AMORTISSEMENT: TFloatField;
Table1MONTANTTVA: TFloatField;
Table1MENSUALITE_TOTALE: TFloatField;
Database1: TDatabase;
DBGrid4: TDBGrid;
procedure BitBtnCalculClick(Sender: TObject);
procedure ButtonSaisiesClick(Sender: TObject);
procedure EditMontantKeyPress(Sender: TObject; var Key: Char);
procedure EditDureeKeyPress(Sender: TObject; var Key: Char);
procedure EditDureeDiffereKeyPress(Sender: TObject; var Key: Char);
procedure MaskEditDateDdeKeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton1Click(Sender: TObject);
procedure RadioGroupTypeAmortClick(Sender: TObject);
procedure RadioGroup2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure CreationAlias(NomAlias,DataDir:String);
private
{ Private declarations }
public
{ Public declarations }
end;
var
F_Calcul_Interet: TF_Calcul_Interet;
MontantLigne, Pduree, Amortissement,duree, MontantInterets, MontantP, TVA, Annuite :double;
TauxP, TauxTVA, DelaiP, differe :double;
Year, Month, Day: Word;
periode,Temps, temps1, Lemois, Annees, Lejour, an, mois, jour, i:integer;
TypeAmort, etat, Interet_Alias :string;
debut, fin, DPEcheance :Tdate;
implementation
uses Apropos;
{$R *.dfm}
procedure TF_Calcul_Interet.BitBtnCalculClick(Sender: TObject);
Var cumul :double;
begin
RadioGroup2Click(Sender);
RadioGroupTypeAmortClick(Sender);
if RadioGroup2.ItemIndex <> -1 then
begin
if RadioGroupTypeAmort.ItemIndex <> -1 then
begin
if EditMontant.Text <>'' then
begin
if EditDuree.Text <>'' then
begin
if MaskEditDateDde.Text <>' / / ' then
begin
if MaskEditTaux.Text <>' , ' then
begin
TauxTVA :=18.25;
if RadioGroupTypeAmort.ItemIndex =0 then
begin
//Cas amortissement constant
Table1.Close;
Table1.EmptyTable;
Table1.Open;
If RadioGroup2.ItemIndex =1 then
begin
//Cas amortisssement constant sans differé
DecodeDate(strtodate(MaskEditDateDde.Text), Year, Month, Day);
Annees := Year;
Lemois := Month;
Lejour := Day;
MontantP:=strtofloat(Editmontant.Text);
Tauxp:= strtofloat(MaskEditTaux.Text);
temps:=round(strtofloat(editduree.Text));
mois:=Lemois;
an:=annees;
jour:=Lejour;
periode:=1;
CUMUL :=0;
while (periode<=temps) do
begin
Amortissement:=round(MontantP/temps);
MontantInterets:=round((MontantP-CUMUL)* tauxp/100);
Annuite:=Amortissement+MontantInterets;
TVA:=round(MontantInterets*tauxtva/100);
Table1.Append;
Table1PECHEANCE.Value :=periode;
Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
Table1MENSUALITE.Value :=Annuite;
Table1CAPITALE_REST.Value :=MontantP-CUMUL;
Table1AMORTISSEMENT.Value :=Amortissement;
Table1INTERETS.Value :=MontantInterets;
Table1MONTANTTVA.Value :=TVA;
Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
Table1.Post;
if mois=12 then
begin
inc(an);
mois:=1;
end
else
begin
inc(mois);
end;
if mois=2 then
begin
If jour=29 then
begin
if IsLeapYear(an) then Jour:=jour else Jour := 28;
end
else if jour=30 then
begin
if IsLeapYear(an) then Jour:=29 else Jour := 28;
end
else if jour=31 then
begin
if IsLeapYear(an) then Jour:=29 else Jour := 28;
end
else jour:=Lejour;
end
else if ((mois=4) or (mois=6) or (mois=9) or (mois=11)) and (jour=31) then
begin
jour:=30;
end
else jour:=lejour;
periode:=periode+1;
cumul:=cumul+Amortissement;
end;
end
else
begin
//Cas amortissement constant avec differé
DecodeDate(strtodate(MaskEditDateDde.Text), Year, Month, Day);
Annees := Year;
Lemois := Month;
Lejour := Day;
MontantP:=strtofloat(Editmontant.Text);
tauxp :=strtofloat(MaskEditTaux.Text);
differe :=round(strtofloat(EditDureeDiffere.Text));
temps :=round(strtofloat(editduree.Text)+differe);
mois :=Lemois;
jour :=lejour;
an :=annees;
periode:=1;
CUMUL :=0;
while periode<=temps do
begin
if periode<=differe then
begin
//Amortissement:=round(MontantP/strtofloat(editduree.Text));
MontantInterets:=round((MontantP* tauxp)/100);
//Annuite:=Amortissement+interet;
TVA:=round(MontantInterets*tauxtva/100);
Table1.Append;
Table1PECHEANCE.Value :=periode;
Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
Table1MENSUALITE.Value :=MontantInterets;
Table1CAPITALE_REST.Value :=MontantP;
Table1AMORTISSEMENT.Value :=Amortissement;
Table1INTERETS.Value :=MontantInterets;
Table1MONTANTTVA.Value :=TVA;
Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
Table1.Post;
end
Else
begin
Amortissement:=round(MontantP/strtofloat(editduree.Text));
MontantInterets:=round((MontantP-CUMUL)* tauxp/100);
Annuite:=Amortissement+MontantInterets;
TVA:=round(MontantInterets*TauxTVA/100);
Table1.Append;
Table1PECHEANCE.Value :=periode;
Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
Table1MENSUALITE.Value :=Annuite;
Table1CAPITALE_REST.Value :=MontantP-CUMUL;
Table1AMORTISSEMENT.Value :=Amortissement;
Table1INTERETS.Value :=MontantInterets;
Table1MONTANTTVA.Value :=TVA;
Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
Table1.Post;
end;
if mois=12 then
begin
inc(an);
mois:=1;
// Lejour:=lejour;
end
else
begin
inc(mois);
end;
if mois=2 then
begin
If jour=29 then
begin
if IsLeapYear(an) then Jour:=jour else Jour := 28;
end
else if jour=30 then
begin
if IsLeapYear(an) then Jour:=29 else Jour := 28;
end
else if jour=31 then
begin
if IsLeapYear(an) then Jour:=29 else Jour := 28;
end
else jour:=Lejour;
end
else if ((mois=4) or (mois=6) or (mois=9) or (mois=11)) and (jour=31) then
begin
jour:=30;
end
else jour:=lejour;
periode:=periode+1;
cumul:=cumul+Amortissement;
end;
end;
end
else
begin
//CAs amortissement variable
Table1.Close;
Table1.EmptyTable;
Table1.Open;
If RadioGroup2.ItemIndex =1 then
begin
//CAs amortissement variable sans differé
DecodeDate(strtodate(MaskEditDateDde.Text), Year, Month, Day);
Annees := Year;
Lemois := Month;
Lejour := Day;
MontantP:=strtofloat(Editmontant.Text);
tauxP:=strtofloat(MaskEditTaux.Text);
temps:=round(strtofloat(editduree.Text));
mois:=Lemois;
an:=annees;
jour:=lejour;
periode:=1;
CUMUL :=0;
while (periode<=temps) do
begin
Annuite:=round((MontantP*tauxp/100)/(1-power((1+tauxp/100),-temps)));
MontantInterets:=round((MontantP-CUMUL)* TAUXP/100);
Amortissement:=Annuite-MontantInterets;
TVA:=round(MontantInterets*TauxTVA/100);
Table1.Append;
Table1PECHEANCE.Value :=periode;
Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
Table1MENSUALITE.Value :=Annuite;
Table1CAPITALE_REST.Value :=MontantP-CUMUL;
Table1AMORTISSEMENT.Value :=Amortissement;
Table1INTERETS.Value :=MontantInterets;
Table1MONTANTTVA.Value :=TVA;
Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
Table1.Post;
if mois=12 then
begin
inc(an);
mois:=1;
// Lejour:=lejour;
end
else
begin
inc(mois);
end;
if mois=2 then
begin
If jour=29 then
begin
if IsLeapYear(an) then Jour:=jour else Jour := 28;
end
else if jour=30 then
begin
if IsLeapYear(an) then Jour:=29 else Jour := 28;
end
else if jour=31 then
begin
if IsLeapYear(an) then Jour:=29 else Jour := 28;
end
else jour:=Lejour;
end
else if ((mois=4) or (mois=6) or (mois=9) or (mois=11)) and (jour=31) then
begin
jour:=30;
end
else jour:=lejour;
periode:=periode+1;
cumul:=cumul+Amortissement;
end;
end
else
begin
//Cas amortissement variable avec differé
DecodeDate(strtodate(MaskEditDateDde.Text), Year, Month, Day);
Annees := Year;
Lemois := Month;
Lejour := Day;
MontantP:=strtofloat(Editmontant.Text);
tauxP:=strtofloat(MaskEditTaux.Text);
differe:=round(strtofloat(EditDureeDiffere.Text));
temps:=round(strtofloat(editduree.Text));
temps1:=round(strtofloat(editduree.Text)+differe);
mois:=Lemois;
an:=annees;
jour:=Lejour;
periode:=1;
CUMUL :=0;
while (periode<=temps1) do
begin
if periode<=differe then
begin
//Amortissement:=round(MontantP/strtofloat(editduree.Text));
MontantInterets:=round((MontantP)* TAUXP/100);
//Annuite:=Amortissement+interet;
TVA:=round(MontantInterets*TauxTVA/100);
Table1.Append;
Table1PECHEANCE.Value :=periode;
Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
Table1MENSUALITE.Value :=Annuite;
Table1CAPITALE_REST.Value :=MontantP-CUMUL;
Table1AMORTISSEMENT.Value :=Amortissement;
Table1INTERETS.Value :=MontantInterets;
Table1MONTANTTVA.Value :=TVA;
Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
Table1.Post;
end
Else
begin
Annuite:=round((MontantP*tauxp/100)/(1-power((1+tauxp/100),-temps)));
MontantInterets:=round((MontantP-CUMUL)* TAUXP/100);
Amortissement:=Annuite-MontantInterets;
TVA:=round(MontantInterets*TauxTVA/100);
Table1.Append;
Table1PECHEANCE.Value :=periode;
Table1DATEECHEANCE.Value :=Encodedate(an, mois, jour);
Table1MENSUALITE.Value :=Annuite;
Table1CAPITALE_REST.Value :=MontantP-CUMUL;
Table1AMORTISSEMENT.Value :=Amortissement;
Table1INTERETS.Value :=MontantInterets;
Table1MONTANTTVA.Value :=TVA;
Table1MENSUALITE_TOTALE.VALUE :=Annuite+tva;
Table1.Post;
end;
if mois=12 then
begin
inc(an);
mois:=1;
// Lejour:=lejour;
end
else
begin
inc(mois);
end;
if mois=2 then
begin
If jour=29 then
begin
if IsLeapYear(an) then Jour:=jour else Jour := 28;
end
else if jour=30 then
begin
if IsLeapYear(an) then Jour:=29 else Jour := 28;
end
else if jour=31 then
begin
if IsLeapYear(an) then Jour:=29 else Jour := 28;
end
else jour:=Lejour;
end
else if ((mois=4) or (mois=6) or (mois=9) or (mois=11)) and (jour=31) then
begin
jour:=30;
end
else jour:=lejour;
periode:=periode+1;
cumul:=cumul+Amortissement;
end;
end;
ButtonSaisies.SetFocus;
end;
end
else
begin
showmessage('Préciser le taux d''intérêt SVP.');
MaskEditTaux.SetFocus;
end;
end
else
begin
showmessage('Préciser la date de la première écheance SVP.');
MaskEditDateDde.SetFocus;
end;
end
else
begin
showmessage('Préciser la durée du crédit SVP.');
EditDuree.SetFocus;
end;
end
else
begin
showmessage('Préciser le capital du crédit SVP.');
EditMontant.SetFocus;
end;
end
else
begin
showmessage('Préciser le type d''amortissement SVP.');
end;
end
else
begin
showmessage('Préciser s''il y a différé ou non.');
end;
BitBtnCalcul.Enabled :=false;
ButtonSaisies.Enabled :=true;
ButtonSaisies.SetFocus;
end;
procedure TF_Calcul_Interet.ButtonSaisiesClick(Sender: TObject);
begin
RadioGroupTypeAmort.ItemIndex :=-1;
RadioGroup2.ItemIndex :=-1;
EditMontant.SetFocus;
EditMontant.Clear;
EditDuree.Clear;
EditDureeDiffere.Clear;
MaskEditDateDde.Text :='';
MaskEditTaux.Text :='';
BitBtnCalcul.Enabled :=true;
ButtonSaisies.Enabled :=false;
//Vider la table
Table1.Close;
Table1.EmptyTable;
Table1.Open;
end;
procedure TF_Calcul_Interet.EditMontantKeyPress(Sender: TObject;
var Key: Char);
begin
if not (Key in ['0'..'9', DecimalSeparator, Chr(VK_BACK), Chr(VK_DELETE), Chr(VK_RETURN)])then
Key := #0;
if Key = DecimalSeparator then
if Pos(DecimalSeparator, EditMontant.Text) <> 0 then
Key := #0;
if key=#13 then MaskEditDateDde.SetFocus;
end;
procedure TF_Calcul_Interet.EditDureeKeyPress(Sender: TObject;
var Key: Char);
begin
if not (Key in ['0'..'9', DecimalSeparator, Chr(VK_BACK), Chr(VK_DELETE), Chr(VK_RETURN)])then
Key := #0;
if Key = DecimalSeparator then
if Pos(DecimalSeparator, EditDuree.Text) <> 0 then
Key := #0;
if key=#13 then MaskEditTaux.SetFocus;
end;
procedure TF_Calcul_Interet.EditDureeDiffereKeyPress(Sender: TObject;
var Key: Char);
begin
if not (Key in ['0'..'9', DecimalSeparator, Chr(VK_BACK), Chr(VK_DELETE), Chr(VK_RETURN)])then
Key := #0;
if Key = DecimalSeparator then
if Pos(DecimalSeparator, EditDureeDiffere.Text) <> 0 then
Key := #0;
if key=#13 then BitBtnCalcul.SetFocus;
end;
procedure TF_Calcul_Interet.MaskEditDateDdeKeyPress(Sender: TObject;
var Key: Char);
begin
if key=#13 then EditDuree.SetFocus;
end;
procedure TF_Calcul_Interet.SpeedButton1Click(Sender: TObject);
begin
F_APropos.Show;
end;
procedure TF_Calcul_Interet.RadioGroupTypeAmortClick(Sender: TObject);
begin
if RadioGroupTypeAmort.ItemIndex =0 then typeamort:='C'
else typeamort:='V';
end;
procedure TF_Calcul_Interet.RadioGroup2Click(Sender: TObject);
begin
If RadioGroup2.ItemIndex =1 then
begin
EditDureeDiffere.Enabled :=false;
EditDureeDiffere.Clear;
end
else
begin
EditDureeDiffere.Enabled :=true;
EditDureeDiffere.SetFocus;
end;
end;
//MISE A JOUR
procedure TF_Calcul_Interet.FormShow(Sender: TObject);
Var DataDir,NomAlias:string;
I:Integer;
begin
Top := 90;
Left := 168;
// appel de la procedure creation alias
dataDir:='C:\Interets';
CreateDir(DataDir);
NomAlias:='Interet_Alias';
CreationAlias(NomAlias,datadir);
database1.Close;
database1.DatabaseName :='Gestion';
database1.AliasName := NomAlias;
database1.Open;
database1.Connected :=true;
Table1.Close;
Table1.DatabaseName :='Gestion';
Table1.TableName :='TECHEANCE_CREDIT';
Table1.TableType :=ttParadox;
Table1.EmptyTable;
Table1.Open;
end;
procedure TF_Calcul_Interet.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #27 then Close;
end;
//MISE A JOUR POUR LA Création de l''alias AUTOMATIQUE
// Ici la procedur creation alias paradox
procedure TF_Calcul_Interet.CreationAlias(NomAlias,DataDir:String);
begin
if not Session.IsAlias(NomAlias) then
session.AddStandardAlias(NomAlias,DataDir,'PARADOX');
end;
end.
Historique
- 17 octobre 2007 20:14:08 :
- bonjour a tous et merci pour vos commentaires.
la mise à jour concerne l'alias de connexion : dans cette mise à jour elle est crée automatiquement.
NB : le nom du projet à un peu changer : c'est le même projet que j'ai renomme en "calcul_interet"
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Calcul des agios bancaire et interets crediteurs sur les comptes [ par tgr74 ]
Bonjour a tous,je suis actuellement de mettre en place pour une association des jeunes qui font dans l'entraide et l'epargne collectif un petit progr
calcul sur des entiers renvoyant un réel [ par zwyx ]
Bonjour à tous,J'ai constaté une erreur lors de l'exécution de mon programme. Cette erreur vient soit de moi, si j'ai oublié un détail, dans ce cas, v
Calcul de diffirence entre 2 Tdatetime en min [ par cheggour ]
Bonjour tous, je souhaite calculer la différence en minute entre deux TDatetime sans prendre en considération les jours, le mois et l'année. Merci d'
calcul de temps [ par vladocbm ]
bonjour tt le mondevoila je suis un débutant sur delphi, et j'ai un petit souci pour calculer un temps ecoulé par exemple date de debute 05/03/2008 /h
calcul des heures [ par Relisys76000 ]
Relisys Bonjour, je cherche une solution qui me pourrais me permettre de connaitre le temps sous forme jours, hh:mm:ss d'une liste de fichier mp3: par
Problème calcul décimal [ par Jordan59 ]
Bonjour à tous,Je rencontre un problème dans la fonction suivante :function TEcartArticle.GetValo: Extended;begin Result := (- EcartMoins + EcartPlus
calcul du temps [ par sptchasso ]
Salut, tout le monde.Ma preoccupation est de recuperer en temps reel le temps en microsecondes qui s'est ecoule entre deux points d' programme en Delp
probleme avec commandButton_click() [ par nadolille ]
bonjour!j'ai un problème avec mes comboBox!!alors j'ai 5 feuilles ,menu,calcul,BS,Resultats,Resultats_Régma feuil2;calcul:j'ai un combobox et comman
LOGICIEL Calcul INTERËTS [ par pivoine72 ]
Bonjour, je recherche un logiciel gratuit, qui pourrait me calculer le montant des Intérêts annuels de placement C Epargne et autres, sachant que le p
calcul entre date avec delai [ par ericdu62x ]
Bonsoir a tout le monde,j'ai besoin d'un petit peut d'aide concernant un calcul entre deux dates dans une base de donnée.a savoir:je stocke une date d
|
Derniers Blogs
TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|