pub struct TaxReturnGenerator { /* private fields */ }Expand description
Aggregates tax lines into periodic tax returns by jurisdiction.
For each unique jurisdiction_id found in the input lines, the generator
sums output tax (from TaxableDocumentType::CustomerInvoice lines) and
input tax (from deductible TaxableDocumentType::VendorInvoice lines),
then produces a single TaxReturn per jurisdiction.
All indirect tax lines (VAT, GST, sales tax) produce
TaxReturnType::VatReturn returns.
Filing behavior:
- ~95% of returns are filed on time.
- ~5% remain in
TaxReturnStatus::Draft. - ~2% of filed returns are filed late (after the deadline).
Implementations§
Source§impl TaxReturnGenerator
impl TaxReturnGenerator
Sourcepub fn new(seed: u64) -> Self
pub fn new(seed: u64) -> Self
Creates a new tax return generator with the given deterministic seed.
Sourcepub fn generate(
&mut self,
entity_id: &str,
tax_lines: &[TaxLine],
period_start: NaiveDate,
period_end: NaiveDate,
filing_deadline: NaiveDate,
) -> Vec<TaxReturn>
pub fn generate( &mut self, entity_id: &str, tax_lines: &[TaxLine], period_start: NaiveDate, period_end: NaiveDate, filing_deadline: NaiveDate, ) -> Vec<TaxReturn>
Aggregate tax lines into returns by jurisdiction and period.
Groups lines by jurisdiction_id, then sums:
- output tax (from
CustomerInvoicelines) - input tax (from
VendorInvoicelines whereis_deductible == true) net_payable = output_tax - input_tax
Creates one TaxReturn per jurisdiction per period.
Auto Trait Implementations§
impl Freeze for TaxReturnGenerator
impl RefUnwindSafe for TaxReturnGenerator
impl Send for TaxReturnGenerator
impl Sync for TaxReturnGenerator
impl Unpin for TaxReturnGenerator
impl UnsafeUnpin for TaxReturnGenerator
impl UnwindSafe for TaxReturnGenerator
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
Mutably borrows from an owned value. Read more
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.