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
use objets_metier_rs::CptaApplication;
use objets_metier_rs::SageResult;
fn main() -> SageResult<()> {
println!("🚀 Démonstration de la bibliothèque objets_metier_rs avec la base de démo BIJOU");
// Détection automatique de la version Sage installée
let app = CptaApplication::new_auto()?;
app.set_name(r"D:\TMP\BIJOU.MAE")?;
app.loggable()?.set_user_name("<Administrateur>")?;
app.loggable()?.set_user_pwd("")?;
match app.open() {
Ok(()) => {
if app.is_open()? {
// Syntaxe fluide directe - plus besoin de conversions manuelles !
println!("✅ Utilisation de la syntaxe fluide améliorée !");
println!("📋 Test Obtention compte général avec code 'BEU'...");
match app.factory_journal()?.read_numero("BEU")?.compte_general() {
Ok(Some(compte)) => {
println!(" ✅ CompteG obtenu : {:?}", compte);
println!(" - Numéro : {:?}", compte.cg_num());
println!(" - Intitulé : {:?}", compte.cg_intitule());
}
Ok(None) => {
println!(" 🔍 DEBUG CompteG - Aucun compte général associé à ce journal");
}
Err(e) => {
println!(" ⚠️ Erreur obtention CompteG : {}", e);
}
}
// Test ExistNumero avec code journal string
println!("📋 Test ExistNumero avec code 'VTE'...");
match app.factory_journal()?.exists_by_code("VTE") {
Ok(exists) => {
println!(
" ✅ ExistNumero('VTE') réussi: Journal existe = {}",
exists
);
if exists {
// Test ReadNumero avec code journal string
println!("📋 Test ReadNumero avec code 'VTE'...");
match app.factory_journal()?.read_by_code("VTE") {
Ok(journal) => {
println!(" ✅ ReadNumero('VTE') réussi: {:?}", journal);
// Test des méthodes typées du journal
println!(" 🔸 Numéro : {:?}", journal.jo_num());
println!(" 🔸 Intitulé : {:?}", journal.jo_intitule());
println!(" 🔸 Type : {:?}", journal.jo_type());
println!(
" 🔸 Contrepartie : {:?}",
journal.jo_contrepartie()
);
println!(
" 🔸 Saisie analytique : {:?}",
journal.jo_saisi_anal()
);
println!(" 🔸 En sommeil : {:?}", journal.jo_sommeil());
match journal.compte_general() {
Ok(Some(compte)) => {
println!(" 🔸 CompteG obtenu : {:?}", compte);
println!(" - Numéro : {:?}", compte.cg_num());
println!(
" - Intitulé : {:?}",
compte.cg_intitule()
);
}
Ok(None) => {
println!(
" 🔸 CompteG : Aucun compte général associé à ce journal"
);
}
Err(e) => {
println!(" 🔸 Erreur obtention CompteG : {}", e)
}
}
}
Err(e) => println!(
" ⚠️ ReadNumero('VTE'): {} (Dossier fermé = normal)",
e
),
}
}
}
Err(e) => println!(" ⚠️ ExistNumero('VTE'): {} (Dossier fermé = normal)", e),
}
// Test FactoryEcriture
println!("📋 Test ExistNumero avec numéro 3...");
match app.factory_ecriture()?.exist_numero(3) {
Ok(exists) => {
println!(" ✅ ExistNumero(3) réussi: Écriture existe = {}", exists);
if exists {
// Test ReadNumero avec numéro
println!("📋 Test ReadNumero avec numéro 3...");
match app.factory_ecriture()?.read_numero(3) {
Ok(ecriture) => {
println!(" ✅ ReadNumero(3) réussi: {:?}", ecriture);
// Test des méthodes typées de l'écriture
println!(" 🔸 Numéro : {:?}", ecriture.ec_no());
println!(" 🔸 Pièce : {:?}", ecriture.ec_piece());
println!(" 🔸 Intitulé : {:?}", ecriture.ec_intitule());
println!(" 🔸 Montant : {:?}", ecriture.ec_montant());
println!(" 🔸 Sens : {:?}", ecriture.ec_sens());
println!(" 🔸 Lettrage : {:?}", ecriture.ec_lettrage());
println!(" 🔸 Devise : {:?}", ecriture.ec_devise());
println!(" 🔸 Date : {:?}", ecriture.date());
println!(" 🔸 Date de saisie : {:?}", ecriture.date_saisie());
match ecriture.compte_general() {
Ok(Some(compte)) => {
println!(" 🔸 CompteG obtenu : {:?}", compte);
println!(" - Numéro : {:?}", compte.cg_num());
println!(
" - Intitulé : {:?}",
compte.cg_intitule()
);
}
Ok(None) => {
println!(
" 🔸 CompteG : Aucun compte général associé à cette écriture"
);
}
Err(e) => {
println!(" 🔸 Erreur obtention CompteG : {}", e)
}
}
match ecriture.journal() {
Ok(Some(journal)) => {
println!(" 🔸 Journal obtenu : {:?}", journal);
println!(" - Numéro : {:?}", journal.jo_num());
println!(
" - Intitulé : {:?}",
journal.jo_intitule()
);
}
Ok(None) => {
println!(
" 🔸 Journal : Aucun journal associé à cette écriture"
);
}
Err(e) => {
println!(" 🔸 Erreur obtention Journal : {}", e)
}
}
match ecriture.tiers() {
Ok(Some(tiers)) => {
println!(" 🔸 Tiers obtenu : {:?}", tiers);
println!(" - Numéro : {:?}", tiers.ct_num());
println!(
" - Raison sociale : {:?}",
tiers.ct_intitule()
);
println!(" - Type : {:?}", tiers.ct_type());
println!(" - Qualité : {:?}", tiers.ct_qualite());
println!(
" - Classement : {:?}",
tiers.ct_classement()
);
println!(
" - Commentaire : {:?}",
tiers.ct_commentaire()
);
println!(
" - Identifiant : {:?}",
tiers.ct_identifiant()
);
println!(" - SIRET : {:?}", tiers.ct_siret());
println!(" - APE : {:?}", tiers.ct_ape());
println!(
" - Date de création : {:?}",
tiers.ct_date_create()
);
println!(" - Sommeil : {:?}", tiers.ct_sommeil());
}
Ok(None) => {
println!(
" 🔸 Tiers : Aucun tiers associé à cette écriture"
);
}
Err(e) => println!(" 🔸 Erreur obtention Tiers : {}", e),
}
}
Err(e) => {
println!(" ⚠️ ReadNumero(1): {} (Dossier fermé = normal)", e)
}
}
}
}
Err(e) => println!(" ⚠️ ExistNumero(1): {} (Dossier fermé = normal)", e),
}
println!("\n🎉 Syntaxe fluide améliorée fonctionnelle !");
// Fermer proprement
app.close()?;
println!("\n✅ Base fermée proprement !");
}
}
Err(e) => {
println!("❌ ÉCHEC DE CONNEXION: {}", e);
println!("💡 Causes possibles:");
println!(" - Fichier BIJOU.MAE inexistant");
println!(" - Credentials incorrects");
println!(" - Base corrompue");
println!(" - Sage OM 100c non installé");
}
}
Ok(())
}