[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1399] trunk
- Subject: SF.net SVN: ledger-smb: [1399] trunk
- From: ..hidden..
- Date: Sun, 15 Jul 2007 17:03:37 -0700
Revision: 1399
http://svn.sourceforge.net/ledger-smb/?rev=1399&view=rev
Author: einhverfr
Date: 2007-07-15 17:03:37 -0700 (Sun, 15 Jul 2007)
Log Message:
-----------
Credit/Debit notes now work, credit/debit invoices still need some testing
Modified Paths:
--------------
trunk/LedgerSMB/AA.pm
trunk/LedgerSMB/CT.pm
trunk/LedgerSMB/Form.pm
trunk/LedgerSMB/IR.pm
trunk/LedgerSMB/IS.pm
trunk/LedgerSMB/Menu.pm
trunk/LedgerSMB/Template.pm
trunk/LedgerSMB.pm
trunk/bin/aa.pl
trunk/bin/ir.pl
trunk/bin/is.pl
trunk/lsmb-request.pl
trunk/scripts/menu.pl
Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/LedgerSMB/AA.pm 2007-07-16 00:03:37 UTC (rev 1399)
@@ -39,6 +39,12 @@
sub post_transaction {
my ( $self, $myconfig, $form ) = @_;
+ for (1 .. $form->{rowcount}){
+ $form->{"amount_$_"} = $form->parse_amount(
+ $myconfig, $form->{"amount_$_"}
+ );
+ $form->{"amount_$_"} *= -1 if $form->{reverse};
+ }
# connect to database
my $dbh = $form->{dbh};
@@ -89,11 +95,10 @@
my %tax = ();
my $accno;
-
# add taxes
foreach $accno (@taxaccounts) {
- $fxtax += $tax{fxamount}{$accno} =
- $form->parse_amount( $myconfig, $form->{"tax_$accno"} );
+ $form->{"tax_$accno"} *= -1 if $form->{reverse};
+ $fxtax += $tax{fxamount}{$accno} = $form->{"tax_$accno"};
$tax += $tax{fxamount}{$accno};
push @{ $form->{acc_trans}{taxes} },
@@ -125,8 +130,7 @@
my %amount = ();
my $fxinvamount = 0;
for ( 1 .. $form->{rowcount} ) {
- $fxinvamount += $amount{fxamount}{$_} =
- $form->parse_amount( $myconfig, $form->{"amount_$_"} );
+ $fxinvamount += $amount{fxamount}{$_} = $form->{"amount_$_"};
}
$form->{taxincluded} *= 1;
@@ -207,7 +211,11 @@
# add payments
for $i ( 1 .. $form->{paidaccounts} ) {
- $fxamount = $form->parse_amount( $myconfig, $form->{"paid_$i"} );
+ $form->{"paid_$i"} = $form->parse_amount(
+ $myconfig, $form->{"paid_$i"}
+ );
+ $form->{"paid_$i"} *= -1 if $form->{reverse};
+ $fxamount = $form->{"paid_$i"};
if ($fxamount) {
$paid += $fxamount;
@@ -294,7 +302,7 @@
SET invnumber = ?,
ordnumber = ?,
transdate = ?,
- $form->{vc}_id = ?,
+ entity_id = ?,
taxincluded = ?,
amount = ?,
duedate = ?,
@@ -304,7 +312,7 @@
curr = ?,
notes = ?,
department_id = ?,
- employee_id = ?,
+ person_id = ?,
ponumber = ?
WHERE id = ?
|;
Modified: trunk/LedgerSMB/CT.pm
===================================================================
--- trunk/LedgerSMB/CT.pm 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/LedgerSMB/CT.pm 2007-07-16 00:03:37 UTC (rev 1399)
@@ -325,7 +325,7 @@
$sth->execute(
$form->{entity_id}, $form->{entity_class}, $form->{discount},
$form->{taxincluded}, $form->{creditlimit},
- $form->{terms}, $form->{"$form->{vc}number"}, $form->{cc},
+ $form->{terms}, $form->{"$form->{db}number"}, $form->{cc},
$form->{bcc}, $form->{business_id},
$form->{language_code}, $form->{pricegroup_id}, $form->{curr},
$form->{startdate} || undef, $form->{enddate} || undef,
Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/LedgerSMB/Form.pm 2007-07-16 00:03:37 UTC (rev 1399)
@@ -1241,15 +1241,20 @@
my $sth;
- my $query = qq|SELECT count(*) FROM $vc|;
+ if ($vc eq 'customer'){
+ $self->{vc_class} = 2;
+ } else {
+ $self->{vc_class} = 1;
+ }
+ my $query = qq|SELECT count(*) FROM entity_credit_account where entity_class = ?|;
my $where;
- my @queryargs = ();
+ my @queryargs = ($self->{vc_class});
if ($transdate) {
- $query .= qq| WHERE (startdate IS NULL OR startdate <= ?)
+ $query .= qq| AND (startdate IS NULL OR startdate <= ?)
AND (enddate IS NULL OR enddate >= ?)|;
- @queryargs = ( $transdate, $transdate );
+ push (@queryargs, $transdate, $transdate );
}
$sth = $dbh->prepare($query);
@@ -1596,7 +1601,7 @@
d.description AS department,
a.amount AS oldinvtotal, a.paid AS oldtotalpaid,
a.employee_id, e.name AS employee,
- c.language_code, a.ponumber
+ c.language_code, a.ponumber, a.reverse
FROM $arap a
JOIN $vc c ON (a.${vc}_id = c.id)
LEFT JOIN employee e ON (e.id = a.employee_id)
@@ -1664,6 +1669,9 @@
$ref->{exchangerate} =
$self->get_exchangerate( $dbh, $self->{currency},
$ref->{transdate}, $fld );
+ if ($form->{reverse}){
+ $ref->{amount} *= -1;
+ }
push @{ $self->{acc_trans}{ $xkeyref{ $ref->{accno} } } }, $ref;
}
@@ -1741,7 +1749,7 @@
where entity_id IS NOT NULL $where
order by id DESC limit 1)|;
- $sth = $dbh->prepare($query);
+ $sth = $self->{dbh}->prepare($query);
$sth->execute() || $self->dberror($query);
my $ref = $sth->fetchrow_hashref(NAME_lc);
Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/LedgerSMB/IR.pm 2007-07-16 00:03:37 UTC (rev 1399)
@@ -45,6 +45,7 @@
unless $form->{invnumber};
for ( 1 .. $form->{rowcount} ) {
+ $form->{"qty_$_"} *= -1 if $form->{reverse};
unless ( $form->{"deliverydate_$_"} ) {
$form->{"deliverydate_$_"} = $form->{transdate};
}
@@ -285,6 +286,7 @@
deliverydate = ?,
project_id = ?,
serialnumber = ?,
+ reverse = ?
notes = ?
WHERE id = ?|;
$sth = $dbh->prepare($query);
@@ -295,7 +297,8 @@
$form->{"discount_$i"}, $allocated,
$form->{"unit_$i"}, $form->{"deliverydate_$i"},
$project_id, $form->{"serialnumber_$i"},
- $form->{"notes_$i"}, $invoice_id
+ $form->{reverse}, $form->{"notes_$i"},
+ $invoice_id
) || $form->dberror($query);
if (defined $form->{approved}) {
@@ -1070,7 +1073,7 @@
a.ordnumber, a.quonumber, a.paid, a.taxincluded,
a.notes, a.intnotes, a.curr AS currency,
a.vendor_id, a.language_code, a.ponumber,
- a.on_hold
+ a.on_hold, a.reverse
FROM ap a
WHERE id = ?|;
$sth = $dbh->prepare($query);
@@ -1138,7 +1141,7 @@
while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
$form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-
+ $ref->{qty} *= -1 if $form->{reverse};
my ($dec) = ( $ref->{fxsellprice} =~ /\.(\d+)/ );
$dec = length $dec;
my $decimalplaces = ( $dec > 2 ) ? $dec : 2;
Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/LedgerSMB/IS.pm 2007-07-16 00:03:37 UTC (rev 1399)
@@ -912,6 +912,9 @@
foreach $i ( 1 .. $form->{rowcount} ) {
$form->{"qty_$i"} = $form->parse_amount( $myconfig, $form->{"qty_$i"} );
+ if ($form->{reverse}){
+ $form->{"qty_$i"} *= -1;
+ }
if ( $form->{"qty_$i"} ) {
@@ -1120,6 +1123,7 @@
deliverydate = ?,
project_id = ?,
serialnumber = ?,
+ reverse = ?,
notes = ?
WHERE id = ?|;
@@ -1131,7 +1135,8 @@
$form->{"discount_$i"}, $allocated,
$form->{"unit_$i"}, $form->{"deliverydate_$i"},
$project_id, $form->{"serialnumber_$i"},
- $form->{"notes_$i"}, $invoice_id
+ $form->{reverse}, $form->{"notes_$i"},
+ $invoice_id
) || $form->dberror($query);
if (defined $form->{approved}) {
@@ -1793,7 +1798,7 @@
a.intnotes,
a.duedate, a.taxincluded, a.curr AS currency,
a.employee_id, e.name AS employee, a.till,
- a.entity_id,
+ a.entity_id, a.reverse
a.language_code, a.ponumber,
a.on_hold
FROM ar a
@@ -1863,6 +1868,7 @@
while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
$form->db_parse_numeric(sth=>$sth, hashref => $ref);
+ $ref->{qty} *= -1 if $form->{reverse};
my ($dec) = ( $ref->{fxsellprice} =~ /\.(\d+)/ );
$dec = length $dec;
my $decimalplaces = ( $dec > 2 ) ? $dec : 2;
Modified: trunk/LedgerSMB/Menu.pm
===================================================================
--- trunk/LedgerSMB/Menu.pm 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/LedgerSMB/Menu.pm 2007-07-16 00:03:37 UTC (rev 1399)
@@ -19,7 +19,6 @@
use Config::Std;
use base(qw(LedgerSMB::DBObject));
-
1;
=head1 METHODS
Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/LedgerSMB/Template.pm 2007-07-16 00:03:37 UTC (rev 1399)
@@ -144,6 +144,7 @@
my $self = shift;
my $FH;
+ print STDERR "Content-Type: $self->{mimetype}; charset=utf-8\n\n";
if ($self->{mimetype} =~ /^text/) {
print "Content-Type: $self->{mimetype}; charset=utf-8\n\n";
} else {
Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/LedgerSMB.pm 2007-07-16 00:03:37 UTC (rev 1399)
@@ -226,7 +226,7 @@
sub _get_password {
my ($self) = shift @_;
$self->{sessionexpired} = shift @_;
- @{$self->{hidden}} = [];
+ $self->{hidden} = [];
for (keys %$self){
next if $_ =~ /(^script$|^endsession$|^password$)/;
my $attr = {};
Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/bin/aa.pl 2007-07-16 00:03:37 UTC (rev 1399)
@@ -92,6 +92,18 @@
$form->{callback} =
"$form->{script}?action=add&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
unless $form->{callback};
+ if ($form->{type} eq "credit_note"){
+ $form->{reverse} = 1;
+ $form->{subtype} = 'credit_note';
+ $form->{type} = 'transaction';
+ } elsif ($form->{type} eq 'debit_note'){
+ $form->{reverse} = 1;
+ $form->{subtype} = 'debit_note';
+ $form->{type} = 'transaction';
+ }
+ else {
+ $form->{reverse} = 0;
+ }
&create_links;
@@ -103,7 +115,19 @@
sub edit {
$form->{title} = "Edit";
+ if ($form->{reverse}){
+ if ($form->{ARAP} eq 'AR'){
+ $form->{subtype} = 'credit_note';
+ $form->{type} = 'transaction';
+ } elsif ($form->{ARAP} eq 'AP'){
+ $form->{subtype} = 'debit_note';
+ $form->{type} = 'transaction';
+ } else {
+ $form->error("Unknown AR/AP selection value: $form->{ARAP}");
+ }
+ }
+
&create_links;
&display_form;
@@ -375,12 +399,29 @@
sub form_header {
$title = $form->{title};
- $form->{title} = $locale->text("$title $form->{ARAP} Transaction");
+ if ($form->{reverse} == 0){
+ $form->{title} = $locale->text("$title $form->{ARAP} Transaction");
+ }
+ elsif($form->{reverse} == 1) {
+ if ($form->{subtype} eq 'credit_note'){
+ $form->{title} = $locale->text("$title Credit Note");
+ } elsif ($form->{subtype} eq 'debit_note'){
+ $form->{title} = $locale->text("$title Debit Note");
+ } else {
+ $form->error("Unknown subtype $form->{subtype} in $form->{ARAP} "
+ . "transaction.");
+ }
+ }
+ else {
+ $form->error('Reverse flag not true or false on AR/AP transaction');
+ }
$form->{taxincluded} = ( $form->{taxincluded} ) ? "checked" : "";
- # $locale->text('Add AR Transaction')
- # $locale->text('Edit AR Transaction')
+ # $locale->text('Add Debit Note')
+ # $locale->text('Edit Debit Note')
+ # $locale->text('Add Credit Note')
+ # $locale->text('Edit Credit Note')
# $locale->text('Add AP Transaction')
# $locale->text('Edit AP Transaction')
@@ -496,14 +537,14 @@
<body onload="document.forms[0].${focus}.focus()" />
<form method=post action=$form->{script}>
-
<input type=hidden name=type value="$form->{formname}">
<input type=hidden name=title value="$title">
|;
$form->hide_form(
- qw(id printed emailed sort closedto locked oldtransdate audittrail recurring checktax)
+ qw(id printed emailed sort closedto locked oldtransdate audittrail
+ recurring checktax reverse batch_id subtype)
);
if ( $form->{vc} eq 'customer' ) {
Modified: trunk/bin/ir.pl
===================================================================
--- trunk/bin/ir.pl 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/bin/ir.pl 2007-07-16 00:03:37 UTC (rev 1399)
@@ -50,9 +50,15 @@
# end of main
sub add {
+ if ($form->{type} eq 'debit_invoice'){
+ $form->{title} = $locale->text('Add Debit Invoice');
+ $form->{subtype} = 'debit_invoice';
+ $form->{reverse} = 1;
+ } else {
+ $form->{title} = $locale->text('Add Vendor Invoice');
+ $form->{reverse} = 0;
+ }
- $form->{title} = $locale->text('Add Vendor Invoice');
-
$form->{callback} =
"$form->{script}?action=add&type=$form->{type}&login=$form->{login}&path=$form->{path}&sessionid=$form->{sessionid}"
unless $form->{callback};
@@ -63,9 +69,14 @@
}
sub edit {
+ if ($form->{reverse}){
+ $form->{title} = $locale->text('Add Debit Invoice');
+ $form->{subtype} = 'debit_invoice';
+ } else {
+ $form->{title} = $locale->text('Edit Vendor Invoice');
+ }
+
- $form->{title} = $locale->text('Edit Vendor Invoice');
-
&invoice_links;
&prepare_invoice;
&display_form;
@@ -367,7 +378,8 @@
$form->{vc} = "vendor";
$form->hide_form(
- qw(id title vc type terms creditlimit creditremaining closedto locked shipped oldtransdate recurring)
+ qw(id title vc type terms creditlimit creditremaining closedto locked
+ shipped oldtransdate recurring reverse batch_id subtype)
);
print qq|
@@ -1139,4 +1151,4 @@
#&invoice_links(); # is that it?
&edit(); # it was already IN edit for this to be reached.
}
-}
\ No newline at end of file
+}
Modified: trunk/bin/is.pl
===================================================================
--- trunk/bin/is.pl 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/bin/is.pl 2007-07-16 00:03:37 UTC (rev 1399)
@@ -55,9 +55,14 @@
# end of main
sub add {
-
- $form->{title} = $locale->text('Add Sales Invoice');
-
+ if ($form->{type} eq 'credit_invoice'){
+ $form->{title} = $locale->text('Add Credit Invoice');
+ $form->{subtype} = 'credit_invoice';
+ $form->{reverse} = 1;
+ } else {
+ $form->{title} = $locale->text('Add Sales Invoice');
+ $form->{reverse} = 0;
+ }
$form->{callback} =
"$form->{script}?action=add&type=$form->{type}&login=$form->{login}&path=$form->{path}&sessionid=$form->{sessionid}"
unless $form->{callback};
@@ -70,8 +75,12 @@
sub edit {
- $form->{title} = $locale->text('Edit Sales Invoice');
-
+ if ($form->{reverse}) {
+ $form->{title} = $locale->text('Add Credit Invoice');
+ $form->{subtype} = 'credit_invoice';
+ } else {
+ $form->{title} = $locale->text('Add Sales Invoice');
+ }
&invoice_links;
&prepare_invoice;
&display_form;
@@ -402,7 +411,9 @@
|;
$form->hide_form(
- qw(id type media format printed emailed queued title vc terms discount creditlimit creditremaining tradediscount business closedto locked shipped oldtransdate recurring)
+ qw(id type media format printed emailed queued title vc terms discount
+ creditlimit creditremaining tradediscount business closedto locked
+ shipped oldtransdate recurring reverse batch_id subtype)
);
print qq|
@@ -1198,4 +1209,4 @@
#&invoice_links(); # is that it?
&edit(); # it was already IN edit for this to be reached.
}
-}
\ No newline at end of file
+}
Modified: trunk/lsmb-request.pl
===================================================================
--- trunk/lsmb-request.pl 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/lsmb-request.pl 2007-07-16 00:03:37 UTC (rev 1399)
@@ -56,3 +56,4 @@
|| $request->error($locale->text("Action Not Defined: ") . $request->{action});
$script->can($request->{action})->($request);
+1;
Modified: trunk/scripts/menu.pl
===================================================================
--- trunk/scripts/menu.pl 2007-07-15 22:14:15 UTC (rev 1398)
+++ trunk/scripts/menu.pl 2007-07-16 00:03:37 UTC (rev 1399)
@@ -37,7 +37,7 @@
sub expanding_menu {
my ($request) = @_;
- my $menu = new LedgerSMB::Menu({base => $request});
+ my $menu = LedgerSMB::Menu->new({base => $request});
$menu->generate();
my $template = LedgerSMB::Template->new(
user => $request->{_user},
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.