pub struct PayrollWriteService { /* private fields */ }Implementations§
Source§impl PayrollWriteService
impl PayrollWriteService
pub fn new(pool: PgPool) -> Self
Sourcepub fn with_overtime_inputs(self, inputs: Box<dyn OvertimeInputs>) -> Self
pub fn with_overtime_inputs(self, inputs: Box<dyn OvertimeInputs>) -> Self
Override where overtime hours come from (default: the pool read mirroring attendance’s export).
Sourcepub fn set_timesheet_inputs(&self, inputs: Arc<dyn ApprovedTimesheetInputs>)
pub fn set_timesheet_inputs(&self, inputs: Arc<dyn ApprovedTimesheetInputs>)
Wire the approved-timesheet input port (the composing app’s adapter when it wants the SQL in one place; the pool default reads the timesheet tables directly under the fence).
Sourcepub fn with_employee_inputs(
self,
inputs: Box<dyn EmployeeStatutoryInputs>,
) -> Self
pub fn with_employee_inputs( self, inputs: Box<dyn EmployeeStatutoryInputs>, ) -> Self
Override where employee statutory facts come from (default: the pool read mirroring the employee module’s export).
Sourcepub fn with_gl_sink(self, sink: Arc<dyn GlPostSink>) -> Self
pub fn with_gl_sink(self, sink: Arc<dyn GlPostSink>) -> Self
Override the GL-posting seam (default UnwiredGlSink — post refuses with
gl_seam_unwired).
Sourcepub fn with_event_sink(self, sink: Arc<dyn PayrollEventSink>) -> Self
pub fn with_event_sink(self, sink: Arc<dyn PayrollEventSink>) -> Self
Override the domain-event sink (default LoggingSink). A durable composition stages into
an outbox here.
Sourcepub fn with_remit_sink(self, sink: Arc<dyn RemittanceSink>) -> Self
pub fn with_remit_sink(self, sink: Arc<dyn RemittanceSink>) -> Self
Override the remittance seam (default UnwiredRemittance — remit refuses with
remittance_seam_unwired).
Sourcepub async fn post_run(
&self,
run_id: Uuid,
posting_date: NaiveDate,
) -> Result<PostOutcome, PayrollError>
pub async fn post_run( &self, run_id: Uuid, posting_date: NaiveDate, ) -> Result<PostOutcome, PayrollError>
Post through the module-held GL + event seams — the composition-root convenience over
Self::post_payroll_entry (which stays public for callers supplying their own sinks,
e.g. tests driving a real accounting adapter).
Sourcepub async fn remit_run(
&self,
run_id: Uuid,
) -> Result<RemitOutcome, PayrollError>
pub async fn remit_run( &self, run_id: Uuid, ) -> Result<RemitOutcome, PayrollError>
Remit through the module-held remittance seam — the composition-root convenience over
Self::remit_payroll_entry.
Sourcepub async fn create_structure(
&self,
s: NewStructure,
) -> Result<Uuid, PayrollError>
pub async fn create_structure( &self, s: NewStructure, ) -> Result<Uuid, PayrollError>
Define a salary structure with its earning/deduction components.
Sourcepub async fn create_payroll_entry(
&self,
e: NewPayrollEntry,
) -> Result<Uuid, PayrollError>
pub async fn create_payroll_entry( &self, e: NewPayrollEntry, ) -> Result<Uuid, PayrollError>
Open a payroll run for a period (draft). Unique per (org unit, year, month) once the composing service’s tenancy decorator has re-declared the run unique org-scoped.
Sourcepub async fn add_salary_slip(
&self,
run_id: Uuid,
s: NewSalarySlip,
) -> Result<Uuid, PayrollError>
pub async fn add_salary_slip( &self, run_id: Uuid, s: NewSalarySlip, ) -> Result<Uuid, PayrollError>
Add an employee’s slip to a DRAFT run. Earnings come from the structure, prorated by unpaid days
(gross = Σ earning · (working − unpaid)/working); fixed + supplied statutory deductions subtract.
net = gross − deductions and must be non-negative.
Sourcepub async fn add_computed_salary_slip(
&self,
r: ComputedSlipRequest,
) -> Result<Uuid, PayrollError>
pub async fn add_computed_salary_slip( &self, r: ComputedSlipRequest, ) -> Result<Uuid, PayrollError>
Build one employee’s slip end-to-end: period → effective statutory params → employee facts →
TER/bracket dispatch → overtime pay → the same Self::add_salary_slip write path a manual
caller uses. The statutory base is the structure’s un-prorated monthly earning total (the
salary being paid); overtime pay rides in as an ordinary earning line so gross stays balanced
through the existing journal.
Sourcepub async fn process_payroll_entry(
&self,
run_id: Uuid,
) -> Result<(), PayrollError>
pub async fn process_payroll_entry( &self, run_id: Uuid, ) -> Result<(), PayrollError>
Roll the run’s slips up into its totals and move draft → processed (ready to post).
Sourcepub async fn render_slip_pdf(
&self,
slip_id: Uuid,
) -> Result<Vec<u8>, PayrollError>
pub async fn render_slip_pdf( &self, slip_id: Uuid, ) -> Result<Vec<u8>, PayrollError>
Post the processed run to the GL — the 8th producer. Builds ONE balanced posting
(Dr Salary Expense (gross) · Cr Salary Payable (net) · Cr Σ deduction-account), drives the
GlPostSink (idempotent per run), then transition-gates processed → posted with the journal.
Posts at most once. Emits PayrollPosted.
Render one slip as a PDF (#553). Published-run gated like the
self-service read: a slip on a draft or processed run is an
internal draft, not a promise to the employee.
Sourcepub async fn cancel_payroll_entry(
&self,
run_id: Uuid,
) -> Result<bool, PayrollError>
pub async fn cancel_payroll_entry( &self, run_id: Uuid, ) -> Result<bool, PayrollError>
Cancel a run that has not left draft (#605): the month opens for a
fresh run, the slips go with it. Only draft may cancel (posted
history is immutable — reverse, don’t delete); idempotent on an
already-cancelled row.
pub async fn post_payroll_entry( &self, run_id: Uuid, posting_date: NaiveDate, sink: &dyn GlPostSink, events: &dyn PayrollEventSink, ) -> Result<PostOutcome, PayrollError>
Sourcepub async fn remit_payroll_entry(
&self,
run_id: Uuid,
sink: &dyn RemittanceSink,
) -> Result<RemitOutcome, PayrollError>
pub async fn remit_payroll_entry( &self, run_id: Uuid, sink: &dyn RemittanceSink, ) -> Result<RemitOutcome, PayrollError>
Remit a posted run’s payables — one instruction per deduction account, each carrying the
stable payroll_remittance:{company}:{run}:{account} idempotency key so retries dedup at
the sink (the company segment is the legacy tenancy twin echo, ADR-0029 — stable per unit
under a composing service, nil undecorated). Requires posted (an unposted run has no
settled obligations to pay). Payee resolution is the composing host’s adapter, never
payroll’s.
Auto Trait Implementations§
impl !Freeze for PayrollWriteService
impl !RefUnwindSafe for PayrollWriteService
impl !UnwindSafe for PayrollWriteService
impl Send for PayrollWriteService
impl Sync for PayrollWriteService
impl Unpin for PayrollWriteService
impl UnsafeUnpin for PayrollWriteService
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