Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Saving work to be able to fetch it later.
- Loading branch information
Showing
10 changed files
with
342 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletions
24
app/controllers/backend/bank_statement_items_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
module Backend | ||
class BankStatementItemsController < Backend::BaseController | ||
def new | ||
safe_params = permit_params | ||
return head :bad_request unless @bank_statement = BankStatement.find(safe_params[:bank_statement_id]) | ||
@bank_statement_item = BankStatementItem.new | ||
permitted_params = params.permit(:debit, :credit, :transfered_on, :letter, :name, :bank_statement_id) | ||
@bank_statement_item.attributes = permitted_params | ||
@bank_statement_item.attributes = safe_params | ||
if request.xhr? | ||
render partial: 'reconciliation_row_form', object: @bank_statement_item | ||
render partial: 'bank_statement_item_row_form', locals: { item: @bank_statement_item, bank_statement: @bank_statement } | ||
else | ||
redirect_to_back | ||
end | ||
end | ||
|
||
def create | ||
safe_params = permit_params | ||
return head :bad_request unless @bank_statement = BankStatement.find(safe_params[:bank_statement_id]) | ||
letter = @bank_statement.next_letter | ||
@bank_statement_item = BankStatementItem.new(safe_params.merge(letter: letter)) | ||
return head :bad_request unless @bank_statement_item.save! | ||
render 'bank_statements/bank_statement_item', item: @bank_statement_item | ||
end | ||
|
||
protected | ||
|
||
def permit_params | ||
params | ||
.reject { |_key, value| value == '0.0' || value == '' } | ||
.permit(:debit, :credit, :transfered_on, :letter, :name, :bank_statement_id) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/views/backend/bank_statement_items/_bank_statement_item_row_form.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
= simple_form_for [:backend, bank_statement, item], remote: true do |f| | ||
%tr.bank-statement-item-type{ class: "#{item.id}-bank-statement-item" } | ||
%td.hidden= f.hidden_field :name, class: "name" | ||
%td.hidden= f.hidden_field :transfered_on | ||
%td.hidden= f.hidden_field :debit | ||
%td.hidden= f.hidden_field :credit | ||
%td.hidden= f.hidden_field :letter, class: "bank-statement-letter" | ||
%td.hidden= f.hidden_field :initiated_on | ||
%td.hidden= f.hidden_field :transaction_number | ||
%td.del | ||
= link_to "#", class: "destroy" do | ||
%i | ||
%td.type-icon | ||
%i | ||
%td.name= item.name | ||
%td | ||
%td.center.debit= item.debit || 0.0 | ||
%td.center.credit= item.credit || 0.0 | ||
%td.center.bank-statement-letter= item.letter | ||
%td.clear | ||
%a{ href: "#" } | ||
%i | ||
= :clear.tl | ||
%td |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/views/backend/bank_statements/_bank_statement_item.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
%tr.bank-statement-item-type{ class: "#{item.id}-bank-statement-item" } | ||
%td.hidden= hidden_field_tag "items[#{item.id}][name]", item.name, class: "name" | ||
%td.hidden= hidden_field_tag "items[#{item.id}][transfered_on]", item.transfered_on | ||
%td.hidden= hidden_field_tag "items[#{item.id}][debit]", item.debit | ||
%td.hidden= hidden_field_tag "items[#{item.id}][credit]", item.credit | ||
%td.hidden= hidden_field_tag "items[#{item.id}][letter]", item.letter, class: "bank-statement-letter" | ||
%td.hidden= hidden_field_tag "items[#{item.id}][initiated_on]", item.initiated_on | ||
%td.hidden= hidden_field_tag "items[#{item.id}][transaction_number]", item.transaction_number | ||
|
||
%td.del | ||
= link_to "#", class: "destroy" do | ||
%i | ||
%td.type-icon | ||
%i | ||
%td.name= item.name | ||
%td | ||
%td.center.debit= item.debit || 0.0 | ||
%td.center.credit= item.credit || 0.0 | ||
%td.center.bank-statement-letter= item.letter | ||
%td.clear | ||
%a{ href: "#" } | ||
%i | ||
= :clear.tl | ||
%td |
17 changes: 17 additions & 0 deletions
17
app/views/backend/bank_statements/_journal_entry_item.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
%tr.journal-entry-item-type | ||
%td.hidden= hidden_field_tag "journal_entry_items[#{item.id}][bank_statement_letter]", item.bank_statement_letter, class: "bank-statement-letter" | ||
%td.del | ||
%td.type-icon | ||
%i | ||
%td.name= item.name | ||
%td | ||
%td.center.debit= item.real_debit || 0.0 | ||
%td.center.credit= item.real_credit || 0.0 | ||
%td.center.bank-statement-letter= item.bank_statement_letter | ||
%td.clear | ||
%a{ href: "#" } | ||
%i | ||
= :clear.tl | ||
%td.complete | ||
%a{ href: "#" } | ||
= :complete.tl |
102 changes: 102 additions & 0 deletions
102
app/views/backend/bank_statements/old_reconciliation.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
- content_for(:main_toolbar) do | ||
= button_tag(:reset.tl, type: :button, class: "btn btn-default", id: "reset_reconciliation") | ||
= button_tag(:auto_reconciliate.tl, type: :button, class: "btn btn-default", id: "auto_reconciliation") | ||
|
||
= form_tag({}, class: "reconciliation-form") do | ||
-# = field_set(:details) do | ||
= attributes_list stamps: false do |l| | ||
- l.attribute(:number) | ||
- l.attribute(:started_on) | ||
- l.attribute(:stopped_on) | ||
= field_set(:entries_to_point) do | ||
.active-list | ||
/ Prepare more reconciliation letters than required | ||
%table.list.bank-reconciliation-items{ data: { next_letters: @bank_statement.cash_next_reconciliation_letters.take(@items.size), currency_precision: Nomen::Currency.find(@bank_statement.currency).precision } } | ||
|
||
%thead | ||
%tr | ||
%th.payment-buttons{colspan: 4} | ||
= tool_to(:new_outgoing_payment.tl, { controller: :outgoing_payments, action: :new }, tabindex: -1, method: :get, style: "display: none;") | ||
= tool_to(:new_incoming_payment.tl, { controller: :incoming_payments, action: :new }, tabindex: -1, method: :get, style: "display: none;") | ||
%th.center= BankStatementItem.human_attribute_name(:debit) | ||
%th.center= BankStatementItem.human_attribute_name(:credit) | ||
%tr | ||
%th.right{colspan: 4}= :initial_balance_of_bank_statement.tl | ||
%th.center= text_field_tag("bank_statement[initial_balance_debit]", @bank_statement.initial_balance_debit || 0.0, id: "initial_balance_debit", class: "center", data: { exclusive_nullify: "#initial_balance_credit" }) | ||
%th.center= text_field_tag("bank_statement[initial_balance_credit]", @bank_statement.initial_balance_credit || 0.0, id: "initial_balance_credit", class: "center", data: { exclusive_nullify: "#initial_balance_debit" }) | ||
|
||
%tfoot | ||
%tr.total | ||
%th.add-bank-statement-item-cont{colspan: 4} | ||
= date_field_tag "add-bank-statement-item-date", nil, id: "add-bank-statement-item-date", data: { label: :add_line.tl, classes: "btn btn-new icn" } | ||
= :reconciled_total.tl | ||
%td.center.reconciliated-debit 0.0 | ||
%td.center.reconciliated-credit 0.0 | ||
%th{colspan: 3} | ||
%tr.total.remaining-reconciliation-balance | ||
%th{colspan: 4} | ||
= :remaining_amount_to_reconcile.tl | ||
%td.center.remaining-reconciliated-debit 0.0 | ||
%td.center.remaining-reconciliated-credit 0.0 | ||
%th{colspan: 3} | ||
%tr.total | ||
%th{colspan: 4} | ||
= :final_balance.tl | ||
%td.center{ data: { use: "#initial_balance_debit,.bank-statement-item-type .debit", calculate_round: 2 } } 0.0 | ||
%td.center{ data: { use: "#initial_balance_credit,.bank-statement-item-type .credit", calculate_round: 2 } } 0.0 | ||
%th{colspan: 3} | ||
|
||
%tbody.items | ||
= render partial: "reconciliation_date_section" # template used by JS | ||
- @items_grouped_by_date.each do |date, items| | ||
= render partial: "reconciliation_date_section", locals: { date: date } | ||
- items.each do |item| | ||
- if BankStatementItem === item | ||
%tr.bank-statement-item-type{ class: "#{item.id}-bank-statement-item" } | ||
%td.hidden= hidden_field_tag "items[#{item.id}][name]", item.name, class: "name" | ||
%td.hidden= hidden_field_tag "items[#{item.id}][transfered_on]", item.transfered_on | ||
%td.hidden= hidden_field_tag "items[#{item.id}][debit]", item.debit | ||
%td.hidden= hidden_field_tag "items[#{item.id}][credit]", item.credit | ||
%td.hidden= hidden_field_tag "items[#{item.id}][letter]", item.letter, class: "bank-statement-letter" | ||
%td.hidden= hidden_field_tag "items[#{item.id}][initiated_on]", item.initiated_on | ||
%td.hidden= hidden_field_tag "items[#{item.id}][transaction_number]", item.transaction_number | ||
|
||
%td.del | ||
= link_to "#", class: "destroy" do | ||
%i | ||
%td.type-icon | ||
%i | ||
%td.name= item.name | ||
%td | ||
%td.center.debit= item.debit || 0.0 | ||
%td.center.credit= item.credit || 0.0 | ||
%td.center.bank-statement-letter= item.letter | ||
%td.clear | ||
%a{ href: "#" } | ||
%i | ||
= :clear.tl | ||
%td | ||
|
||
- else | ||
%tr.journal-entry-item-type | ||
%td.hidden= hidden_field_tag "journal_entry_items[#{item.id}][bank_statement_letter]", item.bank_statement_letter, class: "bank-statement-letter" | ||
%td.del | ||
%td.type-icon | ||
%i | ||
%td.name= item.name | ||
%td | ||
%td.center.debit= item.real_debit || 0.0 | ||
%td.center.credit= item.real_credit || 0.0 | ||
%td.center.bank-statement-letter= item.bank_statement_letter | ||
%td.clear | ||
%a{ href: "#" } | ||
%i | ||
= :clear.tl | ||
%td.complete | ||
%a{ href: "#" } | ||
= :complete.tl | ||
|
||
= form_actions do | ||
= button_tag :save.tl, class: 'btn btn-primary' | ||
= link_to :cancel.tl, :back, class: "btn" |
Oops, something went wrong.