Skip to main content

GlVoucherRepository

Struct GlVoucherRepository 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Default for GlVoucherRepository

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more