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
use crate::com::{FromDispatchNew, SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
/// Wrapper pour l'objet Dossier de Sage 100c (IBODossier3)
///
/// Représente un dossier comptable dans Sage 100c.
/// Contient les informations sur un dossier de l'entreprise.
#[derive(Debug)]
pub struct Dossier {
pub dispatch: IDispatch,
}
impl Dossier {
/// Crée un SafeDispatch temporaire pour les appels
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
// ==================== PROPRIÉTÉS PRINCIPALES ====================
/// Récupère le nom du dossier
pub fn d_nom(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("D_Nom", &[])?
.to_string()
}
/// Définit le nom du dossier
pub fn set_d_nom(&self, nom: &str) -> SageResult<()> {
let param = SafeVariant::from_string(nom);
self.dispatch().call_method_by_name("SetD_Nom", &[param])?;
Ok(())
}
/// Récupère la raison sociale du dossier
pub fn d_raison_sociale(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("D_RaisonSociale", &[])?
.to_string()
}
/// Définit la raison sociale du dossier
pub fn set_d_raison_sociale(&self, raison: &str) -> SageResult<()> {
let param = SafeVariant::from_string(raison);
self.dispatch()
.call_method_by_name("SetD_RaisonSociale", &[param])?;
Ok(())
}
/// Récupère le chemin du dossier
pub fn d_chemin(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("D_Chemin", &[])?
.to_string()
}
/// Récupère le code du dossier
pub fn d_code(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("D_Code", &[])?
.to_string()
}
// ==================== MÉTHODES IBIPersistObject ====================
/// Sauvegarde les modifications du dossier
pub fn write(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Write", &[])?;
Ok(())
}
/// Supprime le dossier
pub fn remove(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Remove", &[])?;
Ok(())
}
// ==================== MÉTHODES DE DESCRIPTION ====================
/// Retourne une description formatée du dossier
pub fn description(&self) -> SageResult<String> {
let nom = self.d_nom()?;
let raison = self.d_raison_sociale()?;
Ok(format!("Dossier: {} - {}", nom, raison))
}
}
impl FromDispatchNew for Dossier {
fn from_dispatch_new(dispatch: IDispatch) -> SageResult<Self> {
Ok(Self { dispatch })
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_dossier_properties() {
// Test de documentation des propriétés disponibles
// Propriétés principales: d_nom, d_raison_sociale, d_chemin, d_code
// Méthodes: write(), remove(), description()
}
}