use crate::com::{FromDispatchNew, SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
#[derive(Debug)]
pub struct EcritureA {
pub dispatch: IDispatch,
}
impl EcritureA {
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
pub fn ea_num(&self) -> SageResult<i32> {
self.dispatch().call_method_by_name("EA_Num", &[])?.to_i32()
}
pub fn ea_ecriture_num(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("EA_EcritureNum", &[])?
.to_i32()
}
pub fn ea_ecriture_ligne(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("EA_EcritureLigne", &[])?
.to_i32()
}
pub fn ea_code_ana(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("EA_CodeAna", &[])?
.to_string()
}
pub fn ea_montant(&self) -> SageResult<f64> {
self.dispatch()
.call_method_by_name("EA_Montant", &[])?
.to_f64()
}
pub fn ea_reference(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("EA_Reference", &[])?
.to_string()
}
pub fn ea_date(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("EA_Date", &[])?
.to_string()
}
pub fn ea_libelle(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("EA_Libelle", &[])?
.to_string()
}
pub fn set_ea_code_ana(&self, code_ana: &str) -> SageResult<()> {
let code_variant = SafeVariant::from_string(code_ana);
self.dispatch()
.call_property_put("EA_CodeAna", &[code_variant])?;
Ok(())
}
pub fn set_ea_montant(&self, montant: f64) -> SageResult<()> {
let montant_variant = SafeVariant::R8(montant);
self.dispatch()
.call_property_put("EA_Montant", &[montant_variant])?;
Ok(())
}
pub fn set_ea_reference(&self, reference: &str) -> SageResult<()> {
let reference_variant = SafeVariant::from_string(reference);
self.dispatch()
.call_property_put("EA_Reference", &[reference_variant])?;
Ok(())
}
pub fn set_ea_date(&self, date: &str) -> SageResult<()> {
let date_variant = SafeVariant::from_string(date);
self.dispatch()
.call_property_put("EA_Date", &[date_variant])?;
Ok(())
}
pub fn set_ea_libelle(&self, libelle: &str) -> SageResult<()> {
let libelle_variant = SafeVariant::from_string(libelle);
self.dispatch()
.call_property_put("EA_Libelle", &[libelle_variant])?;
Ok(())
}
}
impl FromDispatchNew for EcritureA {
fn from_dispatch_new(dispatch: IDispatch) -> SageResult<Self> {
Ok(Self { dispatch })
}
}