Bonjour la communauté,
Dans mon projet de conception d'une application de gestion de stock, je suis confronté à un souci depuis une semaine.
En fait je souhaiterais,lors de la mise en place d'une facture, faire la mise à jour du stock des articles facturés. La mise à jour du stock est faite(puisque je vérifie au niveau de l'analyse avec l'outil WDMap). Jusque là tout va bien.
Il y a aussi une fiche de saisie de sortie au cas ou un article a un défaut (donc la mise en place de la facture et la sortie de stock doivent jouer le même rôle au niveau de la mise à jour du stock).
NB: Quand j'effectue une sortie d'article, j'ai une table qui récapitule les ENTREES, SORTIES, en fonction de la sélection d'une valeur de COMBO.
Le problème c'est que lorsque plusieurs articles sont facturés,je veux que toutes les lignes de factures (ou sortie d'article) pour chaque produit s'affichent parmi les SORTIES ,seulement c'est juste le dernier article ajouté à la facture qui s'affiche.
Merci d'avance pour les éventuelles réactions
Ci -joint annexes et code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 SI TABLE_LIGNEFACT..Occurrence = 0 ALORS Erreur("Vous devez renseigner au moins une ligne de commande") RETOUR FIN // Lecture des informations saisies EcranVersFichier() //***fin test**** // Ajoute / modifie l'enregistrement //HAjoute(FACTURE) nOrdre est un entier = 1 // Enregistrement des lignes de facture POUR TOUTE LIGNE DE TABLE_LIGNEFACT // On affecte l'identifiant de Commande dans les colonnes de la table des LigneFact // TABLE_LIGNEFACT.COL_IDFACTURE= FACTURE.IDFACTURE // LIGNEFACT.IDFACTURE=FACTURE.IDCLIENTS LIGNEFACT.Qte=TABLE_LIGNEFACT.COL_Qte LIGNEFACT.RefenceArticles=TABLE_LIGNEFACT.COL_Reference LIGNEFACT.LibArticle=TABLE_LIGNEFACT.COL_LibArticle LIGNEFACT.Prixvente=TABLE_LIGNEFACT.COL_Prixvente LIGNEFACT.TauxTva=TABLE_LIGNEFACT.COL_TVA LIGNEFACT.TotalHT=TABLE_LIGNEFACT.COL_SousTotal LIGNEFACT.TotalTVA=TABLE_LIGNEFACT.COL_SousTotal* 0.18 // LIGNEFACT.IDCLIENTS=TABLE_LIGNEFACT.COL_IDClients LIGNEFACT.TotalTTC=TABLE_LIGNEFACT.COL_SousTotal + (TABLE_LIGNEFACT.COL_SousTotal*0.18) // LIGNEFACT.NumFacture=nOrdre // ARTICLES.RefenceArticles=COMBO_ARTICLES..ValeurMémorisée // LIGNEFACT.RefenceArticles=ARTICLES.RefenceArticles // LIGNEFACT.IDARTICLES=ARTICLES.IDARTICLES // LIGNEFACT.TotalHT=SAI_TotalHT // LIGNEFACT.TotalTVA=SAI_TotalTVA // LIGNEFACT.TotalTTC=SAI_TotalTTC // On modifie l'ordre des lignes de commande pour mémoriser l'ordre souhaité par l'utilisateur // TABLE_LIGNEFACT.COL_OrdreAffichage = nOrdre // LIGNEFACT.OrdreAffichage=SAI_Numfacture // Enregistrement de la table TableEnregistre(TABLE_LIGNEFACT) nOrdre++ // Trace(TABLE_LIGNEFACT) // COL_ProcéduresGlobalesStockUpdate.RemplitMouvement() FIN //*****debut test**** SI OuiNon("Confirmez-vous cette facture? Elle ne sera plus modifiable !!") ALORS HRAZ(FACTURE) FACTURE.DateFacture = DateDuJour() FACTURE.IDCLIENTS = COMBO_CLIENT..ValeurMémorisée FACTURE.IDLIGNEFACT=LIGNEFACT.IDLIGNEFACT //FACTURE.DateFacture=SAI_DateFacture //FACTURE.IDFACTURE=TABLE_LIGNEFACT.COL_IDFACTURE //FACTURE.IDFACTURE=nOrdre //Facture.NumCommande = Commande.NumCommande //Facture.Observations = Commande.Observations //FACTURE.IDCLIENTS=COMBO_CLIENT..Valeur FACTURE.TotalHT =SAI_TotalHT FACTURE.TVA = TABLE_LIGNEFACT.COL_TVA FACTURE.TotalTTC = SAI_TotalTTC FACTURE.TotalTVA= SAI_TotalHT* 0.18 HAjoute(FACTURE) Info("Facture enregistrée avec succès !!") //// Ligne de facture correspondante //POUR TOUTE LIGNEFACT // HRAZ(LigneFact) //// LigneFact.IDLIGNEFACT = LigneCde.IDLigneCde // LigneFact.RefenceArticles = TABLE_LIGNEFACT.COL_Reference // LigneFact.IDFACTURE = Facture.IDFACTURE // LigneFact.PrixVente = TABLE_LIGNEFACT.COL_Prixvente //// LigneFac.Quantite = LigneCde.Quantite //// LigneFact.RefenceArticles = LigneCde.Reference //// LigneFac.Remise = LigneCde.Remise // LigneFact.TauxTVA =SAI_TotalTVA //// LigneFac.OrdreAffichage = LigneCde.OrdreAffichage // HAjoute(LigneFact) // SI OuiNon("Voulez-vous imprimer cette facture?") ALORS // ExécuteTraitement(BTN_Imprimer,trtClic) // // // SINON // Ferme(FEN_FACTURE) // FIN //On refait le calcul sur le stock du produit correspondant POUR TOUTE LIGNE DE TABLE_LIGNEFACT // POUR nIndice=1 a TABLE_LIGNEFACT..Occurrence HLitRecherchePremier(ARTICLES,RefenceArticles,TABLE_LIGNEFACT.COL_Reference) // SI HTrouve(ARTICLES) ALORS //met à jour le stock // XX produit en moins en stock // Stock.QteEnStock -= SortieStock.Quantite // Stock.QteStockVirtuel -= SortieStock.Quantite // HModifie(Stock) // Info("Sortie Validée") SortieStock.RefenceArticles=TABLE_LIGNEFACT.COL_Reference SortieStock.DateSortie=SAI_DateFacture SortieStock.Motif="Vente" SortieStock.IDSORTIE=SortieStock.IDSORTIE+1 SortieStock.Quantite=TABLE_LIGNEFACT.COL_Qte // SI pas HEnregistre(SortieStock,hNumEnrEnCours) ALORS // Erreur(errComplet) // fin HEnregistre(SortieStock) // Il faut modifier le stock du produit en conséquence HLitRecherchePremier(Stock, RefenceArticles, SortieStock.RefenceArticles) SI HTrouve(Stock) = Faux ALORS HRAZ(Stock) // Stock.AuteurModif = gsNomUtilisateurCourant Stock.DateModif = DateDuJour() Stock.RefenceArticles= SortieStock.RefenceArticles HAjoute(Stock) FIN // XX produit en moins en stock Stock.QteEnStock -= SortieStock.Quantite Stock.QteStockVirtuel -= SortieStock.Quantite HModifie(Stock) // HLitSuivant() // SINON // //// SortieStock.Quantite=TABLE_LIGNEFACT.COL_Qte // stock.RefenceArticles=TABLE_LIGNEFACT.COL_Reference // Stock.QteEnStock -= SortieStock.Quantite // Stock.QteStockVirtuel-= SortieStock.Quantite // HEnregistre(Stock) // Info("Mise à jour du stock effectuée") // FIN FIN // ToastAffiche("Mise à jour du stock effectuée",toastLong,cvMilieu,chCentre,VertClair) SINON FIN //SINON //SINON //sinon //FIN Ferme(FEN_FACTURE) // Valeur de retour de la fenêtre MaFenêtre..ValeurRenvoyée = Vrai
Partager