From 8066acc76d4098199b1bb60830dd881bd65f3900 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Wed, 10 Oct 2007 17:43:24 +0000 Subject: Merging in David Mora's payment changes. Still working on the template and workflow scripts. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1735 4979c152-3d1c-0410-bac9-87ea11338e46 --- CONTRIBUTORS | 2 + LedgerSMB.pm | 3 +- LedgerSMB/Batch.pm | 1 + LedgerSMB/DBObject/Date.pm | 87 +++++++++++++++++++++++++++++++++++++++++++ LedgerSMB/DBObject/Payment.pm | 36 +++++++++++++++++- UI/create_batch.html | 22 +++++++++-- sql/modules/Date.sql | 17 +++++++++ sql/modules/Payment.sql | 23 ++++++++++-- 8 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 LedgerSMB/DBObject/Date.pm create mode 100644 sql/modules/Date.sql diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a6cbcb07..bc2b7168 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -73,6 +73,8 @@ handling. Chad Phillips [email omitted] Various bugfixes. Also contributed a template widget system for 1.3. +David Mora contributed the new Payment template/system. + Original Authors of SQL-Ledger: =================================== Dieter Simader diff --git a/LedgerSMB.pm b/LedgerSMB.pm index d20b4875..1ca1ec13 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -205,8 +205,7 @@ sub new { $self->{_locale} = LedgerSMB::Locale->get_handle('en') # temporary or $self->error(__FILE__.':'.__LINE__.": Locale not loaded: $!\n"); - $self->{stylesheet} = 'ledgersmb.css'; # temporary - #$self->{stylesheet} = $self->{_user}->{stylesheet}; + $self->{stylesheet} = $self->{_user}->{stylesheet}; return $self; diff --git a/LedgerSMB/Batch.pm b/LedgerSMB/Batch.pm index 591f409d..7c7bcc53 100644 --- a/LedgerSMB/Batch.pm +++ b/LedgerSMB/Batch.pm @@ -3,3 +3,4 @@ package LedgerSMB::Batch; use base qw(LedgerSMB::DBObject); +1; diff --git a/LedgerSMB/DBObject/Date.pm b/LedgerSMB/DBObject/Date.pm new file mode 100644 index 00000000..50d0bcd8 --- /dev/null +++ b/LedgerSMB/DBObject/Date.pm @@ -0,0 +1,87 @@ + +=head1 NAME + +LedgerSMB::Date Date Handling Back-end Routines for LedgerSMB + +=head1 SYNOPSIS + +Provides the functions for generating the data structures for dates used in +LedgerSMB. + +=cut + +package LedgerSMB::DBObject::Date; +use base qw(LedgerSMB::DBObject); +use strict; +use Math::BigFloat lib => 'GMP'; +our $VERSION = '0.1.0'; + +=head1 METHODS + +=over + +=item LedgerSMB::DBObject::Payment->new() + +Inherited from LedgerSMB::DBObject. Please see that documnetation for details. + +=item $self->build_filter_by_period() + +This function takes $locale as an argument to build the list boxes, of the +period filter. + +It sets $self->{yearsOptions}, $self->{$monthsOptions}, $self->{radioOptions} +so you just pass the hash to the template system. :) + +=back + +=cut + + +sub build_filter_by_period { + my ($self, $locale) = @_; + my @all_years = $self->call_procedure(procname => 'date_get_all_years'); + for my $ref (0 .. $#all_years) { + push @{$self->{yearsOptions}} , { value => $all_years[$ref]{year}, + text => $all_years[$ref]{year}} + } + @{$self->{monthsOptions}} = ( + { value => '01', text => $locale->text('January')}, + { value => '02', text => $locale->text('February')}, + { value => '03', text => $locale->text('March')}, + { value => '04', text => $locale->text('April')}, + { value => '05', text => $locale->text('May')}, + { value => '06', text => $locale->text('June')}, + { value => '07', text => $locale->text('July')}, + { value => '08', text => $locale->text('August')}, + { value => '09', text => $locale->text('September')}, + { value => '10', text => $locale->text('October')}, + { value => '11', text => $locale->text('November')}, + { value => '12', text => $locale->text('December')} + ); + + + @{$self->{radioOptions}} = ( + { + label => $locale->text('Current'), + name => 'radioPeriod', + value => '1', + }, + { + label => $locale->text('Month'), + name => 'radioPeriod', + value => '2', + active => '1', + }, + { + label => $locale->text('Quarter'), + name => 'radioPeriod', + value => '3', + }, + { + label => $locale->text('Year'), + name => 'radioPeriod', + value => '4', + }); +} +1; + diff --git a/LedgerSMB/DBObject/Payment.pm b/LedgerSMB/DBObject/Payment.pm index 8ee92792..f13a3d42 100644 --- a/LedgerSMB/DBObject/Payment.pm +++ b/LedgerSMB/DBObject/Payment.pm @@ -183,7 +183,7 @@ sub list_open_projects { } =over -=item list_open_projects +=item list_departments This method gets the type of document as a parameter, and provides a list of departments of the required type. @@ -202,4 +202,38 @@ sub list_departments { return @{$self->{departments}}; } +=item list_open_vc + +This method gets the type of vc (vendor or customer) as a parameter, and provides a list of departments +of the required type. +The list is attached to $self->{departments} and returned. + +=back +=cut + +sub list_departments { + my ($self) = shift @_; + my @args = @_; + @{$self->{departments}} = $self->call_procedure( + procname => 'department_list', + args => \@args + ); + return @{$self->{departments}}; +} + +=item get_open_currencies + +This method gets a list of the open currencies inside the database, it requires that +$self->{account_class} (must be 1 or 2) exist to work. + +=back +=cut + +sub get_open_currencies { + my ($self) = shift @_; + @{$self->{openCurrencies}} = $self->exec_method( funcname => 'payments_get_open_currencies'); + return @{$self->{openCurrencies}}; +} + + 1; diff --git a/UI/create_batch.html b/UI/create_batch.html index 49d484b1..da71ca26 100644 --- a/UI/create_batch.html +++ b/UI/create_batch.html @@ -17,18 +17,34 @@
-
+
- +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
- + diff --git a/sql/modules/Date.sql b/sql/modules/Date.sql new file mode 100644 index 00000000..7b942c2a --- /dev/null +++ b/sql/modules/Date.sql @@ -0,0 +1,17 @@ +CREATE OR REPLACE FUNCTION date_get_all_years() returns setof INT AS +$$ +DECLARE + date_out record; + BEGIN + FOR date_out IN + SELECT EXTRACT('YEAR' from transdate) AS year + FROM acc_trans + GROUP BY EXTRACT('YEAR' from transdate) + ORDER BY year + LOOP + return next date_out.year; + END LOOP; + END; +$$ language plpgsql; +COMMENT ON FUNCTION date_get_all_years() IS +$$ This function return each year inside transdate in transactions. $$; diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql index 7b771734..f6332099 100644 --- a/sql/modules/Payment.sql +++ b/sql/modules/Payment.sql @@ -215,7 +215,7 @@ $$ LANGUAGE PLPGSQL; COMMENT ON FUNCTION payment_post (in_trans_id int, in_source text, in_amount numeric, in_ar_ap_accno text, - in_cash_accno text, in_approved bool, in_payment_date, + in_cash_accno text, in_approved bool, in_payment_date date, in_account_class int) IS $$ This function takes the following arguments (prefaced with in_ in the db): @@ -272,6 +272,21 @@ comment on function department_list(in_role char) is $$ This function returns all department that match the role provided as the argument.$$; - - - +CREATE OR REPLACE FUNCTION payments_get_open_currencies(in_account_class int)returns setof char(3) AS +$$ +DECLARE resultrow record; +BEGIN + FOR resultrow IN + SELECT curr FROM ar + WHERE amount <> paid + AND in_account_class=2 + UNION + SELECT curr FROM ap + WHERE amount <> paid + AND in_account_class=1 + ORDER BY curr + LOOP + return next resultrow.curr; + END LOOP; +END; +$$ language plpgsql; -- cgit v1.2.3