diff options
-rw-r--r-- | LedgerSMB/IS.pm | 7 | ||||
-rw-r--r-- | LedgerSMB/RC.pm | 4 | ||||
-rwxr-xr-x | LedgerSMB/Session/DB.pm | 1 | ||||
-rw-r--r-- | scripts/vouchers.pl | 56 | ||||
-rw-r--r-- | sql/Pg-database.sql | 15 |
5 files changed, 77 insertions, 6 deletions
diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm index b3b54fca..fdb22861 100644 --- a/LedgerSMB/IS.pm +++ b/LedgerSMB/IS.pm @@ -916,6 +916,11 @@ sub post_invoice { my $ml; my $invoice_id; my $ndx; + for (keys %$form) { + if (UNIVERSAL::isa( $form->{$_}, 'Math::BigFloat' )){ + $form->{$_} = $form->{$_}->bstr(); + } + } foreach $i ( 1 .. $form->{rowcount} ) { $form->{"qty_$i"} = $form->parse_amount( $myconfig, $form->{"qty_$i"} ); @@ -1138,7 +1143,7 @@ sub post_invoice { $form->{paid} = 0; for $i ( 1 .. $form->{paidaccounts} ) { $form->{"paid_$i"} = - $form->parse_amount( $myconfig, $form->{"paid_$i"} ); + $form->parse_amount( $myconfig, $form->{"paid_$i"} )->bstr(); $form->{paid} += $form->{"paid_$i"}; $form->{datepaid} = $form->{"datepaid_$i"} if ( $form->{"paid_$i"} ); diff --git a/LedgerSMB/RC.pm b/LedgerSMB/RC.pm index e3517044..4eae7823 100644 --- a/LedgerSMB/RC.pm +++ b/LedgerSMB/RC.pm @@ -45,11 +45,11 @@ sub getposlines { my $dbh = $form->{dbh}; my $query = qq| - SELECT sum(amount) AS amount, source FROM acc_trans + SELECT sum(amount) AS amount, memo FROM acc_trans WHERE chart_id = (SELECT id FROM chart WHERE accno = ?) AND transdate = date 'NOW' AND cleared IS NOT TRUE - GROUP BY source|; + GROUP BY memo|; my $sth = $dbh->prepare($query); $sth->execute( $pos_config{till_accno} ) || $form->dberror($query); while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) { diff --git a/LedgerSMB/Session/DB.pm b/LedgerSMB/Session/DB.pm index 98694774..bfc0b9fc 100755 --- a/LedgerSMB/Session/DB.pm +++ b/LedgerSMB/Session/DB.pm @@ -266,7 +266,6 @@ sub password_check { $fetchPassword->fetchrow_array; if ( $dbusername ne $username ) { - # User data retrieved from db not for the requested user return 0; } diff --git a/scripts/vouchers.pl b/scripts/vouchers.pl new file mode 100644 index 00000000..34305139 --- /dev/null +++ b/scripts/vouchers.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +# This file is copyright (C) 2007the LedgerSMB core team and licensed under +# the GNU General Public License. For more information please see the included +# LICENSE and COPYRIGHT files + +package LedgerSMB::Scripts::vouchers; +our $VERSION = '0.1'; + +$menufile = "menu.ini"; +use LedgerSMB::Batch; +use LedgerSMB::Voucher; +use LedgerSMB::Template; +use strict; + +sub create_batch { + my ($request) = @_; + $request->{hidden} = [ + batch_type => $request->{batch_type}, + ]; + my $template = LedgerSMB::Template->new( + user =>$request->{_user}, + locale => $request->{_locale}, + path => 'UI', + template => 'create_batch', + format => 'HTML' + ); + $template->render($request); +} + +sub create_vouchers { + # This function is not safe for caching as long as the scripts are in bin. + # This is because these scripts import all functions into the *current* + # namespace. People using fastcgi and modperl should *not* cache this + # module at the moment. -- CT + my %vouchers_dispatch = ( + payable => {script => 'bin/ap.pl', function => sub {add()}}, + receivable => {script => 'bin/ar.pl', function => sub {add()}}, + payments => {script => 'bin/cp.pl', function => sub {payments()}}, + receipts => {script => 'bin/cp.pl', function => sub {receipts()}}, + gl => {script => 'bin/gl.pl'. function => sub {add()}}, + ) + require $vouchers_dispatch{$request->{batch_type}}{script} + $vouchers_dispatch{$request->{batch_type}}{function}(); +} + +sub list_vouchers { +} + +sub approve_batch { +} + +sub delete_batch { +} + +1; diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql index 85c8df74..bfaf7c75 100644 --- a/sql/Pg-database.sql +++ b/sql/Pg-database.sql @@ -781,6 +781,7 @@ insert into batch_class (id,class) values (2,'ar'); insert into batch_class (id,class) values (3,'payment'); insert into batch_class (id,class) values (4,'payment_reversal'); insert into batch_class (id,class) values (5,'gl'); +insert into batch_class (id,class) values (6,'receipt'); SELECT SETVAL('batch_class_id_seq',6); @@ -795,12 +796,22 @@ CREATE TABLE batch ( created_on date default now() ); +COMMENT ON batch.batch_class_id IS +$$ Note that this field is largely used for sorting the vouchers. A given batch is NOT restricted to this type.$$; + CREATE TABLE voucher ( - trans_id int, + trans_id int REFERENCES transactions(id) NOT NULL, batch_id int references batch(id) not null, - id serial primary key + id serial NOT NULL, + batch_class int references batch_class not null, + PRIMARY KEY (batch_class, batch_id, trans_id) ); +COMMENT ON batch.batch_class IS $$ This is the authoritative class of the +voucher. $$; + +COMMENT ON voucher.id IS $$ This is simply a surrogate key for easy reference.$$; + -- create table shipto ( trans_id int, |