use crate::com::{FromDispatchNew, SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
#[derive(Debug)]
pub struct CompteG {
pub dispatch: IDispatch,
}
impl CompteG {
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
pub fn cg_num(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CG_Num", &[])?
.to_string()
}
pub fn cg_intitule(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CG_Intitule", &[])?
.to_string()
}
pub fn cg_type(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("CG_Type", &[])?
.to_i32()
}
pub fn cg_niveau(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("CG_Niveau", &[])?
.to_i32()
}
pub fn cg_sens_solde(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("CG_SensSolde", &[])?
.to_i32()
}
pub fn cg_solde_initial(&self) -> SageResult<f64> {
self.dispatch()
.call_method_by_name("CG_SoldeInitial", &[])?
.to_f64()
}
pub fn cg_solde_actuel(&self) -> SageResult<f64> {
self.dispatch()
.call_method_by_name("CG_SoldeActuel", &[])?
.to_f64()
}
pub fn cg_code_ifrs(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CG_CodeIFRS", &[])?
.to_string()
}
pub fn cg_compte_regroup(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CG_CompteRegroup", &[])?
.to_string()
}
pub fn cg_analytique(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("CG_Analytique", &[])?
.to_i32()
}
pub fn cg_journala(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CG_JournalA", &[])?
.to_string()
}
pub fn cg_interrogation_tiers(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("CG_InterrogationTiers", &[])?
.to_i32()
}
pub fn cg_lettrage(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("CG_Lettrage", &[])?
.to_i32()
}
pub fn cg_saisie_analytique(&self) -> SageResult<bool> {
let result = self
.dispatch()
.call_method_by_name("CG_SaisieAnalytique", &[])?
.to_i32()?;
Ok(result != 0)
}
pub fn cg_saisie_echeance(&self) -> SageResult<bool> {
let result = self
.dispatch()
.call_method_by_name("CG_SaisieEcheance", &[])?
.to_i32()?;
Ok(result != 0)
}
pub fn cg_saisie_quantite(&self) -> SageResult<bool> {
let result = self
.dispatch()
.call_method_by_name("CG_SaisieQuantite", &[])?
.to_i32()?;
Ok(result != 0)
}
pub fn cg_taux_taxe(&self) -> SageResult<f64> {
self.dispatch()
.call_method_by_name("CG_TauxTaxe", &[])?
.to_f64()
}
pub fn cg_code_taxe(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CG_CodeTaxe", &[])?
.to_string()
}
pub fn cg_reporting(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CG_Reporting", &[])?
.to_string()
}
pub fn cg_classement(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CG_Classement", &[])?
.to_string()
}
pub fn set_cg_num(&self, num: &str) -> SageResult<()> {
let num_variant = SafeVariant::from_string(num);
self.dispatch()
.call_property_put("CG_Num", &[num_variant])?;
Ok(())
}
pub fn set_cg_intitule(&self, intitule: &str) -> SageResult<()> {
let intitule_variant = SafeVariant::from_string(intitule);
self.dispatch()
.call_property_put("CG_Intitule", &[intitule_variant])?;
Ok(())
}
pub fn set_cg_type(&self, type_compte: i32) -> SageResult<()> {
let type_variant = SafeVariant::from_i32(type_compte);
self.dispatch()
.call_property_put("CG_Type", &[type_variant])?;
Ok(())
}
pub fn set_cg_niveau(&self, niveau: i32) -> SageResult<()> {
let niveau_variant = SafeVariant::from_i32(niveau);
self.dispatch()
.call_property_put("CG_Niveau", &[niveau_variant])?;
Ok(())
}
pub fn set_cg_sens_solde(&self, sens: i32) -> SageResult<()> {
let sens_variant = SafeVariant::from_i32(sens);
self.dispatch()
.call_property_put("CG_SensSolde", &[sens_variant])?;
Ok(())
}
pub fn set_cg_code_ifrs(&self, code_ifrs: &str) -> SageResult<()> {
let code_variant = SafeVariant::from_string(code_ifrs);
self.dispatch()
.call_property_put("CG_CodeIFRS", &[code_variant])?;
Ok(())
}
pub fn set_cg_compte_regroup(&self, compte_regroup: &str) -> SageResult<()> {
let compte_variant = SafeVariant::from_string(compte_regroup);
self.dispatch()
.call_property_put("CG_CompteRegroup", &[compte_variant])?;
Ok(())
}
pub fn set_cg_analytique(&self, analytique: i32) -> SageResult<()> {
let analytique_variant = SafeVariant::from_i32(analytique);
self.dispatch()
.call_property_put("CG_Analytique", &[analytique_variant])?;
Ok(())
}
pub fn set_cg_journala(&self, journala: &str) -> SageResult<()> {
let journala_variant = SafeVariant::from_string(journala);
self.dispatch()
.call_property_put("CG_JournalA", &[journala_variant])?;
Ok(())
}
pub fn set_cg_interrogation_tiers(&self, interrogation: i32) -> SageResult<()> {
let interrogation_variant = SafeVariant::from_i32(interrogation);
self.dispatch()
.call_property_put("CG_InterrogationTiers", &[interrogation_variant])?;
Ok(())
}
pub fn set_cg_lettrage(&self, lettrage: i32) -> SageResult<()> {
let lettrage_variant = SafeVariant::from_i32(lettrage);
self.dispatch()
.call_property_put("CG_Lettrage", &[lettrage_variant])?;
Ok(())
}
pub fn set_cg_saisie_analytique(&self, saisie: bool) -> SageResult<()> {
let saisie_variant = SafeVariant::from_bool(saisie);
self.dispatch()
.call_property_put("CG_SaisieAnalytique", &[saisie_variant])?;
Ok(())
}
pub fn set_cg_saisie_echeance(&self, saisie: bool) -> SageResult<()> {
let saisie_variant = SafeVariant::from_bool(saisie);
self.dispatch()
.call_property_put("CG_SaisieEcheance", &[saisie_variant])?;
Ok(())
}
pub fn set_cg_saisie_quantite(&self, saisie: bool) -> SageResult<()> {
let saisie_variant = SafeVariant::from_bool(saisie);
self.dispatch()
.call_property_put("CG_SaisieQuantite", &[saisie_variant])?;
Ok(())
}
pub fn set_cg_taux_taxe(&self, taux: f64) -> SageResult<()> {
let taux_variant = SafeVariant::R8(taux);
self.dispatch()
.call_property_put("CG_TauxTaxe", &[taux_variant])?;
Ok(())
}
pub fn set_cg_code_taxe(&self, code_taxe: &str) -> SageResult<()> {
let code_variant = SafeVariant::from_string(code_taxe);
self.dispatch()
.call_property_put("CG_CodeTaxe", &[code_variant])?;
Ok(())
}
pub fn set_cg_reporting(&self, reporting: &str) -> SageResult<()> {
let reporting_variant = SafeVariant::from_string(reporting);
self.dispatch()
.call_property_put("CG_Reporting", &[reporting_variant])?;
Ok(())
}
pub fn set_cg_classement(&self, classement: &str) -> SageResult<()> {
let classement_variant = SafeVariant::from_string(classement);
self.dispatch()
.call_property_put("CG_Classement", &[classement_variant])?;
Ok(())
}
pub fn is_persistant(&self) -> SageResult<bool> {
let result = self
.dispatch()
.call_method_by_name("IsPersistant", &[])?
.to_i32()?;
Ok(result != 0)
}
pub fn is_modified(&self) -> SageResult<bool> {
let result = self
.dispatch()
.call_method_by_name("IsModified", &[])?
.to_i32()?;
Ok(result != 0)
}
pub fn write(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Write", &[])?;
Ok(())
}
pub fn write_default(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("WriteDefault", &[])?;
Ok(())
}
pub fn read(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Read", &[])?;
Ok(())
}
pub fn remove(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Remove", &[])?;
Ok(())
}
pub fn set_default(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("SetDefault", &[])?;
Ok(())
}
pub fn refresh(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Refresh", &[])?;
Ok(())
}
}
impl Clone for CompteG {
fn clone(&self) -> Self {
Self {
dispatch: self.dispatch.clone(),
}
}
}
impl PartialEq for CompteG {
fn eq(&self, other: &Self) -> bool {
match (self.cg_num(), other.cg_num()) {
(Ok(num1), Ok(num2)) => num1 == num2,
_ => false,
}
}
}
impl FromDispatchNew for CompteG {
fn from_dispatch_new(dispatch: IDispatch) -> SageResult<Self> {
Ok(Self { dispatch })
}
}