pub struct Fund {
pub id: Uuid,
pub acp_id: Uuid,
pub kind: FundKind,
pub name: String,
pub purpose: Option<String>,
pub target_amount: Option<Decimal>,
pub balance: Decimal,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Fonds de l’ACP — roulement, réserve légale, ou affecté (thésaurisation).
Fields§
§id: Uuid§acp_id: Uuid§kind: FundKind§name: String§purpose: Option<String>Objet précis du chantier — uniquement pour FundKind::Earmarked.
target_amount: Option<Decimal>Objectif d’épargne — uniquement pour FundKind::Earmarked.
balance: Decimal§created_at: DateTime<Utc>§updated_at: DateTime<Utc>Implementations§
Source§impl Fund
impl Fund
Sourcepub fn new(
acp_id: Uuid,
kind: FundKind,
name: String,
purpose: Option<String>,
target_amount: Option<Decimal>,
) -> Result<Self, FundError>
pub fn new( acp_id: Uuid, kind: FundKind, name: String, purpose: Option<String>, target_amount: Option<Decimal>, ) -> Result<Self, FundError>
Crée un fonds de roulement ou de réserve (pas d’objet, pas
d’objectif). Pour un fonds affecté, voir Fund::new_earmarked.
Sourcepub fn new_earmarked(
acp_id: Uuid,
name: String,
purpose: String,
target_amount: Decimal,
majority_used: MajorityType,
) -> Result<Self, FundError>
pub fn new_earmarked( acp_id: Uuid, name: String, purpose: String, target_amount: Decimal, majority_used: MajorityType, ) -> Result<Self, FundError>
Crée un fonds affecté, en exigeant la majorité des gros travaux (2/3, Art. 3.88 §1, 1°, b).
@security (story #635) : créer un fonds fléché à la majorité simple contournerait la majorité qui protège les copropriétaires du chantier lui-même.
Sourcepub fn contribute(&mut self, amount: Decimal) -> Result<(), FundError>
pub fn contribute(&mut self, amount: Decimal) -> Result<(), FundError>
Alimente le fonds. Le solde ne se confond avec aucun autre fonds :
chaque Fund porte le sien.
Sourcepub fn progress(&self) -> Option<Decimal>
pub fn progress(&self) -> Option<Decimal>
Progression de l’épargne vers l’objectif (balance / target_amount).
None pour un fonds sans objectif (roulement/réserve) ou à objectif
nul.
Sourcepub fn reliquat(&self) -> Option<Decimal>
pub fn reliquat(&self) -> Option<Decimal>
Le reliquat : ce que le fonds a accumulé au-delà de son objectif, une fois celui-ci atteint (chantier terminé sous budget).
None tant que l’objectif n’est pas dépassé, ou pour un fonds sans
objectif (roulement/réserve).
Sourcepub fn assert_expense_matches_purpose(
&self,
expense_work_ref: &str,
ag_override: Option<ResolutionStatus>,
) -> Result<(), FundError>
pub fn assert_expense_matches_purpose( &self, expense_work_ref: &str, ag_override: Option<ResolutionStatus>, ) -> Result<(), FundError>
Autorise (ou refuse) une dépense imputée à ce fonds pour l’objet
expense_work_ref.
Seul un fonds affecté restreint ainsi ses dépenses — roulement et
réserve n’ont pas d’objet unique à comparer. ag_override lève la
restriction quand il vaut Some(ResolutionStatus::Adopted) : « ne
jamais bloquer une dépense au seul motif que le fonds était fléché
ailleurs, dès lors qu’une décision d’AG l’autorise » (PO @gilmry).
Sourcepub fn reassign(
&mut self,
new_purpose: String,
amount: Option<Decimal>,
resolution_id: Uuid,
resolution_status: ResolutionStatus,
) -> Result<FundReassignment, FundError>
pub fn reassign( &mut self, new_purpose: String, amount: Option<Decimal>, resolution_id: Uuid, resolution_status: ResolutionStatus, ) -> Result<FundReassignment, FundError>
Réaffecte tout ou partie du solde de ce fonds affecté vers une autre
fin, sur décision d’AG adoptée. Retourne l’audit trail
(FundReassignment) tracant l’affectation d’origine.
amount = None réaffecte la TOTALITÉ du solde disponible : le fonds
sert alors intégralement la nouvelle fin (purpose change).
amount = Some(x) avec x strictement inférieur au solde ne
réaffecte qu’une partie : le reliquat continue de servir l’objet
d’origine. Si x égale le solde entier, le résultat est le même que
la totalité.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Fund
impl<'de> Deserialize<'de> for Fund
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Fund
Auto Trait Implementations§
impl Freeze for Fund
impl RefUnwindSafe for Fund
impl Send for Fund
impl Sync for Fund
impl Unpin for Fund
impl UnsafeUnpin for Fund
impl UnwindSafe for Fund
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more