[freeside-commits] freeside/FS/FS Schema.pm, 1.145, 1.146 cust_bill.pm, 1.245, 1.246 cust_bill_pkg.pm, 1.34, 1.35 Conf.pm, 1.292, 1.293 AccessRight.pm, 1.38, 1.39 cust_main.pm, 1.434, 1.435 cust_tax_adjustment.pm, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Wed Jun 24 18:28:55 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv28555/FS/FS
Modified Files:
Schema.pm cust_bill.pm cust_bill_pkg.pm Conf.pm AccessRight.pm
cust_main.pm
Added Files:
cust_tax_adjustment.pm
Log Message:
tax adjustments, RT#5595
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.292
retrieving revision 1.293
diff -u -d -r1.292 -r1.293
--- Conf.pm 22 Jun 2009 10:06:11 -0000 1.292
+++ Conf.pm 25 Jun 2009 01:28:53 -0000 1.293
@@ -2851,6 +2851,13 @@
],
},
+ {
+ 'key' => 'enable_tax_adjustments',
+ 'section' => 'billing',
+ 'description' => 'Enable the ability to add manual tax adjustments.',
+ 'type' => 'checkbox',
+ },
+
);
1;
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.434
retrieving revision 1.435
diff -u -d -r1.434 -r1.435
--- cust_main.pm 22 Jun 2009 17:00:57 -0000 1.434
+++ cust_main.pm 25 Jun 2009 01:28:53 -0000 1.435
@@ -41,6 +41,7 @@
use FS::cust_main_county;
use FS::cust_location;
use FS::cust_main_exemption;
+use FS::cust_tax_adjustment;
use FS::tax_rate;
use FS::tax_rate_location;
use FS::cust_tax_location;
@@ -2661,6 +2662,35 @@
}
+ #add tax adjustments
+ warn "adding tax adjustments...\n" if $DEBUG > 2;
+ foreach my $cust_tax_adjustment (
+ qsearch('cust_tax_adjustment', { 'custnum' => $self->custnum,
+ 'billpkgnum' => '',
+ }
+ )
+ ) {
+
+ my $tax = sprintf('%.2f', $cust_tax_adjustment->amount );
+ $total_setup = sprintf('%.2f', $total_setup+$tax );
+
+ my $itemdesc = $cust_tax_adjustment->taxname;
+ $itemdesc = '' if $itemdesc eq 'Tax';
+
+ push @cust_bill_pkg, new FS::cust_bill_pkg {
+ 'pkgnum' => 0,
+ 'setup' => $tax,
+ 'recur' => 0,
+ 'sdate' => '',
+ 'edate' => '',
+ 'itemdesc' => $itemdesc,
+ 'itemcomment' => $cust_tax_adjustment->comment,
+ 'cust_tax_adjustment' => $cust_tax_adjustment,
+ #'cust_bill_pkg_tax_location' => \@cust_bill_pkg_tax_location,
+ };
+
+ }
+
my $charged = sprintf('%.2f', $total_setup + $total_recur );
#create the new invoice
--- NEW FILE: cust_tax_adjustment.pm ---
package FS::cust_tax_adjustment;
use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );
use FS::cust_main;
use FS::cust_bill_pkg;
=head1 NAME
FS::cust_tax_adjustment - Object methods for cust_tax_adjustment records
=head1 SYNOPSIS
use FS::cust_tax_adjustment;
$record = new FS::cust_tax_adjustment \%hash;
$record = new FS::cust_tax_adjustment { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
=head1 DESCRIPTION
An FS::cust_tax_adjustment object represents an taxation adjustment.
FS::cust_tax_adjustment inherits from FS::Record. The following fields are
currently supported:
=over 4
=item adjustmentnum
primary key
=item custnum
custnum
=item taxname
taxname
=item amount
amount
=item comment
comment
=item billpkgnum
billpkgnum
=back
=head1 METHODS
=over 4
=item new HASHREF
Creates a new record. To add the record to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
=cut
# the new method can be inherited from FS::Record, if a table method is defined
sub table { 'cust_tax_adjustment'; }
=item insert
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
=cut
# the insert method can be inherited from FS::Record
=item delete
Delete this record from the database.
=cut
# the delete method can be inherited from FS::Record
=item replace OLD_RECORD
Replaces the OLD_RECORD with this one in the database. If there is an error,
returns the error, otherwise returns false.
=cut
# the replace method can be inherited from FS::Record
=item check
Checks all fields to make sure this is a valid record. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
=cut
# the check method should currently be supplied - FS::Record contains some
# data checking routines
sub check {
my $self = shift;
my $error =
$self->ut_numbern('adjustmentnum')
|| $self->ut_foreign_key('custnum', 'cust_main', 'custnum' )
|| $self->ut_text('taxname')
|| $self->ut_money('amount')
|| $self->ut_textn('comment')
|| $self->ut_foreign_keyn('billpkgnum', 'cust_bill_pkg', 'billpkgnum' )
;
return $error if $error;
$self->SUPER::check;
}
sub cust_bill_pkg {
my $self = shift;
qsearchs('cust_bill_pkg', { 'billpkgnum' => $self->billpkgnum } );
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
=cut
1;
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -d -r1.245 -r1.246
--- cust_bill.pm 10 Jun 2009 21:58:30 -0000 1.245
+++ cust_bill.pm 25 Jun 2009 01:28:53 -0000 1.246
@@ -1457,11 +1457,9 @@
} else { #pkgnum tax
next unless $cust_bill_pkg->setup != 0;
- my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc')
- ? ( $cust_bill_pkg->itemdesc || 'Tax' )
- : 'Tax';
- ($pkg, $setup, $recur, $sdate, $edate) =
- ( $itemdesc, sprintf("%10.2f",$cust_bill_pkg->setup), '', '', '' );
+ $pkg = $cust_bill_pkg->desc;
+ $setup = sprintf('%10.2f', $cust_bill_pkg->setup );
+ ( $sdate, $edate ) = ( '', '' );
}
$csv->combine(
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -d -r1.145 -r1.146
--- Schema.pm 22 Jun 2009 07:50:18 -0000 1.145
+++ Schema.pm 25 Jun 2009 01:28:53 -0000 1.146
@@ -513,6 +513,7 @@
'sdate', @date_type, '', '',
'edate', @date_type, '', '',
'itemdesc', 'varchar', 'NULL', $char_d, '', '',
+ 'itemcomment', 'varchar', 'NULL', $char_d, '', '',
'section', 'varchar', 'NULL', $char_d, '', '',
'quantity', 'int', 'NULL', '', '', '',
'unitsetup', @money_typen, '', '',
@@ -520,7 +521,7 @@
],
'primary_key' => 'billpkgnum',
'unique' => [],
- 'index' => [ ['invnum'], [ 'pkgnum' ] ],
+ 'index' => [ ['invnum'], [ 'pkgnum' ], [ 'itemdesc' ], ],
},
'cust_bill_pkg_detail' => {
@@ -800,6 +801,21 @@
'index' => [ [ 'custnum' ] ],
},
+ 'cust_tax_adjustment' => {
+ 'columns' => [
+ 'adjustmentnum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'taxname', 'varchar', '', $char_d, '', '',
+ 'amount', @money_type, '', '',
+ 'comment', 'varchar', 'NULL', $char_d, '', '',
+ 'billpkgnum', 'int', 'NULL', '', '', '',
+ #more? no cust_bill_pkg_tax_location?
+ ],
+ 'primary_key' => 'adjustmentnum',
+ 'unique' => [],
+ 'index' => [ [ 'custnum' ], [ 'billpkgnum' ] ],
+ },
+
'cust_main_county' => { #county+state+country are checked off the
#cust_main_county for validation and to provide
# a tax rate.
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- cust_bill_pkg.pm 10 Jun 2009 21:58:30 -0000 1.34
+++ cust_bill_pkg.pm 25 Jun 2009 01:28:53 -0000 1.35
@@ -175,6 +175,17 @@
}
}
+ my $cust_tax_adjustment = $self->get('cust_tax_adjustment');
+ if ( $cust_tax_adjustment ) {
+ $cust_tax_adjustment->billpkgnum($self->billpkgnum);
+ $error = $cust_tax_adjustment->replace;
+ warn $error;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
@@ -224,6 +235,7 @@
|| $self->ut_numbern('sdate')
|| $self->ut_numbern('edate')
|| $self->ut_textn('itemdesc')
+ || $self->ut_textn('itemcomment')
;
return $error if $error;
@@ -381,7 +393,9 @@
if ( $self->pkgnum > 0 ) {
$self->itemdesc || $self->part_pkg->pkg;
} else {
- $self->itemdesc || 'Tax';
+ my $desc = $self->itemdesc || 'Tax';
+ $desc .= ' '. $self->itemcomment if $self->itemcomment =~ /\S/;
+ $desc;
}
}
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- AccessRight.pm 17 Jun 2009 06:43:08 -0000 1.38
+++ AccessRight.pm 25 Jun 2009 01:28:53 -0000 1.39
@@ -152,6 +152,7 @@
'View invoices',
'Resend invoices', #NEWNEW
'View customer tax exemptions', #yow
+ 'Add customer tax adjustment', #new, but no need to phase in
'View customer batched payments', #NEW
'View customer pending payments', #NEW
'Edit customer pending payments', #NEW
More information about the freeside-commits
mailing list