Skip to content

Commit

Permalink
show diff by kid or by bill
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwen Blel committed Dec 28, 2011
1 parent e256501 commit af0fc0f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
22 changes: 20 additions & 2 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@ def subsidiary_ledger_journal
@journal_operations = Report.report_subsidiary_ledger_journal(periods, @account, from_ledger, to_ledger, @car, @unit, @project, @journal_type)
@stored_params = params
@stored_params.delete(:utf8);@stored_params.delete(:commit)

@diff = Hash.new
@journal_operations.each do |op|

@diff[:"#{op["ledgid"]}"] = Hash.new if @diff[:"#{op["ledgid"]}"].blank?
if op["status"].blank?
unless op["jkid"].blank?
@diff[:"#{op["ledgid"]}"][:"#{"k" + op["jkid"].to_s}"]= 0 if @diff[:"#{op["ledgid"]}"][:"#{"k" + op["jkid"].to_s}"].blank?
@diff[:"#{op["ledgid"]}"][:"#{"k" + op["jkid"].to_s}"] += op["balance"].to_f
end

unless op["jbill"].blank?
@diff[:"#{op["ledgid"]}"][:"#{"b" + op["jbill"].to_s}"] = 0 if @diff[:"#{op["ledgid"]}"][:"#{"b" + op["jbill"].to_s}"].blank?
@diff[:"#{op["ledgid"]}"][:"#{"b" + op["jbill"].to_s}"] += op["balance"].to_f
end
end
end

end

def open_closed_operations
Expand All @@ -145,7 +163,7 @@ def open_closed_operations
#removing closed operation entry from database
co = ClosedOperation.find(params[:closed_op_id])
co.delete

redirect_to params[:redirection]

end
Expand All @@ -158,7 +176,7 @@ def dagbok
@project = ( project == 'null' ? nil : Project.find(project))
@car = ( car == 'null' ? nil : Car.find(car))
@journal_type = ( journal_type == 'null' ? nil : JournalType.find(journal_type))
puts @journal_operations.count

end

private
Expand Down
7 changes: 3 additions & 4 deletions app/helpers/reports_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def car(id)
end

def closed_by(closed_op_id)
"closed by " + JournalOperation.where(:closed_operation_id => closed_op_id).first.closed_operation.matched_by.to_s
#t(:closed_status, :scope => :reports)
JournalOperation.where(:closed_operation_id => closed_op_id).first.closed_operation.matched_by.to_s
end

end
end
3 changes: 2 additions & 1 deletion app/views/payment_runs/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

<% if @matches.count > 0 %>
<div><h2><%= t(:automatic_matching, :scope => :reports) %></h2></div>

<form method='post' action='/payment_runs/create'>
Expand All @@ -14,6 +15,7 @@
end
%>
</form>
<% end %>

<table class='repport5'>

Expand Down Expand Up @@ -262,7 +264,6 @@ end
%>

<tr>
<% puts "*","*","*","*",op.id,"*","*" if op.journal_id.blank? %>
<% jrnl = Journal.find(op.journal_id)%>
<td> <%= jrnl.journal_type.to_s %> </td>
<td> <%= link_to jrnl.number, edit_journal_path(jrnl)%> </td>
Expand Down
26 changes: 17 additions & 9 deletions app/views/reports/subsidiary_ledger_journal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@
<%= t(:bill , :scope => :reports) %>
</td>
<td style="text-align: right">
<%= t(:diff_by_invoice , :scope => :reports) %>
<%= t(:diff_by_kid, :scope => :reports) %>
</td>
<td style="text-align: right">
<%= t(:diff_by_kid, :scope => :reports) %>
<%= t(:diff_by_invoice , :scope => :reports) %>
</td>
<td style="text-align: right">
<%= t(:operation_status, :scope => :reports) %>
Expand Down Expand Up @@ -114,19 +114,27 @@
<td class="bill" style="text-align: right">
<%= jo["jbill"] %>
</td>
<td class="diff_invoice" style="text-align: right">
<td class="diff_kid" style="text-align: right">
<% if jo["status"].blank? %>
<%= number_with_precision(( (jo["jkid"].blank? and jo["jbill"].blank?) ? jo["balance"] : nil ), :locale =>I18n.locale) %>
<% end %>
<% if jo["jkid"].blank? and jo["jbill"].blank? %>
<%= number_with_precision(jo["balance"], :locale =>I18n.locale) %>
<% elsif !jo["jkid"].blank?%>
<%= number_with_precision(@diff[:"#{jo["ledgid"]}"][:"#{"k" + jo["jkid"].to_s}"],:locale => I18n.locale) %>
<%end%>
<% end %>
</td>
<td class="diff_kid" style="text-align: right">
<td class="diff_invoice" style="text-align: right">
<% if jo["status"].blank? %>
<%= number_with_precision(( (jo["jkid"].blank? and jo["jbill"].blank?) ? jo["balance"] : nil ), :locale =>I18n.locale) %>
<% end %>
<% if jo["jkid"].blank? and jo["jbill"].blank? %>
<%= number_with_precision(jo["balance"],:locale => I18n.locale) %>
<% elsif !jo["jbill"].blank? %>
<%= number_with_precision(@diff[:"#{jo["ledgid"]}"][:"#{"b" + jo["jbill"].to_s}"],:locale => I18n.locale) %>
<% end %>
<% end%>
</td>
<% unless jo["status"].blank? %>
<td class="status">
<%= closed_by(jo["status"]) %>
<%= t(:"closed_by_#{closed_by(jo["status"])}",:scope => :reports) %>
</td>
<td> <%= button_to_function t(:show_closed, :scope => :reports),"highlight('closed','.l#{jo["ledgid"]}closed#{jo["status"]}')" unless jo["status"].blank?%> </td>
<td> <%= button_to(t(:open, :scope => :reports), open_closed_operations_reports_path(:closed_op_id => jo["status"],:redirection => @stored_params)) %> </td>
Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,9 @@ en:
invoice_number: Invoice Number
operation_status: Status
actions: Actions
closed_status: Closed
closed_by_: Closed
closed_by_k: Closed(KID)
closed_by_b: Closed(Bill)
show_closed: Show Closed
open: Open
open_status: Open
Expand Down

0 comments on commit af0fc0f

Please sign in to comment.