Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 2 commits
  • 36 files changed
  • 0 commit comments
  • 1 contributor
Showing with 279 additions and 147 deletions.
  1. +4 −2 app/controllers/assets_controller.rb
  2. +11 −0 app/controllers/financial_years_controller.rb
  3. +4 −2 app/helpers/application_helper.rb
  4. +5 −3 app/models/asset.rb
  5. +27 −20 app/models/asset_depreciation.rb
  6. +38 −17 app/models/financial_year.rb
  7. +2 −0  app/models/journal_entry.rb
  8. +2 −1  app/views/assets/_form.html.haml
  9. +1 −1  app/views/assets/show.html.haml
  10. +6 −0 app/views/financial_years/generate_last_journal_entry.html.haml
  11. +4 −0 app/views/financial_years/show.html.haml
  12. +2 −1  app/views/journal_entries/show.html.haml
  13. +2 −0  config/locales/arb/action.yml
  14. +3 −0  config/locales/arb/models.yml
  15. +4 −1 config/locales/eng/action.yml
  16. +8 −0 config/locales/eng/models.yml
  17. +4 −1 config/locales/fra/action.yml
  18. +4 −0 config/locales/fra/models.yml
  19. +2 −0  config/locales/jpn/action.yml
  20. +3 −0  config/locales/jpn/models.yml
  21. +2 −0  config/locales/spa/action.yml
  22. +3 −0  config/locales/spa/models.yml
  23. +2 −2 config/menus.yml
  24. +2 −2 config/rights.yml
  25. +2 −1  config/routes.rb
  26. +12 −0 db/migrate/20120806083148_update_assets.rb
  27. +26 −22 db/schema.rb
  28. +3 −1 lib/ekylibre/models.rb
  29. +11 −0 test/fixtures/accounts.yml
  30. +21 −19 test/fixtures/asset_depreciations.yml
  31. +7 −4 test/fixtures/assets.yml
  32. +14 −13 test/fixtures/financial_years.yml
  33. +1 −1  test/functional/financial_years_controller_test.rb
  34. +21 −19 test/unit/asset_depreciation_test.rb
  35. +2 −1  test/unit/asset_test.rb
  36. +14 −13 test/unit/financial_year_test.rb
