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
use crate::com::{FromDispatchNew, SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
/// Wrapper pour l'objet TiersStat de Sage 100c (IBOTiersStat3)
///
/// Représente une statistique de tiers dans Sage 100c.
/// Permet de définir des axes d'analyse statistiques pour les tiers.
#[derive(Debug)]
pub struct TiersStat {
pub dispatch: IDispatch,
}
impl TiersStat {
/// Crée un SafeDispatch temporaire pour les appels
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
// ==================== PROPRIÉTÉS PRINCIPALES ====================
/// Récupère l'intitulé de la statistique tiers
pub fn ts_intitule(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("TS_Intitule", &[])?
.to_string()
}
/// Définit l'intitulé de la statistique tiers
pub fn set_ts_intitule(&self, intitule: &str) -> SageResult<()> {
let param = SafeVariant::from_string(intitule);
self.dispatch()
.call_method_by_name("SetTS_Intitule", &[param])?;
Ok(())
}
/// Récupère le classement de la statistique
pub fn ts_classement(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("TS_Classement", &[])?
.to_string()
}
/// Définit le classement de la statistique
pub fn set_ts_classement(&self, classement: &str) -> SageResult<()> {
let param = SafeVariant::from_string(classement);
self.dispatch()
.call_method_by_name("SetTS_Classement", &[param])?;
Ok(())
}
/// Récupère le numéro de la statistique
pub fn ts_numero(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("TS_Numero", &[])?
.to_i32()
}
// ==================== MÉTHODES IBIPersistObject ====================
/// Sauvegarde les modifications de la statistique tiers
pub fn write(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Write", &[])?;
Ok(())
}
/// Supprime la statistique tiers
pub fn remove(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Remove", &[])?;
Ok(())
}
// ==================== MÉTHODES DE DESCRIPTION ====================
/// Retourne une description formatée de la statistique tiers
pub fn description(&self) -> SageResult<String> {
let intitule = self.ts_intitule()?;
let numero = self.ts_numero()?;
Ok(format!("TiersStat: {} - {}", numero, intitule))
}
}
impl FromDispatchNew for TiersStat {
fn from_dispatch_new(dispatch: IDispatch) -> SageResult<Self> {
Ok(Self { dispatch })
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_tiers_stat_properties() {
// Test de documentation des propriétés disponibles
// Propriétés principales: ts_intitule, ts_classement, ts_numero
// Méthodes: write(), remove(), description()
}
}