pub struct ValuationOverlayRepository;Expand description
Hand-owned SQL for the valuation overlay. Stateless (methods take the caller’s connection or
run scoped on the pool), mirroring super::GlVoucherRepository.
Implementations§
Source§impl ValuationOverlayRepository
impl ValuationOverlayRepository
pub fn new() -> Self
Sourcepub async fn fetch_posture(
&self,
pool: &PgPool,
) -> Result<Option<PostureRow>, Error>
pub async fn fetch_posture( &self, pool: &PgPool, ) -> Result<Option<PostureRow>, Error>
Read the caller’s org-unit valuation settings row. None when the org unit has no row
— the caller applies the runtime defaults (average / perpetual / anglo off), which
makes rolling the module out a no-op for tenants that never configure it.
Sourcepub async fn fetch_posture_on(
&self,
conn: &mut PgConnection,
) -> Result<Option<PostureRow>, Error>
pub async fn fetch_posture_on( &self, conn: &mut PgConnection, ) -> Result<Option<PostureRow>, Error>
The same posture read on the CALLER’S connection — the variant the move engine uses inside its open movement transaction (the ambient org scope is already bound there, so the fenced read is correct without opening a second transaction).
Sourcepub async fn fetch_location_valuation_override(
&self,
pool: &PgPool,
location_id: Uuid,
) -> Result<Option<Uuid>, Error>
pub async fn fetch_location_valuation_override( &self, pool: &PgPool, location_id: Uuid, ) -> Result<Option<Uuid>, Error>
A location’s valuation-account override, when set. None = no override (the caller
falls through to the door-header account).
The read runs org-scoped: locations are shared masters under the composition’s root-shared fence, so a scoped read resolves the override for tenant-specific and shared locations alike.
Sourcepub async fn fetch_item_weight(
&self,
conn: &mut PgConnection,
item_id: Uuid,
) -> Result<Decimal, Error>
pub async fn fetch_item_weight( &self, conn: &mut PgConnection, item_id: Uuid, ) -> Result<Decimal, Error>
The per-unit shipping weight of one stock item (0 = unweighted; the weight basis of a landed-cost split — an all-zero weight basis is the loud zero-denominator case).
Sourcepub async fn fetch_lc_header(
&self,
conn: &mut PgConnection,
lc_id: Uuid,
) -> Result<Option<LcHeaderRow>, Error>
pub async fn fetch_lc_header( &self, conn: &mut PgConnection, lc_id: Uuid, ) -> Result<Option<LcHeaderRow>, Error>
Read one landed-cost header.
Sourcepub async fn fetch_lc_lines(
&self,
conn: &mut PgConnection,
lc_id: Uuid,
) -> Result<Vec<LcLineRow>, Error>
pub async fn fetch_lc_lines( &self, conn: &mut PgConnection, lc_id: Uuid, ) -> Result<Vec<LcLineRow>, Error>
Read the landed cost’s charge lines.
Sourcepub async fn insert_landed_cost_draft(
&self,
conn: &mut PgConnection,
lc: &NewLandedCostRow<'_>,
) -> Result<(), Error>
pub async fn insert_landed_cost_draft( &self, conn: &mut PgConnection, lc: &NewLandedCostRow<'_>, ) -> Result<(), Error>
Insert a draft landed-cost header. posting_state starts not_applicable: a draft has
no GL leg; validation arms pending in the same transaction that mints the revaluation
SLE rows (the move-engine arming pattern).
Sourcepub async fn insert_lc_line(
&self,
conn: &mut PgConnection,
l: &NewLcLineRow<'_>,
) -> Result<(), Error>
pub async fn insert_lc_line( &self, conn: &mut PgConnection, l: &NewLcLineRow<'_>, ) -> Result<(), Error>
Insert one cost line of a draft landed cost.
Sourcepub async fn fetch_lc_target_receipt(
&self,
conn: &mut PgConnection,
receipt_id: Uuid,
) -> Result<Option<LcTargetReceiptRow>, Error>
pub async fn fetch_lc_target_receipt( &self, conn: &mut PgConnection, receipt_id: Uuid, ) -> Result<Option<LcTargetReceiptRow>, Error>
The target receipt of a landed cost, as its validation reads it: the receipt number the
door stamped as origin on every line move, the header inventory account (the fallback
of the debit leg’s account-resolution chain), and the status (a landed cost only ever
targets a receipt whose moves are DONE; the service derives that from the moves
themselves). Takes the caller’s connection.
Sourcepub async fn mark_lc_validated(
&self,
conn: &mut PgConnection,
lc_id: Uuid,
amount_total: Decimal,
) -> Result<(), Error>
pub async fn mark_lc_validated( &self, conn: &mut PgConnection, lc_id: Uuid, amount_total: Decimal, ) -> Result<(), Error>
Flip a draft landed cost to done and arm its GL leg pending — one transaction
together with the revaluation SLE rows the engine verb minted before this call inside
the caller’s unit of work. amount_total is the document’s Σ cost amounts.
Sourcepub async fn mark_lc_cancelled(
&self,
conn: &mut PgConnection,
lc_id: Uuid,
) -> Result<(), Error>
pub async fn mark_lc_cancelled( &self, conn: &mut PgConnection, lc_id: Uuid, ) -> Result<(), Error>
Cancel a DRAFT landed cost (a done one can never cancel — the reversal pattern is a
negative-amount landed cost). A draft posted no GL, so its posting state retires to
not_applicable.
Sourcepub async fn delete_worksheet(
&self,
conn: &mut PgConnection,
lc_id: Uuid,
) -> Result<(), Error>
pub async fn delete_worksheet( &self, conn: &mut PgConnection, lc_id: Uuid, ) -> Result<(), Error>
Delete the landed cost’s worksheet rows. The worksheet is a RECOMPUTE SURFACE, not a ledger: every (re)validation deletes and recreates it wholesale. The only accounting identity is the posted journal entry.
Sourcepub async fn insert_worksheet_row(
&self,
conn: &mut PgConnection,
w: &NewWorksheetRow,
) -> Result<(), Error>
pub async fn insert_worksheet_row( &self, conn: &mut PgConnection, w: &NewWorksheetRow, ) -> Result<(), Error>
Insert one worksheet row (the caller writes them ordered by move_line_id so the
last-line-eats-the-rounding-diff recipient is deterministic).
Sourcepub async fn fetch_worksheet(
&self,
conn: &mut PgConnection,
lc_id: Uuid,
) -> Result<Vec<WorksheetRow>, Error>
pub async fn fetch_worksheet( &self, conn: &mut PgConnection, lc_id: Uuid, ) -> Result<Vec<WorksheetRow>, Error>
Read the landed cost’s worksheet back (tests + GL repost reconstruction).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ValuationOverlayRepository
impl RefUnwindSafe for ValuationOverlayRepository
impl Send for ValuationOverlayRepository
impl Sync for ValuationOverlayRepository
impl Unpin for ValuationOverlayRepository
impl UnsafeUnpin for ValuationOverlayRepository
impl UnwindSafe for ValuationOverlayRepository
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