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
use crate::com::{SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
/// ✅ IMPLÉMENTATION ENRICHIE - Version Phase 6
///
/// Wrapper pour produits/natures d'articles (IBSCIALProduit3)
///
/// Un produit définit la nature commerciale d'un article :
/// - Marchandise (achat/revente)
/// - Service
/// - Prestation
/// - Bien d'équipement
/// - etc.
///
/// # Exemple
/// ```no_run
/// use objets_metier_rs::wrappers::cial::CialApplication;
///
/// let cial_app = CialApplication::new("Objets100c.CIAL")?;
/// let factory = cial_app.factory_produit()?;
///
/// let produit = factory.create()?;
/// produit.set_intitule("Marchandise")?;
/// produit.set_type_produit(1)?;
/// produit.set_n_numero(1)?;
/// produit.write()?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
pub struct Produit {
pub(crate) dispatch: IDispatch,
}
impl Produit {
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
// ═══════════════════════════════════════════════════════════════════════
// PROPRIÉTÉS DE BASE (3 propriétés)
// ═══════════════════════════════════════════════════════════════════════
/// Identifiant unique (cbMarq)
pub fn cbmarq(&self) -> SageResult<i32> {
self.dispatch().call_method_by_name("cbMarq", &[])?.to_i32()
}
/// Intitulé du produit
pub fn intitule(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("Intitule", &[])?
.to_string()
}
/// Numéro du produit
pub fn n_numero(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("nNumero", &[])?
.to_i32()
}
// ═══════════════════════════════════════════════════════════════════════
// PROPRIÉTÉS DE CONFIGURATION (4 propriétés)
// ═══════════════════════════════════════════════════════════════════════
/// Type de produit (0=Marchandise, 1=Service, 2=Bien d'équipement)
pub fn type_produit(&self) -> SageResult<i16> {
self.dispatch()
.call_method_by_name("TypeProduit", &[])?
.to_short()
}
/// Compte comptable vente
pub fn compte_vente(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CompteVente", &[])?
.to_string()
}
/// Compte comptable achat
pub fn compte_achat(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CompteAchat", &[])?
.to_string()
}
/// Compte comptable stock
pub fn compte_stock(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CompteStock", &[])?
.to_string()
}
// ═══════════════════════════════════════════════════════════════════════
// SETTERS (6 setters)
// ═══════════════════════════════════════════════════════════════════════
/// Modifie l'intitulé du produit
pub fn set_intitule(&self, value: &str) -> SageResult<()> {
let param = SafeVariant::from_string(value);
self.dispatch().call_property_put("Intitule", &[param])?;
Ok(())
}
/// Modifie le numéro du produit
pub fn set_n_numero(&self, value: i32) -> SageResult<()> {
let param = SafeVariant::I4(value);
self.dispatch().call_property_put("nNumero", &[param])?;
Ok(())
}
/// Modifie le type de produit
pub fn set_type_produit(&self, type_p: i16) -> SageResult<()> {
let param = SafeVariant::from_i16(type_p);
self.dispatch().call_property_put("TypeProduit", &[param])?;
Ok(())
}
/// Modifie le compte vente
pub fn set_compte_vente(&self, compte: &str) -> SageResult<()> {
let param = SafeVariant::from_string(compte);
self.dispatch().call_property_put("CompteVente", &[param])?;
Ok(())
}
/// Modifie le compte achat
pub fn set_compte_achat(&self, compte: &str) -> SageResult<()> {
let param = SafeVariant::from_string(compte);
self.dispatch().call_property_put("CompteAchat", &[param])?;
Ok(())
}
/// Modifie le compte stock
pub fn set_compte_stock(&self, compte: &str) -> SageResult<()> {
let param = SafeVariant::from_string(compte);
self.dispatch().call_property_put("CompteStock", &[param])?;
Ok(())
}
// ═══════════════════════════════════════════════════════════════════════
// MÉTHODES STANDARD (3 méthodes)
// ═══════════════════════════════════════════════════════════════════════
/// Enregistre les modifications
pub fn write(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Write", &[])?;
Ok(())
}
/// Enregistre avec valeurs par défaut
pub fn write_default(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("WriteDefault", &[])?;
Ok(())
}
/// Supprime l'objet
pub fn remove(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Remove", &[])?;
Ok(())
}
}