Business-RO-TaxDeduction

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Business-RO-TaxDeduction

0.012   2018-03-04
        Update for 2018 - OUG79/2017.
        No more an official formula for calculating the tax deduction,
        so the module is using (hash) tables for 2018.

0.011   2017-08-15
        Bugfix release.
        Fix for "Invalid coerce '1'".

0.010   2016-06-05
        Add year attribute, now it can make calculations for 2005 -:-
        2015 using the formulas from OMFP 1016/2005 and for 2016 using
        formular from OMFP 52/2016.

0.007   2016-04-21
        Update for 2016 - OMFP52/2016

0.006   2015-10-28
        Refactor round to tens method, add PODs.

0.005   2015-06-13
        Build with dzil.

README.md  view on Meta::CPAN

Business-RO-TaxDeduction
========================
Ștefan Suciu
2018-03-04

Version: 0.012

A Romanian salary tax deduction calculator.

Updated for 2018, but unfortunately there is no more an official
formula for calculating the tax deduction, so the module is using
tables for returning the correct (I hope) amount.

Starting with the v0.010 version, there is a new optional `year`
parameter that can be used to choose between the current regulations
(OMFP 52/2016), or the previous - OMFP 1016/2005.

This is an alternative to the database driven implementation for the
tax deductions calculation.  It may be suitable for small programs or
even for oneliners line this:

lib/Business/RO/TaxDeduction.pm  view on Meta::CPAN

    my $self   = shift;
    my $vbl    = $self->_round_to_int( $self->vbl );

    return $self->_amount_for_2018 if $self->year >= 2018;

    my $amount = $self->deduction->amount;
    if ( $vbl <= $self->vbl_min ) {
        return $amount;
    }
    elsif ( ( $vbl > $self->vbl_min ) && ( $vbl <= $self->vbl_max ) ) {
        $amount = $self->_tax_deduction_formula($vbl, $amount);
        return ( blessed $amount ) ? $amount->bstr : $amount;
    }
    else {
        return 0;               # 0 for VBL > vbl_max
    }
}

sub _tax_deduction_formula {
    my ( $self, $vbl, $base_deduction ) = @_;
    my $amount = $base_deduction * ( 1 - ( $vbl - $self->f_min ) / $self->f_max );
    return $self->_round_to_tens($amount);
}

sub _round_to_int {
    my ( $self, $amount ) = @_;
    return int( $amount + 0.5 * ( $amount <=> 0 ) );
}

lib/Business/RO/TaxDeduction.pm  view on Meta::CPAN


=head2 INSTANCE METHODS

=head3 tax_deduction

Return the deduction calculated for the given amount.

Starting with the current version (0.004) the appropriate algorithm
for the tax deduction calculation year is chosen.

=head3 _tax_deduction_formula

Formula for calculating the tax deduction for amounts above C<vbl_min>
and less or equal to C<vbl_max>.

=head3 _round_to_int

Custom rounding method to the nearest integer.  It uses the Romanian
standard for rounding in bookkeeping.

Example:

lib/Business/RO/TaxDeduction/Ranges.pm  view on Meta::CPAN

        year => $year,
    );
    my $vbl_min = $tdr->vbl_min;
    my $vbl_max = $tdr->vbl_max;
    my $f_min   = $tdr->f_min;
    my $f_max   = $tdr->f_max;

=head1 DESCRIPTION

Data module.  This module holds data used in the tax deduction
formula.

NOTE: No tax deduction formula for 2018.

=head1 INTERFACE

=head2 ATTRIBUTES

=head3 vbl_min

The minimum amount (VBL) used in the tax deduction formula.

=head3 vbl_max

The maximum amount (VBL) used in the tax deduction formula.

=head3 f_min

The amount used in the tax deduction formula:

    250 x [ 1 - ( VBL - $f_min=1000 ) / 2000 ]  # 2005
    300 x [ 1 - ( VBL - $f_min=1500 ) / 1500 ]  # 2016

=head3 f_max

The amount used in the tax deduction formula:

    250 x [ 1 - ( VBL - 1000 ) / $f_max=2000 ]  # 2005
    300 x [ 1 - ( VBL - 1500 ) / $f_max=1500 ]  # 2016

=head2 INSTANCE METHODS

=head1 AUTHOR

Ștefan Suciu <stefan@s2i2.ro>



( run in 2.642 seconds using v1.01-cache-2.11-cpan-3cd7ad12f66 )