diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 557b269..172ad74 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -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 @@ -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 @@ -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 diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index 727b437..1a80ae2 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -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 \ No newline at end of file diff --git a/app/views/payment_runs/edit.html.erb b/app/views/payment_runs/edit.html.erb index 6fa264e..11d7445 100644 --- a/app/views/payment_runs/edit.html.erb +++ b/app/views/payment_runs/edit.html.erb @@ -1,4 +1,5 @@ +<% if @matches.count > 0 %>

<%= t(:automatic_matching, :scope => :reports) %>

@@ -14,6 +15,7 @@ end %>
+<% end %> @@ -262,7 +264,6 @@ end %> - <% puts "*","*","*","*",op.id,"*","*" if op.journal_id.blank? %> <% jrnl = Journal.find(op.journal_id)%> diff --git a/app/views/reports/subsidiary_ledger_journal.html.erb b/app/views/reports/subsidiary_ledger_journal.html.erb index 1e1fc25..a62e1a1 100644 --- a/app/views/reports/subsidiary_ledger_journal.html.erb +++ b/app/views/reports/subsidiary_ledger_journal.html.erb @@ -78,10 +78,10 @@ <%= t(:bill , :scope => :reports) %> - - <% unless jo["status"].blank? %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 048d7f6..3d37b1b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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
<%= jrnl.journal_type.to_s %> <%= link_to jrnl.number, edit_journal_path(jrnl)%> - <%= t(:diff_by_invoice , :scope => :reports) %> + <%= t(:diff_by_kid, :scope => :reports) %> - <%= t(:diff_by_kid, :scope => :reports) %> + <%= t(:diff_by_invoice , :scope => :reports) %> <%= t(:operation_status, :scope => :reports) %> @@ -114,19 +114,27 @@ <%= jo["jbill"] %> + <% 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 %> + <% 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%> - <%= closed_by(jo["status"]) %> + <%= t(:"closed_by_#{closed_by(jo["status"])}",:scope => :reports) %> <%= button_to_function t(:show_closed, :scope => :reports),"highlight('closed','.l#{jo["ledgid"]}closed#{jo["status"]}')" unless jo["status"].blank?%> <%= button_to(t(:open, :scope => :reports), open_closed_operations_reports_path(:closed_op_id => jo["status"],:redirection => @stored_params)) %>