[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1926] trunk
- Subject: SF.net SVN: ledger-smb: [1926] trunk
- From: ..hidden..
- Date: Thu, 29 Nov 2007 23:31:46 -0800
Revision: 1926
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1926&view=rev
Author: einhverfr
Date: 2007-11-29 23:31:45 -0800 (Thu, 29 Nov 2007)
Log Message:
-----------
Separated out multiple payment interface from new payment interface. Still not working, but almost there
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Payment.pm
trunk/UI/Contact/contact.html
trunk/scripts/payment.pl
trunk/sql/modules/Payment.sql
Added Paths:
-----------
trunk/UI/payments/payments_detail.html
trunk/UI/payments/payments_filter.html
trunk/sql/modules/Business_type.sql
Modified: trunk/LedgerSMB/DBObject/Payment.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Payment.pm 2007-11-30 05:43:44 UTC (rev 1925)
+++ trunk/LedgerSMB/DBObject/Payment.pm 2007-11-30 07:31:45 UTC (rev 1926)
@@ -51,14 +51,25 @@
sub __validate__ {
my ($self) = shift @_;
- #FIRST WE CHECK IF THE MAIN PROPERTY 'account_class' IS SET
+ # If the account class is not set, we don't know if it is a payment or a
+ # receipt. --CT
if (!$self->{account_class}) {
$self->error("account_class must be set")
};
- #NOW WE SET THE CURRENT DATE
+ # We should try to re-engineer this so that we don't have to include SQL in
+ # this file. --CT
($self->{current_date}) = $self->{dbh}->selectrow_array('select current_date');
}
+sub get_metadata {
+ my ($self) = @_;
+ $self->list_open_projects();
+ @{$self->{departments}} = $self->exec_method(funcname => 'department_list');
+ $self->get_open_currencies();
+ @{$self->{businesses}} = $self->exec_method(
+ funcname => 'business_type__list'
+ );
+}
sub get_open_accounts {
my ($self) = @_;
Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html 2007-11-30 05:43:44 UTC (rev 1925)
+++ trunk/UI/Contact/contact.html 2007-11-30 07:31:45 UTC (rev 1926)
@@ -546,7 +546,7 @@
value=bank_account_id
} ?>
<div><label for="bic">
- <?lsmb PROCESS input element_data = {
+ <?lsmb INCLUDE input element_data = {
type="text"
label = text('BIC/SWIFT Code:')
name="bic"
Added: trunk/UI/payments/payments_detail.html
===================================================================
--- trunk/UI/payments/payments_detail.html (rev 0)
+++ trunk/UI/payments/payments_detail.html 2007-11-30 07:31:45 UTC (rev 1926)
@@ -0,0 +1,148 @@
+<?lsmb INCLUDE 'ui-header.html'
+ titlebar = 'Payments'
+ include_stylesheet = [
+ 'css/global.css'
+ 'UI/payments/payments.css'
+ ]
+?>
+ <?lsmb PROCESS elements.html # Include form elements helper. ?>
+<?lsmb contact_type = (account_class == 1) ? text('Vendor') : text('Customer')
+?>
+<?lsmb payment_type = (account_class == 1) ? text('Payments') : text('Receipts')
+?>
+<body id="payment_2_body">
+<div class="listtop"><?lsmb payment_type ?></div>
+ <form name="pay_dues" method="post" action="payment.pl">
+ <!-- Moving all hidden variables to the top. -CT -->
+ <?lsmb INCLUDE input element_data = {
+ type = "hidden"
+ name = "project_id"
+ value = project_id
+ } ?>
+ <?lsmb INCLUDE input element_data = {
+ type = "hidden"
+ name = "department_id"
+ value = department_id
+ } ?>
+ <?lsmb INCLUDE input element_data = {
+ type = "hidden"
+ name = "approved"
+ value = approved
+ } ?>
+ <?lsmb INCLUDE input element_data = {
+ type = "hidden"
+ name = "currency"
+ value = currency
+ } ?>
+ <?lsmb INCLUDE input element_data = {
+ type = "hidden"
+ name = "payable_id"
+ value = payable_id
+ } ?>
+ <?lsmb INCLUDE input element_data = {
+ type = "hidden"
+ name = "batch_id"
+ value = batch_id
+ } ?>
+ <table width=100% id="info_table">
+ <tr valign=top id="info_row">
+ <td width=50% id="info_data">
+ <table>
+ <!-- the department will be shown if it was selected in the first step -->
+ <?lsmb IF department.value # Only process element if one exists. As in project above ?>
+ <tr id="department-row">
+ <th align="right" nowrap id="department_label_column"><?lsmb text('Department') ?>:</th>
+ <td colspan="2" id="department_column">
+ <?lsmb department ?>
+ </td>
+ </tr>
+ <?lsmb END ?>
+ <tr id="account_row">
+ <th align="right" nowrap id="account_label_column"><?lsmb text('Account') ?></th>
+ <td colspan="2" id="account_column"><?lsmb payable_accno ?>--<?lsmb payable_description ?></td>
+ </tr>
+ <tr id="date_row">
+ <th align="right" nowrap id="date_label_column"><?lsmb text('Date') ?></th>
+ <td colspan="2" id="date_column">
+ <?lsmb IF batch_id ?>
+ <?lsmb date_paid ?>
+ <?lsmb END ?>
+ <?lsmb INCLUDE input element_data= {
+ value = datepaid
+ name = "datepaid"
+ size = 20
+ class = (batch_id) ? "hidden" : "date"
+ type = (batch_id) ? "hidden" : "text"
+ } ?> </td>
+ </tr>
+ <?lsmb IF defaultcurrency != curr ?>
+ <tr id="exrate_row">
+ <th valig="top" align="right" id="exrate_label_column"><?lsmb text('Exchange Rate') ?>:</th>
+ <td id="exrate_column">
+ <?lsmb PROCESS input element_data= {
+ label = text('Exchange Rate')
+ type = text
+ class = "numeric"
+ name = 'exchange_rate'
+ value = exchange_rate
+ size = 20
+ } # ' ?>
+ </td>
+ </tr>
+ <?lsmb END ?>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <table width="100%" border="1">
+ <tr class="listheading">
+ <?lsmb FOREACH column IN column_headers # Loop through columns ?>
+ <th class="listheading"><?lsmb column.text ?></th>
+ <?lsmb END ?>
+ </tr>
+ <?lsmb # We have to clear i for later usage :) ?>
+ <?lsmb i = '0' ?>
+ <?lsmb FOREACH row IN rows ?>
+ <?lsmb i = i + 1; j = i % 2; alterning_style = "listrow$j"
+ # TODO: Refactor -- CT ?>
+ <tr class="<?lsmb alterning_style ?>"=>
+ <td><a href="<?lsmb row.invoice.href ?>"><?lsmb row.invoice.number ?></a>
+ <input type="hidden" value="<?lsmb row.invoice.id ?>" /> </td>
+ <!-- we can use an href to link this invoice number to the invoice - DM -->
+ <td><?lsmb row.invoice_date ?></td>
+ <td><?lsmb row.amount ?></td>
+ <td><?lsmb row.paid ?></td>
+ <td><?lsmb row.due ?></td>
+ <?lsmb IF defaultcurrency.text != curr.text ?>
+ <td><?lsmb row.exchange_rate ?></td>
+ <td><?lsmb row.due_fx ?></td>
+ <td><div id="<?lsmb "div_topay_invoice_$i" ?>"><?lsmb row.topay ?></div></td>
+ <?lsmb END ?>
+ <!-- DM: This should be computed and updated to the div using -->
+ <td><?lsmb PROCESS input element_data=row.topay_fx ?><div id="<?lsmb "div_topay_$i" ?>">
+ <hr />
+ <table>
+ <!-- Row for payment cash accounts -->
+ <tr id="<?lsmb "account-row$i"?>">
+ <th align="right" nowrap id="<?lsmb "account_label_column$i" ?>"><?lsmb text('Account') ?></th>
+ <td colspan="2" id="<?lsmb "account_column$i" ?>"><?lsmb PROCESS select element_data=account ?></td>
+ </tr>
+ <tr id="<?lsmb "source_row$i" ?>">
+ <?lsmb # here goes all the posible sources wich we can used ?>
+ <th align="right" nowrap id="<?lsmb "source_label_column$i" ?>"><?lsmb text('Source') ?></th>
+ <td width="28%" id="<?lsmb "source_column$i" ?>"><?lsmb PROCESS select element_data=source ?></td>
+ <td><?lsmb PROCESS input element_data=source_text ?></td>
+ <td nowrap align="left"><input name="<?lsmb "optionalpay_$i" ?>" type="checkbox" class="checkbox"></td>
+ </tr>
+ </table>
+ </div>
+ <?lsmb END ?>
+ </table>
+ <hr />
+ <?lsmb PROCESS button element_data=post ?>
+ <?lsmb PROCESS button element_data=post_and_print ?>
+ <?lsmb PROCESS select element_data=format ?>
+ <?lsmb PROCESS select element_data=media ?>
+ </form>
+ </body>
+</html>
Added: trunk/UI/payments/payments_filter.html
===================================================================
--- trunk/UI/payments/payments_filter.html (rev 0)
+++ trunk/UI/payments/payments_filter.html 2007-11-30 07:31:45 UTC (rev 1926)
@@ -0,0 +1,93 @@
+<?lsmb INCLUDE 'ui-header.html'
+ include_stylesheet = [
+ 'css/global.css'
+ 'UI/payments/payments.css'
+ ]
+ titlebar = text('Selection')
+?>
+<?lsmb PROCESS 'elements.html' # Include form elements helper. ?>
+<body id="payments-filter-body">
+<div class="listtop">
+ <!-- CT: Strings for locales:
+ <?lsmb text('Filtering Receipts') ?>
+ <?lsmb text('Filtering Payments') ?> -->
+ <?lsmb IF account_class == 1 ?><?lsmb t = 'Payments'
+ ?><?lsmb ELSE ?><?lsmb t = 'Receipts'
+ ?><?lsmb END ?>
+ <?lsmb text("Filtering $t") ?>
+</div>
+<form name="search" method="post" action="payment.pl">
+
+
+<?lsmb INCLUDE input element_data={
+ value = accountclass
+ type = "hidden"
+ name = "accountclass"
+} ?>
+<div id = "payments-filter-categories" class="inputgroup">
+<?lsmb IF projects ?>
+<div id = "payments-filter-projects" class="input">
+ <label for="project"><?lsmb text('Project') ?></label>
+ d<select name="project_id" id="project">
+ <?lsmb FOREACH p = projects ?>
+ <option value="<?lsmb p.id ?>"><?lsmb p.projectnumber ?></option>
+ <?lsmb END ?>
+</div>
+<?lsmb END ?>
+
+<?lsmb IF departments ?>
+<div id = "payments-filter-departments" class="input">
+ <label for="department"><?lsmb text('Department') ?></label>
+ <select name="department_id" id="department">
+ <?lsmb FOREACH d = departments ?>
+ <option value="<?lsmb d.id ?>"><?lsmb d.description ?></option>
+ <?lsmb END ?>
+</div>
+<?lsmb END ?>
+
+<?lsmb IF businesses ?>
+<div id = "payments-filter-businesses" class="input">
+ <label for="businesses"><?lsmb text('Business Class') ?></label>
+ <select name="businesses" id="businesses">
+ <?lsmb FOREACH b = businesses ?>
+ <option value="<?lsmb b.id ?>"><?lsmb b.description ?></option>
+ <?lsmb END ?>
+</div>
+<?lsmb END ?>
+</div>
+<div id = "payments-filter-daterow" class = "inputgroup">
+<?lsmb PROCESS input element_data = {
+ label = text('Date From:')
+ type = "text"
+ class = "date"
+ value = date_from
+ name = "date_from"
+ size = 12
+} # ' ?>
+<?lsmb PROCESS input element_data = {
+ label = text('Date To:')
+ type = "text"
+ class = "date"
+ value = date_to
+ name = "date_to"
+ size = 12
+} # ' ?>
+</div>
+<div id = "payments-filter-currency-row" class="inputgroup" ?>
+<label for="currency"><?lsmb text('Currency')?></label>
+<select name="currency" id="currency">
+<?lsmb FOREACH c = currencies ?>
+<option value = "<?lsmb c ?>"><?lsmb c ?></option>
+<?lsmb END ?>
+</select>
+</div>
+</div>
+<?lsmb INCLUDE button element_data = {
+ type = "submit"
+ text = text('Continue')
+ class = "submit"
+ value = "display_payments"
+} ?>
+</form>
+</body>
+</html>
Modified: trunk/scripts/payment.pl
===================================================================
--- trunk/scripts/payment.pl 2007-11-30 05:43:44 UTC (rev 1925)
+++ trunk/scripts/payment.pl 2007-11-30 07:31:45 UTC (rev 1926)
@@ -68,6 +68,21 @@
=cut
+sub payments {
+ my ($request) = @_;
+ my $payment = LedgerSMB::DBObject::Payment->new({'base' => $request});
+ $payment->get_metadata();
+ my $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ locale => $request->{_locale},
+ path => 'UI/payments',
+ template => 'payments_filter',
+ format => 'HTML',
+ );
+ $template->render($payment);
+}
+
+
sub payment {
my ($request) = @_;
my $locale = $request->{_locale};
Added: trunk/sql/modules/Business_type.sql
===================================================================
--- trunk/sql/modules/Business_type.sql (rev 0)
+++ trunk/sql/modules/Business_type.sql 2007-11-30 07:31:45 UTC (rev 1926)
@@ -0,0 +1,9 @@
+CREATE OR REPLACE FUNCTION business_type__list() RETURNS SETOF business AS
+$$
+DECLARE out_row business%ROWTYPE;
+BEGIN
+ FOR out_row IN SELECT * FROM business LOOP
+ RETURN NEXT out_row;
+ END LOOP;
+END;
+$$ LANGUAGE PLPGSQL;
Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql 2007-11-30 05:43:44 UTC (rev 1925)
+++ trunk/sql/modules/Payment.sql 2007-11-30 07:31:45 UTC (rev 1926)
@@ -93,7 +93,8 @@
AND c.entity_class = in_account_class
AND a.amount - a.paid <> 0
AND a.curr = in_curr
- AND a.entity_id = coalesce(in_entity_id, a.entity_id)
+ AND a.credit_account = coalesce(in_entity_credit_id,
+ a.credit_account)
LOOP
RETURN NEXT payment_inv;
END LOOP;
@@ -199,10 +200,31 @@
cnsisting of outstanding invoices.
$$;
+CREATE OR REPLACE FUNCTION payment_bulk_post
+(in_transactions numeric[], in_batch_id int, in_source text, in_total numeric,
+ in_ar_ap_accno text, in_cash_accno text, in_approved bool,
+ in_payment_date date, in_account_class int)
+RETURNS int AS
+$$
+DECLARE payment_trans numeric[];
+BEGIN
+END;
+$$ language plpgsql;
+
+COMMENT ON FUNCTION payment_bulk_post
+(in_transactions numeric[], in_batch_id int, in_source text, in_total numeric,
+ in_ar_ap_accno text, in_cash_accno text, in_approved bool,
+ in_payment_date date, in_account_class int)
+IS
+$$ Note that in_transactions is a two-dimensional numeric array. Of each
+sub-array, the first element is the (integer) transaction id, and the second
+is the amount for that transaction. If the total of the amounts do not add up
+to in_total, then an error is generated. $$;
+
CREATE OR REPLACE 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 date,
- in_account_class int)
+(in_trans_id int, in_batch_id int, in_source text, in_amount numeric,
+ in_ar_ap_accno text, in_cash_accno text, in_approved bool,
+ in_payment_date date, in_account_class int)
RETURNS INT AS
$$
DECLARE out_entry_id int;
@@ -266,10 +288,9 @@
comment on function project_list_open(in_date date) is
$$ This function returns all projects that were open as on the date provided as
the argument.$$;
+-- Move this to the projects module when we start on that. CT
-
--- Move this to the projects module when we start on that. CT
CREATE OR REPLACE FUNCTION department_list(in_role char)
RETURNS SETOF department AS
$$
@@ -277,12 +298,13 @@
BEGIN
FOR out_department IN
SELECT * from department
- WHERE role = in_role
+ WHERE role = coalesce(in_role, role)
LOOP
return next out_department;
END LOOP;
END;
$$ language plpgsql;
+-- Move this into another module.
comment on function department_list(in_role char) is
$$ This function returns all department that match the role provided as
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.