[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3873] addons/1.3/budgetting/trunk
- Subject: SF.net SVN: ledger-smb:[3873] addons/1.3/budgetting/trunk
- From: ..hidden..
- Date: Sun, 16 Oct 2011 05:47:56 +0000
Revision: 3873
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3873&view=rev
Author: einhverfr
Date: 2011-10-16 05:47:56 +0000 (Sun, 16 Oct 2011)
Log Message:
-----------
Many budgetting fixes. The following areas are known not to work. The rest appear to work:
1) displaying search results
2) variance reports
3) Adding/displying notes
Additionally the UI needs a little bit of CSS to clean it up
Modified Paths:
--------------
addons/1.3/budgetting/trunk/LedgerSMB/DBObject/Budget.pm
addons/1.3/budgetting/trunk/scripts/budgets.pl
addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql
Added Paths:
-----------
addons/1.3/budgetting/trunk/UI/budgetting/search_criteria.html
Modified: addons/1.3/budgetting/trunk/LedgerSMB/DBObject/Budget.pm
===================================================================
--- addons/1.3/budgetting/trunk/LedgerSMB/DBObject/Budget.pm 2011-10-16 03:45:33 UTC (rev 3872)
+++ addons/1.3/budgetting/trunk/LedgerSMB/DBObject/Budget.pm 2011-10-16 05:47:56 UTC (rev 3873)
@@ -254,7 +254,7 @@
sub obsolete {
my ($self) = @_;
- $self->exec_method({funcname => 'budget__obsolete'});
+ $self->exec_method({funcname => 'budget__mark_obsolete'});
$self->{dbh}->commit;
}
Added: addons/1.3/budgetting/trunk/UI/budgetting/search_criteria.html
===================================================================
--- addons/1.3/budgetting/trunk/UI/budgetting/search_criteria.html (rev 0)
+++ addons/1.3/budgetting/trunk/UI/budgetting/search_criteria.html 2011-10-16 05:47:56 UTC (rev 3873)
@@ -0,0 +1,86 @@
+<?lsmb INCLUDE 'ui-header.html'
+ stylesheet=stylesheet ?>
+<?lsmb PROCESS elements.html ?>
+<body>
+<form action="<?lsmb script ?>" method="get">
+<div class="listtop"><?lsmb title ?></div>
+<div class="input_row" id = "reference_row">
+<div class="input_group">
+ <?lsmb INCLUDE input element_data = {
+ name = "reference",
+ value = reference,
+ type = "text",
+ size = "20",
+ class = 'reference',
+ label = text('Reference')
+ } ?>
+</div>
+<div class="input_group">
+ <?lsmb INCLUDE input element_data = {
+ name = "description",
+ value = description,
+ type = "text",
+ size = "50",
+ class = 'description'
+ label = text('Description')
+ }
+ ?>
+</div></div>
+<div class="input_row" id = "date_row">
+<div class="input_group">
+ <?lsmb INCLUDE input element_data = {
+ name = "start_date"
+ value = start_date
+ type = "text"
+ size = "11"
+ class = 'date'
+ label = text('Start Date') #'
+ } ?>
+</div>
+<div class="input_group">
+ <?lsmb INCLUDE input element_data = {
+ name = "end_date"
+ value = end_date
+ type = "text"
+ size = "11"
+ class = 'date'
+ label = text('End Date') #'
+ } ?>
+</div>
+
+</div></div>
+<div class="input_row" id = "description_row">
+<div class="input_group">
+ <?lsmb INCLUDE select element_data = {
+ text_attr = "description"
+ value_attr = "id"
+ default_values = [department_id]
+ options = departments
+ name = "department_id"
+ label = text('Department')
+ } ?>
+
+</div>
+<div class="input_group">
+ <?lsmb INCLUDE select element_data = {
+ text_attr = "description"
+ value_attr = "id"
+ default_values = [project_id]
+ options = projects
+ name = "project_id"
+ label = text('Project')
+ } ?>
+
+</div></div>
+<div class="input_row" id = "button_row">
+<?lsmb PROCESS button element_data = {
+ text = text('Search')
+ value = 'search'
+ name = 'action'
+ type = 'submit'
+ class = 'submit'
+} ?>
+</div>
+</form>
+</body>
+</html>
Modified: addons/1.3/budgetting/trunk/scripts/budgets.pl
===================================================================
--- addons/1.3/budgetting/trunk/scripts/budgets.pl 2011-10-16 03:45:33 UTC (rev 3872)
+++ addons/1.3/budgetting/trunk/scripts/budgets.pl 2011-10-16 05:47:56 UTC (rev 3873)
@@ -54,7 +54,14 @@
my ($budget) = @_;
$additional_rows = 5;
$additional_rows +=20 unless $budget->{rowcount};
+ $additional_rows = 0 if $budget->{id};
$budget->{rowcount} ||= 0;
+ for $row (@{$budget->{display_rows}}){
+ $row->{debit} = $budget->format_amount(amount => $row->{debit},
+ money => 1) if $row->{debit} ;
+ $row->{credit} = $budget->format_amount(amount => $row->{credit},
+ money => 1) if $row->{credit};
+ }
for (1 .. $additional_rows) {
push @{$budget->{display_rows}},
{accnoset => 0, index => $_ + $budget->{rowcount}};
@@ -116,7 +123,7 @@
{ name => 'action',
text => $budget->{_locale}->text('Obsolete'),
type => 'submit',
- value => 'approve',
+ value => 'obsolete',
class => 'submit',
},
];
@@ -128,7 +135,10 @@
template => 'budget_entry',
format => 'HTML'
);
- $budget->{hiddens} = {rowcount => $budget->{rowcount}};
+ $budget->{hiddens} = {
+ rowcount => $budget->{rowcount},
+ id => $budget->{id},
+ };
$template->render($budget);
}
@@ -162,11 +172,28 @@
my $budget = LedgerSMB::DBObject::Budget->new(
{base => $request, copy => 'base'}
);
+ $budget->merge($request, keys => ['stylesheet']);
$budget->get($request->{id});
+ $budget->{display_rows} = [];
+ for my $line (@{$budget->{lines}}){
+ my $row = {};
+ $row->{description} = $line->{description};
+ if ($line->{amount} < 0 ) {
+ $row->{debit} = $line->{amount} * -1;
+ } else {
+ $row->{credit} = $line->{amount};
+ }
+ my ($account) = $budget->call_procedure(
+ procname => 'account_get',
+ args => [$line->{account_id}]
+ );
+ $row->{account_id} = "$account->{accno}--$account->{description}";
+ push @{$budget->{display_rows}}, $row;
+ }
_render_screen($budget);
}
-=item save_budget
+=item save
LedgerSMB::DBObject::Budget properties required. Lines represented by
[property]_[line number] notation.
@@ -177,6 +204,18 @@
my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
for my $rownum (1 .. $request->{rowcount}){
my $line = {};
+ $request->{"debit_$rownum"} = $request->parse_amount(
+ amount => $request->{"debit_$rownum"}
+ );
+ $request->{"debit_$rownum"} = $request->format_amount(
+ {amount => $request->{"debit_$rownum"}, format => '1000.00'}
+ );
+ $request->{"credit_$rownum"} = $request->parse_amount(
+ amount => $request->{"credit_$rownum"}
+ );
+ $request->{"credit_$rownum"} = $request->format_amount(
+ {amount => $request->{"credit_$rownum"}, format => '1000.00'}
+ );
if ($request->{"debit_$rownum"} and $request->{"credit_$rownum"}){
$request->error($request->{_locale}->text(
'Cannot specify both debits and credits for budget line [_1]',
@@ -208,6 +247,9 @@
sub approve {
my ($request) = @_;
+ my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
+ $budget->approve;
+ view_budget($request);
}
=item reject
@@ -217,6 +259,9 @@
sub reject {
my ($request) = @_;
+ my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
+ $budget->reject;
+ begin_search($request);
}
=item obsolete
@@ -226,6 +271,9 @@
sub obsolete {
my ($request) = @_;
+ my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
+ $budget->obsolete;
+ view_budget($request);
}
=item add_note
@@ -246,13 +294,15 @@
my ($request) = @_;
my $budget = LedgerSMB::DBObject::Budget->new({base => $request});
@{$budget->{projects}} = $budget->list_projects;
+ unshift @{$budget->{projects}}, {};
@{$budget->{departments}} = $budget->list_departments;
+ unshift @{$budget->{departments}}, {};
# TODO: Add buttons
my $template = LedgerSMB::Template->new(
user => $request->{_user},
locale => $request->{_locale},
path => 'UI/budgetting',
- template => 'begin_search',
+ template => 'search_criteria',
format => 'HTML'
);
Modified: addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql
===================================================================
--- addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql 2011-10-16 03:45:33 UTC (rev 3872)
+++ addons/1.3/budgetting/trunk/sql/modules/Budgetting.sql 2011-10-16 05:47:56 UTC (rev 3873)
@@ -161,6 +161,15 @@
$$Saves the extended budget info passed through to the function. See the
comment on type budget_info_ext for more information.$$;
+CREATE OR REPLACE FUNCTION budget__approve(in_id int)
+RETURNS budget_info_ext AS $$
+UPDATE budget_info
+ set approved_at = now(), approved_by = person__get_my_entity_id()
+ WHERE id = $1;
+
+SELECT budget__get_info($1);
+$$ language sql;
+
CREATE OR REPLACE FUNCTION budget__save_details(in_id int, in_details text[])
RETURNS budget_info_ext AS
$$
@@ -302,7 +311,7 @@
$$
UPDATE budget_info
set obsolete_by = person__get_my_entity_id(), obsolete_at = now()
- WHERE id = $1;
+ WHERE id = $1 and approved_by is not null;
SELECT budget__get_info($1)
$$ language sql;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.