View
6 app/controllers/assets_controller.rb
@@ -35,11 +35,13 @@ def index
list(:depreciations, :model => :asset_depreciations, :conditions => {:asset_id => ['params[:id]']}, :order => :position) do |t|
t.column :amount, :currency => true
+ t.column :asset_amount, :currency => true
+ t.column :depreciated_amount, :currency => true
t.column :started_on
t.column :stopped_on
t.column :code, :through => :financial_year, :url => true
- t.column :journal_entry, :url => true
- t.action :edit
+ t.column :number, :through => :journal_entry, :url => true
+ t.action :edit, :if => "RECORD.journal_entry.nil? "
end
# Displays details of an asset
View
11 app/controllers/financial_years_controller.rb
@@ -132,4 +132,15 @@ def destroy
redirect_to :action => :index
end
+ def generate_last_journal_entry
+ return unless @financial_year = find_and_check(:financial_year)
+ if request.get?
+ params[:assets_depreciations] ||= 1
+ elsif request.post?
+ @financial_year.generate_last_journal_entry(params)
+ redirect_to journal_entry_url(@financial_year.last_journal_entry)
+ end
+ t3e @financial_year.attributes
+ end
+
end
View
6 app/helpers/application_helper.rb
@@ -850,7 +850,9 @@ def toolbar(options={}, &block)
name = args[0]
args[1] ||= {}
args[2] ||= {}
- args[0] = ::I18n.t("actions.#{args[1][:controller]||controller_name}.#{name}".to_sym, {:default=>["labels.#{name}".to_sym]}.merge(args[2].delete(:i18n)||{})) if name.is_a? Symbol
+ if name.is_a? Symbol
+ args[0] = ::I18n.t("actions.#{args[1][:controller]||controller_name}.#{name}".to_sym, {:default=>"labels.#{name}".to_sym}.merge(args[2].delete(:i18n)||{}))
+ end
if name.is_a? Symbol and name!=:back
args[1][:action] ||= name
end
@@ -879,7 +881,7 @@ def toolbar(options={}, &block)
url[:controller] ||= controller_name
url[:action] = action
url[:id] = record.id
- code << tool_to(t("actions.#{url[:controller]}.#{action}", record.attributes.symbolize_keys), url, tag_options) if authorized?(url)
+ code << tool_to(t("actions.#{url[:controller]}.#{action}".to_sym, {:default=>"labels.#{action}".to_sym}.merge(record.attributes.symbolize_keys)), url, tag_options) if authorized?(url)
end
end
if code.strip.length>0
View
8 app/models/asset.rb
@@ -20,9 +20,10 @@
#
# == Table: assets
#
-# account_id :integer not null
+# allocation_account_id :integer not null
# ceded :boolean
# ceded_on :date
+# charges_account_id :integer
# comment :text
# company_id :integer not null
# created_at :datetime not null
@@ -54,7 +55,8 @@
class Asset < CompanyRecord
DEPRECIATION_METHODS = ['simplified_linear', 'linear'] # graduated
acts_as_numbered
- belongs_to :account
+ belongs_to :charges_account, :class_name => "Account"
+ belongs_to :allocation_account, :class_name => "Account"
belongs_to :journal
has_many :depreciations, :class_name => "AssetDepreciation", :order => :position
has_many :planned_depreciations, :class_name => "AssetDepreciation", :order => :position, :conditions => "NOT protected OR accounted_at IS NULL", :dependent => :destroy
@@ -62,7 +64,7 @@ class Asset < CompanyRecord
validates_numericality_of :current_amount, :depreciable_amount, :depreciated_amount, :depreciation_percentage, :purchase_amount, :allow_nil => true
validates_length_of :currency, :allow_nil => true, :maximum => 3
validates_length_of :depreciation_method, :name, :number, :allow_nil => true, :maximum => 255
- validates_presence_of :account, :company, :depreciable_amount, :depreciated_amount, :depreciation_method, :journal, :name, :number, :started_on, :stopped_on
+ validates_presence_of :allocation_account, :company, :depreciable_amount, :depreciated_amount, :depreciation_method, :journal, :name, :number, :started_on, :stopped_on
#]VALIDATORS]
validates_uniqueness_of :name
View
47 app/models/asset_depreciation.rb
@@ -20,25 +20,27 @@
#
# == Table: asset_depreciations
#
-# accountable :boolean not null
-# accounted_at :datetime
-# amount :decimal(19, 4) not null
-# asset_id :integer not null
-# company_id :integer not null
-# created_at :datetime not null
-# created_on :date not null
-# creator_id :integer
-# depreciation :text
-# financial_year_id :integer
-# id :integer not null, primary key
-# journal_entry_id :integer
-# lock_version :integer default(0), not null
-# position :integer
-# protected :boolean not null
-# started_on :date not null
-# stopped_on :date not null
-# updated_at :datetime not null
-# updater_id :integer
+# accountable :boolean not null
+# accounted_at :datetime
+# amount :decimal(19, 4) not null
+# asset_amount :decimal(19, 4)
+# asset_id :integer not null
+# company_id :integer not null
+# created_at :datetime not null
+# created_on :date not null
+# creator_id :integer
+# depreciated_amount :decimal(19, 4)
+# depreciation :text
+# financial_year_id :integer
+# id :integer not null, primary key
+# journal_entry_id :integer
+# lock_version :integer default(0), not null
+# position :integer
+# protected :boolean not null
+# started_on :date not null
+# stopped_on :date not null
+# updated_at :datetime not null
+# updater_id :integer
#
class AssetDepreciation < CompanyRecord
acts_as_list :scope => :asset_id
@@ -46,7 +48,7 @@ class AssetDepreciation < CompanyRecord
belongs_to :financial_year
belongs_to :journal_entry
#[VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
- validates_numericality_of :amount, :allow_nil => true
+ validates_numericality_of :amount, :asset_amount, :depreciated_amount, :allow_nil => true
validates_inclusion_of :accountable, :protected, :in => [true, false]
validates_presence_of :amount, :asset, :company, :created_on, :started_on, :stopped_on
#]VALIDATORS]
@@ -66,6 +68,11 @@ class AssetDepreciation < CompanyRecord
self.company = self.asset.company if self.asset
end
+ before_validation do
+ self.depreciated_amount = self.asset.depreciations.where("stopped_on < ?", self.started_on).sum(:amount) + self.amount
+ self.asset_amount = self.asset.depreciable_amount - self.depreciated_amount
+ end
+
validate do
# A start day must be the depreciation start or a financial year start
unless self.started_on == self.asset.started_on or self.started_on.beginning_of_month == self.started_on
View
55 app/models/financial_year.rb
@@ -20,26 +20,28 @@
#
# == Table: financial_years
#
-# closed :boolean not null
-# code :string(12) not null
-# company_id :integer not null
-# created_at :datetime not null
-# creator_id :integer
-# currency :string(3)
-# currency_precision :integer
-# id :integer not null, primary key
-# lock_version :integer default(0), not null
-# started_on :date not null
-# stopped_on :date not null
-# updated_at :datetime not null
-# updater_id :integer
+# closed :boolean not null
+# code :string(12) not null
+# company_id :integer not null
+# created_at :datetime not null
+# creator_id :integer
+# currency :string(3)
+# currency_precision :integer
+# id :integer not null, primary key
+# last_journal_entry_id :integer
+# lock_version :integer default(0), not null
+# started_on :date not null
+# stopped_on :date not null
+# updated_at :datetime not null
+# updater_id :integer
#
class FinancialYear < CompanyRecord
attr_readonly :currency
- belongs_to :company
+ belongs_to :last_journal_entry, :class_name => "JournalEntry"
has_many :account_balances, :class_name=>"AccountBalance", :foreign_key=>:financial_year_id, :dependent=>:delete_all
+ has_many :asset_depreciations
#[VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
validates_numericality_of :currency_precision, :allow_nil => true, :only_integer => true
validates_length_of :currency, :allow_nil => true, :maximum => 3
@@ -265,10 +267,29 @@ def print_synthesis(template)
template = ::LibXML::XML::Document.file(template.to_s)
root = template.root
columns = []
-
-
-
return "data"
end
+ # Generate last journal entry with assets depreciations (optionnally)
+ def generate_last_journal_entry(options = {})
+ unless self.last_journal_entry
+ self.create_last_journal_entry!(:printed_on => self.stopped_on, :journal_id => self.company.journal(:various).id)
+ end
+
+ # Empty journal entry
+ self.last_journal_entry.lines.clear
+
+ if options[:assets_depreciations]
+ for depreciation in self.asset_depreciations
+ name = tc(:bookkeep, :resource => Asset.model_name.human, :number => depreciation.asset.number, :name => depreciation.asset.name, :position => depreciation.position, :total => depreciation.asset.depreciations.count)
+ # Charges
+ self.last_journal_entry.add_debit(name, depreciation.asset.charges_account, depreciation.amount)
+ # Allocation
+ self.last_journal_entry.add_credit(name, depreciation.asset.allocation_account, depreciation.amount)
+ depreciation.update_attributes(:journal_entry_id => self.last_journal_entry.id)
+ end
+ end
+ return self
+ end
+
end
View
2  app/models/journal_entry.rb
@@ -50,6 +50,7 @@ class JournalEntry < CompanyRecord
belongs_to :financial_year
belongs_to :journal
belongs_to :resource, :polymorphic=>true
+ has_many :asset_depreciations, :dependent=>:nullify
has_many :useful_lines, :conditions=>["balance != ?", 0.0], :foreign_key=>:entry_id, :class_name=>"JournalEntryLine"
has_many :lines, :foreign_key=>:entry_id, :dependent=>:delete_all, :class_name=>"JournalEntryLine"
has_many :outgoing_payments, :dependent=>:nullify
@@ -58,6 +59,7 @@ class JournalEntry < CompanyRecord
has_many :incoming_payment_uses, :dependent=>:nullify
has_many :purchases, :dependent=>:nullify
has_many :sales, :dependent=>:nullify
+ has_one :financial_year_as_last, :foreign_key => :last_journal_entry_id, :class_name => "FinancialYear", :dependent => :nullify
#[VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
validates_numericality_of :balance, :credit, :debit, :original_credit, :original_currency_rate, :original_debit, :allow_nil => true
validates_length_of :original_currency, :allow_nil => true, :maximum => 3
View
3  app/views/assets/_form.html.haml
@@ -21,4 +21,5 @@
=formalize do |f|
-f.title :accountancy
-f.field :asset, :journal_id, :choices=>{:reflection=>:journals}, :new=>true
- -f.field :asset, :account_id, :choices=>:account, :new=>true
+ -f.field :asset, :allocation_account_id, :choices=>:account, :new=>true
+ -f.field :asset, :charges_account_id, :choices=>:account, :new=>true
View
2  app/views/assets/show.html.haml
@@ -6,7 +6,7 @@
-l.attribute :name
-l.attribute :depreciation_method
-l.attribute :depreciable_amount, :currency => true
- -l.attribute :depreciated_amount, :currency => true
+ -# l.attribute :depreciated_amount, :currency => true
-l.attribute :depreciation_percentage
-l.attribute :started_on
-l.attribute :stopped_on
View
6 app/views/financial_years/generate_last_journal_entry.html.haml
@@ -0,0 +1,6 @@
+=form_tag() do
+ %fieldset
+ -#%legend=tc(:generate_last_journal_entry)
+ =formalize do |f|
+ -f.field content_tag(:label, tc(:with_assets_depreciations), :for=>:assets_depreciations), check_box_tag(:assets_depreciations)
+ .actions=submit_tag tc(:generate), :name=>nil
View
4 app/views/financial_years/show.html.haml
@@ -1,5 +1,8 @@
=toolbar do |t|
-t.compute_balances @financial_year, :method=>:post
+ -attrs = {}
+ -attrs["data-confirm"] = "labels.are_you_sure".t if @financial_year.last_journal_entry
+ -t.generate_last_journal_entry @financial_year, attrs
-t.print_balance_sheet @financial_year
-t.print_income_statement @financial_year
-if @financial_year == @current_company.closable_financial_year
@@ -11,6 +14,7 @@
-l.attribute :stopped_on
-l.attribute :closed
-l.attribute :code
+ -l.attribute :last_journal_entry, :url => true
=tabbox(:financial_year) do |tb|
-tb.tab(@financial_year.closed ? :balance : :last_computed_balance) do
View
3  app/views/journal_entries/show.html.haml
@@ -1,6 +1,7 @@
=journals_tag
=toolbar do |t|
- -t.edit @journal_entry unless @journal_entry.closed?
+ -t.edit @journal_entry if @journal_entry.updateable?
+ -t.destroy @journal_entry, :method => :delete, "data-confirm" => tg(:are_you_sure) if @journal_entry.destroyable?
=attributes_list(@journal_entry) do |l|
-l.attribute :number
View
2  config/locales/arb/action.yml
@@ -850,6 +850,7 @@ arb:
general: "معلومات عامة"
general_informations: "معلومات عامة"
general_ledger: "دفتر الحسابات"
+ # generate: "Generate"
give_discount: "منح خصومات"
go: "صلاحية"
graph_statistics: "رسومات احصائية"
@@ -1437,6 +1438,7 @@ arb:
warehouse_update: "تعديل موقع التخزين" #?
warehouses: "النظر بقائمة مواقع التخزين"
weight: "الوزن"
+ # with_assets_depreciations: "With assets depreciations"
with_prints: "(وتشمل الطباعة (الفواتير والاوامر"
x_cashes:
one: "حساب بنكي واحد"
View
3  config/locales/arb/models.yml
@@ -17,6 +17,8 @@ arb:
area: #?
code: "الرمز الداخلي" #?
created_at: "تم انشائه في" #?
+ asset_depreciation:
+ # asset_amount: "Accountable value"
bank_statement: #?
number: "رقم" #?
original_debit: "الدين" #?
@@ -1763,6 +1765,7 @@ arb:
sale: "انشاء طلب بيع"
sales_invoice: "انشاء فاتورة"
financial_year:
+ # bookkeep: "[%{resource} %{number}] Depreciation of %{name} (%{position}/%{total})"
code:
double: "EX%{first_year}/%{second_year}"
single: "EX%{first_year}"
View
5 config/locales/eng/action.yml
@@ -15,7 +15,7 @@ eng:
new: "Add a postal area"
assets:
cede: "Cede %{name}" #?
- depreciate: "Compute depreciations of %{name}"
+ depreciate: "Compute depreciations of %{name}" #?
edit: "Edit asset: %{name}"
index: "Assets"
new: "New asset"
@@ -126,6 +126,7 @@ eng:
close: "Close financial year: %{code}"
compute_balances: "Compute financial year balance"
edit: "Edit new financial year"
+ # generate_last_journal_entry: "Generate last journal entry financial year"
index: "Financial years"
new: "Open a new financial year"
show: "Financial year %{code}"
@@ -721,6 +722,7 @@ eng:
general: "General"
general_informations: "General informations"
general_ledger: "General ledger"
+ generate: "Generate"
give_discount: "Give discount"
go: "Go"
graph_statistics: "Graph statistics"
@@ -1144,6 +1146,7 @@ eng:
stocks: "Stocks"
warehouses: "Warehouses"
weight: "Weight"
+ with_assets_depreciations: "With assets depreciations"
with_prints: "Include printing archives (sales invoices, purchases...)"
x_cashes:
one: "%{count} cash"
View
8 config/locales/eng/models.yml
@@ -1,6 +1,8 @@
eng:
activerecord:
attributes:
+ asset_depreciation:
+ asset_amount: "Accountable value"
cash:
key: "BBAN key"
mode: "Mode"
@@ -317,6 +319,7 @@ eng:
address: "Address"
admin: "Admin"
agency_code: "Agency code"
+ # allocation_account: "Allocation account"
amount: "Amount"
annotation: "Annotation"
area: "Area"
@@ -325,6 +328,7 @@ eng:
areas: "Areas"
arrived_on: "Arrived on"
asset: "Asset"
+ # asset_amount: "Asset amount"
asset_depreciations: "Asset depreciations"
assets: "Assets"
assimilated_taxes_amount: "Assimilated taxes amount"
@@ -368,6 +372,7 @@ eng:
ceded: "Ceded"
ceded_on: "Ceded on"
changes_reflected: "Changes reflected"
+ # charges_account: "Charges account"
charges_accounts: "Charges accounts"
check_number: "Check number"
check_state: "Check state"
@@ -536,6 +541,7 @@ eng:
filesize: "Filesize"
filtered_columns: "Filtered columns"
financial_year: "Financial year"
+ # financial_year_as_last: "Financial year as last"
financial_years: "Financial years"
finish: "Finish"
first_financial_year: "First financial year"
@@ -605,6 +611,7 @@ eng:
language: "Language"
last_bank_statement: "Last bank statement"
last_cweek: "Last cweek"
+ # last_journal_entry: "Last journal entry"
last_letter: "Last letter"
last_month: "Last month"
last_name: "Last name"
@@ -1175,6 +1182,7 @@ eng:
sale: "Creation of a sale"
sales_invoice: "Creation of a sales invoice"
financial_year:
+ bookkeep: "[%{resource} %{number}] Depreciation of %{name} (%{position}/%{total})"
code:
double: "FY%{first_year}/%{second_year}"
single: "FY%{first_year}"
View
5 config/locales/fra/action.yml
@@ -133,6 +133,7 @@ fra:
close: "Clôturer l’exercice %{code}"
compute_balances: "Calculer la balance de l’exercice"
edit: "Modifier un nouvel exercice"
+ generate_last_journal_entry: "Générer l’écriture de fin de l’exercice %{code}" #?
index: "Exercices comptables"
new: "Créer un nouvel exercice"
show: "Exercice comptable %{code}"
@@ -712,7 +713,7 @@ fra:
deposit: "Remise en banque"
deposit_update: "Modifier la remise en banque" #?
depositable: "Complément d’information"
- depreciation: "Ammortissement"
+ depreciation: "Ammortissement" #?
description: "Description"
destroy: "Supprimer"
details: "Informations complémentaires"
@@ -787,6 +788,7 @@ fra:
general: "Informations générales"
general_informations: "Informations générales"
general_ledger: "Grand livre"
+ generate: "Générer"
give_discount: "Octroyer une remise"
go: "Valider"
graph_statistics: "Statistiques graphiques"
@@ -1312,6 +1314,7 @@ fra:
warehouse_update: "Modifier le lieu de stockage" #?
warehouses: "Voir la liste des lieux de stockage"
weight: "Poids"
+ with_assets_depreciations: "Inclure les amortissements des immobilisations"
with_prints: "Inclure les impressions (factures, commandes...)"
x_cashes:
one: "1 compte bancaire"
View
4 config/locales/fra/models.yml
@@ -1,6 +1,8 @@
fra:
activerecord:
attributes:
+ asset_depreciation:
+ asset_amount: "Valeur nette comptable (VNC)"
cash:
key: "Clé RIB"
mode: "Mode"
@@ -21,6 +23,7 @@ fra:
event_nature:
duration: "Durée par défaut (en min.)"
financial_year:
+ last_journal_entry: "Écriture de fin d'exercice" #?
stopped_on: "Date de clôture"
incoming_payment:
amount: "Montant"
@@ -1209,6 +1212,7 @@ fra:
sale: "Création d’un devis"
sales_invoice: "Création d’une facture"
financial_year:
+ bookkeep: "[%{resource} %{number}] Amortissement de %{name} (%{position}/%{total})"
code:
double: "EX%{first_year}/%{second_year}"
single: "EX%{first_year}"
View
2  config/locales/jpn/action.yml
@@ -748,6 +748,7 @@ jpn:
# general: "General"
# general_informations: "General informations"
# general_ledger: "General ledger"
+ # generate: "Generate"
# give_discount: "Give discount"
# go: "Go"
# graph_statistics: "Graph statistics"
@@ -1177,6 +1178,7 @@ jpn:
# stocks: "Stocks"
# warehouses: "Warehouses"
# weight: "Weight"
+ # with_assets_depreciations: "With assets depreciations"
# with_prints: "Include printing archives (sales invoices, purchases...)"
x_cashes:
# one: "%{count} cash"
View
3  config/locales/jpn/models.yml
@@ -1,6 +1,8 @@
jpn:
activerecord:
attributes:
+ asset_depreciation:
+ # asset_amount: "Accountable value"
cash:
# key: "BBAN key"
# mode: "Mode"
@@ -1189,6 +1191,7 @@ jpn:
# sale: "Creation of a sale"
# sales_invoice: "Creation of a sales invoice"
financial_year:
+ # bookkeep: "[%{resource} %{number}] Depreciation of %{name} (%{position}/%{total})"
code:
# double: "FY%{first_year}/%{second_year}"
# single: "FY%{first_year}"
View
2  config/locales/spa/action.yml
@@ -813,6 +813,7 @@ spa:
general: "Descripción general"
general_informations: "Informaciones generales"
general_ledger: "Grande libro"
+ # generate: "Generate"
# give_discount: "Give discount"
# go: "Go"
# graph_statistics: "Graph statistics"
@@ -1321,6 +1322,7 @@ spa:
warehouse_update: "Modifiar el lugar de deposito" #?
warehouses: "Ver la lista de los lugares de deposito"
# weight: "Weight"
+ # with_assets_depreciations: "With assets depreciations"
with_prints: "Incluir las impresiones (facturas, encargos...)"
x_cashes:
# one: "%{count} cash"
View
3  config/locales/spa/models.yml
@@ -1,6 +1,8 @@
spa:
activerecord:
attributes:
+ asset_depreciation:
+ # asset_amount: "Accountable value"
cash:
# key: "BBAN key"
# mode: "Mode"
@@ -1186,6 +1188,7 @@ spa:
# sale: "Creation of a sale"
# sales_invoice: "Creation of a sales invoice"
financial_year:
+ # bookkeep: "[%{resource} %{number}] Depreciation of %{name} (%{position}/%{total})"
code:
# double: "FY%{first_year}/%{second_year}"
# single: "FY%{first_year}"
View
4 config/menus.yml
@@ -1,5 +1,4 @@
# Unused actions in menus
-# - "assets::depreciate"
# - "companies::register"
# - "dashboards::accountancy"
# - "dashboards::finances"
@@ -367,11 +366,12 @@ menus:
- "financial_years::create"
- "financial_years::destroy"
- "financial_years::edit"
+ - "financial_years::generate_last_journal_entry"
- "financial_years::list"
- "financial_years::list_account_balances"
+ - "financial_years::list_asset_depreciations"
- "financial_years::new"
- "financial_years::show"
- - "financial_years::synthesis" # NONEXISTENT ACTION !!!
- "financial_years::update"
- finances:
- cashes:
View
4 config/rights.yml
@@ -1,5 +1,4 @@
# Unused actions in rights
-# - "assets::depreciate"
# - "production_chain_conveyors::create"
# - "production_chain_conveyors::destroy"
# - "production_chain_conveyors::edit"
@@ -507,12 +506,13 @@ manage_financial_years:
- "financial_years::create"
- "financial_years::destroy"
- "financial_years::edit"
+ - "financial_years::generate_last_journal_entry"
- "financial_years::index"
- "financial_years::list"
- "financial_years::list_account_balances"
+ - "financial_years::list_asset_depreciations"
- "financial_years::new"
- "financial_years::show"
- - "financial_years::synthesis # NONEXISTENT ACTION !!! # NONEXISTENT ACTION !!! # NONEXISTENT ACTION !!! # NONEXISTENT ACTION !!!"
- "financial_years::update"
# Manage incoming delivery modes
manage_incoming_delivery_modes:
View
3  config/routes.rb
@@ -61,7 +61,7 @@
get :list
end
end
- resources :assets, :path => "financial-assets" do
+ resources :assets, :path => "financial_assets" do
collection do
get :list
get :formize
@@ -216,6 +216,7 @@
end
member do
match "close", :via=>[:get, :post]
+ match :generate_last_journal_entry, :via=>[:get, :post]
post :compute_balances
get :synthesis
end
View
12 db/migrate/20120806083148_update_assets.rb
@@ -1,7 +1,9 @@
class UpdateAssets < ActiveRecord::Migration
def up
rename_column :assets, :deprecated_amount, :depreciated_amount
+ rename_column :assets, :account_id, :allocation_account_id
add_column :assets, :current_amount, :decimal, :precision=>19, :scale=>4
+ add_column :assets, :charges_account_id, :integer
change_column_null :assets, :purchase_amount, true
change_column_null :assets, :purchased_on, true
change_column :assets, :purchase_amount, :decimal, :precision=>19, :scale=>4
@@ -12,14 +14,24 @@ def up
change_column :asset_depreciations, :amount, :decimal, :precision=>19, :scale=>4
add_column :asset_depreciations, :protected, :boolean, :null => false, :default => false
add_column :asset_depreciations, :financial_year_id, :integer
+ add_column :asset_depreciations, :asset_amount, :decimal, :precision=>19, :scale=>4
+ add_column :asset_depreciations, :depreciated_amount, :decimal, :precision=>19, :scale=>4
+
+ add_column :financial_years, :last_journal_entry_id, :integer
end
def down
+ remove_column :financial_years, :last_journal_entry_id
+
+ remove_column :asset_depreciations, :depreciated_amount
+ remove_column :asset_depreciations, :asset_amount
remove_column :asset_depreciations, :financial_year_id
remove_column :asset_depreciations, :protected
remove_column :assets, :depreciation_percentage
+ remove_column :assets, :charges_account_id
remove_column :assets, :current_amount
+ rename_column :assets, :allocation_account_id, :account_id
rename_column :assets, :depreciated_amount, :deprecated_amount
end
end
View
48 db/schema.rb
@@ -87,24 +87,26 @@
add_index "areas", ["updater_id"], :name => "index_areas_on_updater_id"
create_table "asset_depreciations", :force => true do |t|
- t.integer "company_id", :null => false
- t.integer "asset_id", :null => false
+ t.integer "company_id", :null => false
+ t.integer "asset_id", :null => false
t.integer "journal_entry_id"
- t.boolean "accountable", :default => false, :null => false
- t.date "created_on", :null => false
+ t.boolean "accountable", :default => false, :null => false
+ t.date "created_on", :null => false
t.datetime "accounted_at"
- t.date "started_on", :null => false
- t.date "stopped_on", :null => false
+ t.date "started_on", :null => false
+ t.date "stopped_on", :null => false
t.text "depreciation"
- t.decimal "amount", :precision => 19, :scale => 4, :null => false
+ t.decimal "amount", :precision => 19, :scale => 4, :null => false
t.integer "position"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.integer "creator_id"
t.integer "updater_id"
- t.integer "lock_version", :default => 0, :null => false
- t.boolean "protected", :default => false, :null => false
+ t.integer "lock_version", :default => 0, :null => false
+ t.boolean "protected", :default => false, :null => false
t.integer "financial_year_id"
+ t.decimal "asset_amount", :precision => 19, :scale => 4
+ t.decimal "depreciated_amount", :precision => 19, :scale => 4
end
add_index "asset_depreciations", ["asset_id"], :name => "index_asset_depreciations_on_asset_id"
@@ -117,7 +119,7 @@
create_table "assets", :force => true do |t|
t.integer "company_id", :null => false
- t.integer "account_id", :null => false
+ t.integer "allocation_account_id", :null => false
t.integer "journal_id", :null => false
t.string "name", :null => false
t.string "number", :null => false
@@ -143,10 +145,11 @@
t.integer "lock_version", :default => 0, :null => false
t.string "currency", :limit => 3
t.decimal "current_amount", :precision => 19, :scale => 4
+ t.integer "charges_account_id"
t.decimal "depreciation_percentage", :precision => 19, :scale => 4
end
- add_index "assets", ["account_id"], :name => "index_assets_on_account_id"
+ add_index "assets", ["allocation_account_id"], :name => "index_assets_on_account_id"
add_index "assets", ["company_id"], :name => "index_assets_on_company_id"
add_index "assets", ["created_at"], :name => "index_assets_on_created_at"
add_index "assets", ["creator_id"], :name => "index_assets_on_creator_id"
@@ -781,18 +784,19 @@
add_index "events", ["updater_id"], :name => "index_events_on_updater_id"
create_table "financial_years", :force => true do |t|
- t.string "code", :limit => 12, :null => false
- t.boolean "closed", :default => false, :null => false
- t.date "started_on", :null => false
- t.date "stopped_on", :null => false
- t.integer "company_id", :null => false
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.string "code", :limit => 12, :null => false
+ t.boolean "closed", :default => false, :null => false
+ t.date "started_on", :null => false
+ t.date "stopped_on", :null => false
+ t.integer "company_id", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.integer "creator_id"
t.integer "updater_id"
- t.integer "lock_version", :default => 0, :null => false
- t.string "currency", :limit => 3
+ t.integer "lock_version", :default => 0, :null => false
+ t.string "currency", :limit => 3
t.integer "currency_precision"
+ t.integer "last_journal_entry_id"
end
add_index "financial_years", ["code", "company_id"], :name => "index_financialyears_on_code_and_company_id", :unique => true
View
4 lib/ekylibre/models.rb
@@ -25,7 +25,8 @@ module Ekylibre
:updater_id => :user
},
:asset => {
- :account_id => :account,
+ :allocation_account_id => :account,
+ :charges_account_id => :account,
:company_id => :company,
:creator_id => :user,
:journal_id => :journal,
@@ -203,6 +204,7 @@ module Ekylibre
:financial_year => {
:company_id => :company,
:creator_id => :user,
+ :last_journal_entry_id => :journal_entry,
:updater_id => :user
},
:incoming_delivery => {
View
11 test/fixtures/accounts.yml
@@ -76,3 +76,14 @@ accounts_002:
updated_at: 2009-07-19 19:13:59 +02:00
updater_id: 1
+accounts_003:
+ company_id: 1
+ created_at: 2009-07-19 19:13:59 +02:00
+ creator_id: 1
+ id: 3
+ is_debit: true
+ label: "681 - Tototo"
+ name: "Tototo"
+ number: "681"
+ updated_at: 2009-07-19 19:13:59 +02:00
+ updater_id: 1
View
40 test/fixtures/asset_depreciations.yml
@@ -20,25 +20,27 @@
#
# == Table: asset_depreciations
#
-# accountable :boolean not null
-# accounted_at :datetime
-# amount :decimal(19, 4) not null
-# asset_id :integer not null
-# company_id :integer not null
-# created_at :datetime not null
-# created_on :date not null
-# creator_id :integer
-# depreciation :text
-# financial_year_id :integer
-# id :integer not null, primary key
-# journal_entry_id :integer
-# lock_version :integer default(0), not null
-# position :integer
-# protected :boolean not null
-# started_on :date not null
-# stopped_on :date not null
-# updated_at :datetime not null
-# updater_id :integer
+# accountable :boolean not null
+# accounted_at :datetime
+# amount :decimal(19, 4) not null
+# asset_amount :decimal(19, 4)
+# asset_id :integer not null
+# company_id :integer not null
+# created_at :datetime not null
+# created_on :date not null
+# creator_id :integer
+# depreciated_amount :decimal(19, 4)
+# depreciation :text
+# financial_year_id :integer
+# id :integer not null, primary key
+# journal_entry_id :integer
+# lock_version :integer default(0), not null
+# position :integer
+# protected :boolean not null
+# started_on :date not null
+# stopped_on :date not null
+# updated_at :datetime not null
+# updater_id :integer
#
#
# == Fixture: asset_depreciations
View
11 test/fixtures/assets.yml
@@ -20,9 +20,10 @@
#
# == Table: assets
#
-# account_id :integer not null
+# allocation_account_id :integer not null
# ceded :boolean
# ceded_on :date
+# charges_account_id :integer
# comment :text
# company_id :integer not null
# created_at :datetime not null
@@ -54,7 +55,7 @@
# == Fixture: assets
#
# assets_001:
-# account_id: 1
+# allocation_account_id: 1
# company_id: 1
# created_at: 2009-07-19 19:13:59 +02:00
# creator_id: 1
@@ -72,7 +73,8 @@
#
assets_001:
- account_id: 1
+ allocation_account_id: 1
+ charges_account_id: 3
company_id: 1
created_at: 2009-07-19 19:13:59 +02:00
creator_id: 1
@@ -92,7 +94,8 @@ assets_001:
updater_id: 1
assets_002:
- account_id: 1
+ allocation_account_id: 1
+ charges_account_id: 3
company_id: 1
created_at: 2009-07-19 19:13:59 +02:00
creator_id: 1
View
27 test/fixtures/financial_years.yml
@@ -20,19 +20,20 @@
#
# == Table: financial_years
#
-# closed :boolean not null
-# code :string(12) not null
-# company_id :integer not null
-# created_at :datetime not null
-# creator_id :integer
-# currency :string(3)
-# currency_precision :integer
-# id :integer not null, primary key
-# lock_version :integer default(0), not null
-# started_on :date not null
-# stopped_on :date not null
-# updated_at :datetime not null
-# updater_id :integer
+# closed :boolean not null
+# code :string(12) not null
+# company_id :integer not null
+# created_at :datetime not null
+# creator_id :integer
+# currency :string(3)
+# currency_precision :integer
+# id :integer not null, primary key
+# last_journal_entry_id :integer
+# lock_version :integer default(0), not null
+# started_on :date not null
+# stopped_on :date not null
+# updated_at :datetime not null
+# updater_id :integer
#
#
# == Fixture: financial_years
View
2  test/functional/financial_years_controller_test.rb
@@ -19,5 +19,5 @@
require 'test_helper'
class FinancialYearsControllerTest < ActionController::TestCase
- test_restfully_all_actions :close=>:get_and_post, :compute_balances=>:touch, :except=>[:synthesis]
+ test_restfully_all_actions :generate_last_journal_entry => :get_and_post, :close=>:get_and_post, :compute_balances=>:touch, :except=>[:synthesis]
end
View
40 test/unit/asset_depreciation_test.rb
@@ -20,25 +20,27 @@
#
# == Table: asset_depreciations
#
-# accountable :boolean not null
-# accounted_at :datetime
-# amount :decimal(19, 4) not null
-# asset_id :integer not null
-# company_id :integer not null
-# created_at :datetime not null
-# created_on :date not null
-# creator_id :integer
-# depreciation :text
-# financial_year_id :integer
-# id :integer not null, primary key
-# journal_entry_id :integer
-# lock_version :integer default(0), not null
-# position :integer
-# protected :boolean not null
-# started_on :date not null
-# stopped_on :date not null
-# updated_at :datetime not null
-# updater_id :integer
+# accountable :boolean not null
+# accounted_at :datetime
+# amount :decimal(19, 4) not null
+# asset_amount :decimal(19, 4)
+# asset_id :integer not null
+# company_id :integer not null
+# created_at :datetime not null
+# created_on :date not null
+# creator_id :integer
+# depreciated_amount :decimal(19, 4)
+# depreciation :text
+# financial_year_id :integer
+# id :integer not null, primary key
+# journal_entry_id :integer
+# lock_version :integer default(0), not null
+# position :integer
+# protected :boolean not null
+# started_on :date not null
+# stopped_on :date not null
+# updated_at :datetime not null
+# updater_id :integer
#
require 'test_helper'
View
3  test/unit/asset_test.rb
@@ -20,9 +20,10 @@
#
# == Table: assets
#
-# account_id :integer not null
+# allocation_account_id :integer not null
# ceded :boolean
# ceded_on :date
+# charges_account_id :integer
# comment :text
# company_id :integer not null
# created_at :datetime not null
View
27 test/unit/financial_year_test.rb
@@ -20,19 +20,20 @@
#
# == Table: financial_years
#
-# closed :boolean not null
-# code :string(12) not null
-# company_id :integer not null
-# created_at :datetime not null
-# creator_id :integer
-# currency :string(3)
-# currency_precision :integer
-# id :integer not null, primary key
-# lock_version :integer default(0), not null
-# started_on :date not null
-# stopped_on :date not null
-# updated_at :datetime not null
-# updater_id :integer
+# closed :boolean not null
+# code :string(12) not null
+# company_id :integer not null
+# created_at :datetime not null
+# creator_id :integer
+# currency :string(3)
+# currency_precision :integer
+# id :integer not null, primary key
+# last_journal_entry_id :integer
+# lock_version :integer default(0), not null
+# started_on :date not null
+# stopped_on :date not null
+# updated_at :datetime not null
+# updater_id :integer
#

No commit comments for this range

Something went wrong with that request. Please try again.