summaryrefslogtreecommitdiff
path: root/LedgerSMB/Taxes/Simple.pm
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-08 20:47:38 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-08 20:47:38 +0000
commit68399771603d9a2d084a9eaca480f17016801fe6 (patch)
tree02859ae3e2743f8b141a9837f703c21d77651759 /LedgerSMB/Taxes/Simple.pm
parent7376ef357ac4dce6bf30548c773774dddd2ea033 (diff)
First round of tax code replacement, adds cumulative tax support
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@195 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Taxes/Simple.pm')
-rwxr-xr-xLedgerSMB/Taxes/Simple.pm64
1 files changed, 64 insertions, 0 deletions
diff --git a/LedgerSMB/Taxes/Simple.pm b/LedgerSMB/Taxes/Simple.pm
new file mode 100755
index 00000000..57777be4
--- /dev/null
+++ b/LedgerSMB/Taxes/Simple.pm
@@ -0,0 +1,64 @@
+#=====================================================================
+#
+# Simple Tax support module for LedgerSMB
+# Taxes::Simple
+# Default simple tax application
+#
+# LedgerSMB
+# Small Medium Business Accounting software
+# http://www.ledgersmb.org/
+#
+#
+# Copyright (C) 2006
+# This work contains copyrighted information from a number of sources all used
+# with permission. It is released under the GNU General Public License
+# Version 2 or, at your option, any later version. See COPYRIGHT file for
+# details.
+#
+#
+#======================================================================
+# This package contains tax related functions:
+#
+# calculate_tax - calculates tax on subtotal
+# apply_tax - sets $value to the tax value for the subtotal
+# extract_tax - sets $value to the tax value on a tax-included subtotal
+#
+#====================================================================
+package Taxes::Simple;
+
+use Class::Struct;
+use Math::BigFloat;
+
+struct Taxes::Simple => {
+ taxnumber => '$',
+ description => '$',
+ rate => 'Math::BigFloat',
+ chart => '$',
+ account => '$',
+ value => 'Math::BigFloat',
+ pass => '$'
+};
+
+sub calculate_tax {
+ my ($self, $form, $subtotal, $extract, $passrate) = @_;
+ my $rate = $self->rate;
+ my $tax = $subtotal * $rate / (Math::BigFloat->bone() + $passrate);
+ $tax = $subtotal * $rate if not $extract;
+ return $tax;
+}
+
+sub apply_tax {
+ my ($self, $form, $subtotal) = @_;
+ my $tax = $self->calculate_tax($form, $subtotal, 0);
+ $self->value($tax);
+ return $tax;
+}
+
+sub extract_tax {
+ my ($self, $form, $subtotal, $passrate) = @_;
+ my $tax = $self->calculate_tax($form, $subtotal, 1, $passrate);
+ $self->value($tax);
+ return $tax;
+}
+
+1;