1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
| assign(ftemp,cheminutil+'tempstat');
{$i-}
rewrite(ftemp);
{$i+}
If ioresult <> 0
Then Begin
affichermessage(13,'Anomalie
la création du fichier TEMPSTAT',
'Traitement abandonné','',True,False);
sortieano:=True;
End;
{$i-}
close(ftemp);
{$i+}
If ioresult <> 0 Then;
TypeDuCompte := Depense;
If Not SortieAno Then
Repeat
listestat:=Nil;
CleNom := CadrerIndex(Codcol,3) + ShortToKey(Ord(TypeDuCompte)) + BudgetChoisi
+' '+ ' ' ;
BtClearKey(pfnom,1);
Repeat
BTSearchKey(pfnom,1,NoEnreg,CleNom);
Until Not IsLockError(pfnom,True);
If Not IsamOk Then
Begin
FinFichier := True;
If IsamError=10210 then
begin
{$IfDef TestEur}
{ AfficheString(3,3,'Clenom='+CleNom);
Delay(5000); }
{$EndIf}
Finfichier := True;
end;
If IsamError<>10210 Then
Begin
AfficherAnomalie(12,'Problème à la lecture des index du fichier COPNOM'+StExocourt,
'Traitement abandonné','');
SortieAno := True;
End
End Else FinFichier := False;
While Not FinFichier do
Begin
Clignote:=Not Clignote;
AfficheTraitementEnCours(21,clignote);
Repeat
BTGetRec(pfnom,NoEnreg,Recept.Enreg,True);
Until Not IsLockError(pfnom,True);
If Not IsamOk Then
Begin
AfficherAnomalie(12,'Problème à la lecture du fichier COPNOM'+StExoCourt,'',
'');
FinFichier := True;
SortieAno := True;
End Else
Begin
With Recept do
If (Enreg.NumCol = CodCol)
And (Enreg.TypeCompte = TypeDuCompte)
And ((ComptaCol <> M21) Or (Enreg.Article[1] = BudgetChoisi))
Then Begin
With Enreg do
Begin
GdLivre := ChaineDe(' ',8);
WBP := 0; WBS := 0; WDM :=0;
If TypeCompte = Depense
Then Anterieur(PfGMvt,Enreg,debit,WBP,WBS,WDM);
If TypeCompte = Recette
Then Anterieur(PfGMvt,Enreg,credit,WBP,WBS,WDM);
Case ComptaCol Of
M21 :
Begin
LetReglement:=' ';
If Article[1] <> ' ' Then VerifierAnnexe(Article[1],LetReglement);
Res:=CompteAutorise(PfTab,LetReglement+Copy(Article,2,length(Article)-1),
GdLivre,SensDuSolde,BloquantOuNon,ZBilan);
End;
M1 : Res:=CompteAutorise(PfTab,Article,GdLivre,SensDuSolde,BloquantOuNon,ZBilan);
M2 :
(*If Caractiv = 'G'
Then Res := CompteM2AutoriseG(PfTab,Article,GdLivre,SensDuSolde,BloquantOuNon,ZBilan)
Else*)
Res := CompteM3M4Autorise(PfTab,Article,GdLivre,SensDuSolde,BloquantOuNon,ZBilan);
End;
{Aucun compte n'est exclus : s'il n'est pas présent dans la nomenclature
de référence,le compte grand Livre sera le compte détaillé}
While Length(Article) < 16 do Article := Article + ' ';
If ChaineVide(GdLivre) Then
If ComptaCol = M2 Then GdLivre := Copy(Article,2,10)
Else GdLivre := Copy(Article,1,10);
Article:=EnleverEspacesDroits(GdLivre);
While Length(Article) < 16 do Article := Article + ' ';
End;
If listestat=Nil Then
Begin
new(listestat);
listestat^.tCs:=recept;;
listestat^.Suiv:=Nil;
listestat^.Pred:=Nil;
dernier:=listestat;
End Else
Begin
Aux:=dernier;
{les éléments du fichier sont toujours ajoutés en fin de liste,
sauf pour M1 où le nouvel élément peut être éventuellement
inséré un peu avant les derniers comptes de la liste :
dans tous les cas, il est intéressant de démarrer le balayage
de la liste à partir de la fin}
while (Aux<>Nil) And avant(recept,Aux^.tCs)
do Aux:=Aux^.Pred;
If Aux = dernier Then {fin de liste}
Begin
new(dernier^.Suiv);
dernier^.Suiv^.Pred:=dernier;
dernier:=dernier^.Suiv;
dernier^.Suiv:=Nil;
dernier^.tCs:=recept;
End Else
If Aux = Nil Then {dbut de liste}
Begin
new(listestat^.Pred);
listestat^.Pred^.Suiv:=listestat;
listestat:=listestat^.Pred;
listestat^.Pred:=Nil;
listestat^.tCs:=recept;
End Else {insertion dans la liste}
Begin
new(inser);
inser^.Pred:= Aux;
inser^.Suiv:=Aux^.Suiv;
Aux^.Suiv^.Pred:=inser;
Aux^.Suiv:=inser;
inser^.tCs:=recept;
End;
End;
Repeat
BTNextKey(pfnom,1,NoEnreg,CleNom);
Until Not IsLockError(pfnom,True);
If Not IsamOk Then
Begin
FinFichier := True;
If IsamError <> 10250 Then
Begin
AfficherAnomalie(12,'Problème index du fichier COPNOM'+StExoCourt,'',
'');
SortieAno := True;
End;
End;
End Else FinFichier:=True;
End;{If Not IsamOk}
End;{While Not FinFichier}
{fusion et tri de la liste listestat et du fichier ftri}
If Not sortieano Then
If existfile(cheminutil+'ftri') Then
Begin
assign(ftemp,cheminutil+'ftri');
{$i-}
rename(ftemp,cheminutil+'tempstat');
{$i+}
If ioresult <> 0
Then Begin
affichermessage(13,'Impossible de renommer le fichier TEMPSTAT',
'Traitement abandonné ','',True,False);
sortieano:=True;
End;
End;
If Not sortieano Then
Begin
assign(ftri,cheminutil+'ftri');
assign(ftemp,cheminutil+'tempstat');
{$i-}
rewrite(ftri);
reset(ftemp);
{$i+}
If ioresult <> 0
Then Begin
affichermessage(13,'Anomalie à l''ouverture des fichiers FTRI et TEMPSTAT',
'Traitement abandonné','',True,False);
sortieano:=True;
End Else
Begin
Aux:=listestat;
fintemp:=eof(ftemp);
fin:=fintemp And (Aux=Nil);
If Not fintemp Then read(ftemp,fiche) Else fintemp:=True;
While Not fin do
Begin
If (Aux=Nil) Or (Not fintemp And avant(fiche,Aux^.tCs))
Then Begin
write(ftri,fiche);
If Not eof(ftemp) Then read(ftemp,fiche) Else fintemp:=True;
End Else
Begin
write(ftri,Aux^.tCs);
If Not fintemp And idem(fiche,Aux^.tCs) Then
Begin
write(ftri,fiche);
If Not eof(ftemp) Then read(ftemp,fiche) Else fintemp:=True;
End;
Aux:=Aux^.Suiv;
End;
fin:=fintemp And (Aux=Nil);
End;{While Not fin}
End;
{$i-}
close(ftemp);
erase(ftemp);
close(ftri);
{$i+}
If ioresult=0 Then;
End;
while listestat<>Nil do
Begin
Aux:=listestat^.Suiv;
Dispose(listestat);
listestat:=Aux;
End;
TypeDuCompte:=Succ(TypeDuCompte);
Until (TypeDuCompte = BalEntre) Or SortieAno; |
Partager