diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-11-30 07:31:45 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-11-30 07:31:45 +0000 |
commit | 6935413a1b883aceb9bb6906b653ca77990c5439 (patch) | |
tree | 762e4d7dd49507c3e19ae883715399c75b906617 | |
parent | 57662811db634598271d5a750a68f48ae342fa81 (diff) |
Separated out multiple payment interface from new payment interface. Still not working, but almost there
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1926 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r-- | LedgerSMB/DBObject/Payment.pm | 15 | ||||
-rw-r--r-- | UI/Contact/contact.html | 2 | ||||
-rw-r--r-- | UI/payments/payments_detail.html | 148 | ||||
-rw-r--r-- | UI/payments/payments_filter.html | 93 | ||||
-rw-r--r-- | scripts/payment.pl | 15 | ||||
-rw-r--r-- | sql/modules/Business_type.sql | 9 | ||||
-rw-r--r-- | sql/modules/Payment.sql | 36 |
7 files changed, 308 insertions, 10 deletions
diff --git a/LedgerSMB/DBObject/Payment.pm b/LedgerSMB/DBObject/Payment.pm index 533a9cb8..62bef3bd 100644 --- a/LedgerSMB/DBObject/Payment.pm +++ b/LedgerSMB/DBObject/Payment.pm @@ -51,14 +51,25 @@ calculation. 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) = @_; diff --git a/UI/Contact/contact.html b/UI/Contact/contact.html index bceea462..0504e976 100644 --- a/UI/Contact/contact.html +++ b/UI/Contact/contact.html @@ -546,7 +546,7 @@ problems with multi-word single-quoted constructs in PI tags. -CT --> 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" diff --git a/UI/payments/payments_detail.html b/UI/payments/payments_detail.html new file mode 100644 index 00000000..96210ef1 --- /dev/null +++ b/UI/payments/payments_detail.html @@ -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> diff --git a/UI/payments/payments_filter.html b/UI/payments/payments_filter.html new file mode 100644 index 00000000..7f735715 --- /dev/null +++ b/UI/payments/payments_filter.html @@ -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> diff --git a/scripts/payment.pl b/scripts/payment.pl index 9faa97e4..5cea05ff 100644 --- a/scripts/payment.pl +++ b/scripts/payment.pl @@ -68,6 +68,21 @@ TT2 system. (hopefully it will... ) =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}; diff --git a/sql/modules/Business_type.sql b/sql/modules/Business_type.sql new file mode 100644 index 00000000..af11a9e5 --- /dev/null +++ b/sql/modules/Business_type.sql @@ -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; diff --git a/sql/modules/Payment.sql b/sql/modules/Payment.sql index b2f643ab..afd4abcc 100644 --- a/sql/modules/Payment.sql +++ b/sql/modules/Payment.sql @@ -93,7 +93,8 @@ BEGIN 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 @@ This then returns a set of contact information with a 2 dimensional array 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 @@ $$ language plpgsql; 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 @@ DECLARE out_department department%ROWTYPE; 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 |