pub struct GlVoucherRepository;Expand description
The GL reconcile’s SQL. Stateless: it holds no pool, because both methods run outside the movement’s transaction — the physical movement is already committed by the time a post is emitted, and the reconcile is deliberately a separate write (the GL leg is eventually consistent).
Implementations§
Source§impl GlVoucherRepository
impl GlVoucherRepository
pub fn new() -> Self
Sourcepub async fn mark_posted(
&self,
pool: &PgPool,
voucher: GlVoucher,
voucher_id: Uuid,
journal_id: Uuid,
post_id: Uuid,
) -> Result<(), Error>
pub async fn mark_posted( &self, pool: &PgPool, voucher: GlVoucher, voucher_id: Uuid, journal_id: Uuid, post_id: Uuid, ) -> Result<(), Error>
Reconcile a voucher from the accounting ack — the pending→posted transition.
Guarded on posting_state <> 'posted' so a repost of an already-posted voucher cannot
overwrite the original journal’s ids: accounting dedupes on
(source_type, source_id, posting_type) and hands back the ORIGINAL journal, and this guard
is what keeps the recorded ids stable through that.
Runs org_scope::execute_scoped on the pool — the write rides the ambient org scope’s
request-dedicated connection so it passes the composing decorator’s fence (ADR-0029).
Undecorated (module tests) the UPDATE runs plain.
Sourcepub async fn mark_failed(
&self,
pool: &PgPool,
voucher: GlVoucher,
voucher_id: Uuid,
) -> Result<(), Error>
pub async fn mark_failed( &self, pool: &PgPool, voucher: GlVoucher, voucher_id: Uuid, ) -> Result<(), Error>
Record a GL rejection. The physical movement is NOT rolled back — it really happened; the
voucher parks in failed and is re-drivable via the service’s repost_* entrypoints.
Same scoped-execute discipline as Self::mark_posted.
Sourcepub async fn mark_reversal_posted(
&self,
pool: &PgPool,
voucher: GlVoucher,
voucher_id: Uuid,
journal_id: Uuid,
post_id: Uuid,
) -> Result<(), Error>
pub async fn mark_reversal_posted( &self, pool: &PgPool, voucher: GlVoucher, voucher_id: Uuid, journal_id: Uuid, post_id: Uuid, ) -> Result<(), Error>
Record the GL REVERSAL post for a cancelled voucher (council 2026-07-29, #3).
Distinct from Self::mark_posted: the original post is already posted with its own
journal_id/accounting_post_id (which stay intact — the original really happened). A
cancellation appends compensating SLEs and emits a posting_type='reversal' post; that
reversal’s ids land in reversal_journal_id/reversal_accounting_post_id. There is no
posting_state guard here — the reversal is recorded regardless of the original’s state.
Sourcepub async fn mark_not_applicable(
&self,
pool: &PgPool,
voucher: GlVoucher,
voucher_id: Uuid,
) -> Result<(), Error>
pub async fn mark_not_applicable( &self, pool: &PgPool, voucher: GlVoucher, voucher_id: Uuid, ) -> Result<(), Error>
Retire a voucher’s GL leg to not_applicable — the document genuinely posts no GL under
the current configuration. Two users: a landed-cost validation whose entire allocation
fell on already-consumed stock (Σ remaining-share δ = 0: nothing to revalue, nothing to
post), and a valuation_policy='periodic' posture whose real-time stock posts are
suppressed (the periodic closing flow — a later increment — owns those legs). Idempotent:
re-marking an already-retired voucher is a no-op. Same scoped-execute discipline as
Self::mark_posted.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GlVoucherRepository
impl RefUnwindSafe for GlVoucherRepository
impl Send for GlVoucherRepository
impl Sync for GlVoucherRepository
impl Unpin for GlVoucherRepository
impl UnsafeUnpin for GlVoucherRepository
impl UnwindSafe for GlVoucherRepository
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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