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