onoma 0.2.2 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.gitlab-ci.yml +14 -0
  4. data/Gemfile +2 -0
  5. data/Rakefile +3 -6
  6. data/bin/rake +29 -0
  7. data/config/locales/arb.yml +77 -293
  8. data/config/locales/cmn.yml +69 -193
  9. data/config/locales/deu.yml +61 -1113
  10. data/config/locales/eng.yml +3146 -2987
  11. data/config/locales/fra.yml +629 -478
  12. data/config/locales/ita.yml +63 -1168
  13. data/config/locales/jpn.yml +80 -232
  14. data/config/locales/por.yml +63 -975
  15. data/config/locales/spa.yml +70 -616
  16. data/db/migrate/20170904223101_add_cultivable_zone_registry.xml +4 -0
  17. data/db/migrate/20171106085357_update_account_numbers.xml +431 -0
  18. data/db/migrate/20171212081801_add_fiscal_positions.xml +12 -0
  19. data/db/migrate/20180408190101_add_new_plant_variants.xml +7 -0
  20. data/db/migrate/20180409130101_add_common_crop.xml +4 -0
  21. data/db/migrate/20180418085027_add-hour-counter-indicator.xml +9 -0
  22. data/db/migrate/20180709134310_add_centralizing_field_to_accounts.xml +22 -0
  23. data/db/migrate/20180711093131_review_all_accounts_number_and_fallbacks.xml +431 -0
  24. data/db/migrate/20180806080646_edit_centralizing_field_accounts.xml +17 -0
  25. data/db/migrate/20180814184001_add_missing_categories.xml +12 -0
  26. data/db/migrate/20180907160001_edit_accounts_to_unlock_first_run.xml +21 -0
  27. data/db/migrate/20181004220301_add_journal_ledger.xml +4 -0
  28. data/db/migrate/20181205162401_add_intra_vat.xml +6 -0
  29. data/db/migrate/20181213153405_fix_accounting_systems.xml +7 -0
  30. data/db/migrate/20181217155149_fiscal_position_refers_to_accounting_system.xml +10 -0
  31. data/db/migrate/20181217173101_fiscal_position_reference_typo.xml +4 -0
  32. data/db/migrate/20190315154040_add_suspense_account.xml +4 -0
  33. data/db/migrate/20190326110849_add_asset_fixable_to_product_nature_categories.xml +25 -0
  34. data/db/migrate/20190326135443_change_product_nature_category_cultivable_zone_into_land.xml +21 -0
  35. data/db/migrate/20190329133808_change_land_fixed_assets_account_usage.xml +7 -0
  36. data/db/migrate/20190405120711_delete_land_sales_account_and_assign_land_parcels_sell_revenues_to_land.xml +5 -0
  37. data/db/migrate/20190412071057_add_new_fixed_assets_andn_depreciable_accounts.xml +22 -0
  38. data/db/migrate/20190509092804_add_account_exceptional_depreciations_imputations_expenses_for_fixed_assets.xml +4 -0
  39. data/db/migrate/20190514084753_add_approved_input_volume.xml +9 -0
  40. data/db/migrate/20190520072403_add_new_accounts.xml +58 -0
  41. data/db/migrate/20190521170601_add_missing_taxes.xml +7 -0
  42. data/db/migrate/20190611101014_change_deductible_vat_account.xml +5 -0
  43. data/db/migrate/20190620092151_fix_conflicts_in_new_accounts.xml +6 -0
  44. data/db/migrate/20190625152636_change_mixture_seed_product_nature_variant.xml +4 -0
  45. data/db/migrate/20190718130243_remove_services_expenses.xml +5 -0
  46. data/db/migrate/20190801142431_remove_accounts_from_pcg82.xml +5 -0
  47. data/db/migrate/20190807125202_add_nature_to_product_natures.xml +326 -0
  48. data/db/migrate/20190823091727_fix-cubic-meter-per-hectare-symbol.xml +5 -0
  49. data/db/migrate/20190909150402_add_staff_supply_stock_account.xml +4 -0
  50. data/db/migrate/20190913102036_add_caliber_indicator.xml +4 -0
  51. data/db/migrate/20190917161215_add_missing_mass_area_density_units.xml +21 -0
  52. data/db/migrate/20190917161216_update_quintal_symbol.xml +4 -0
  53. data/db/migrate/20190917161217_adds_more_info_to_units.xml +133 -0
  54. data/db/migrate/20190918074757_add_new_accounts.xml +8 -0
  55. data/db/migrate/20191001122750_add_accounts_fixed_assets_related.xml +10 -0
  56. data/db/migrate/20191016152118_add_missing_document_templates.xml +6 -0
  57. data/db/migrate/20191028175001_add_short_balance_sheet.xml +4 -0
  58. data/db/migrate/20191029131921_add_vine_equipments.xml +117 -0
  59. data/db/migrate/20191112132413_remove_roller_from_product_natures.xml +5 -0
  60. data/db/migrate/20191113134626_add_nature_to_new_product_natures.xml +11 -0
  61. data/db/migrate/20191125133327_add_missing_units_and_indicators.xml +5 -0
  62. data/db/migrate/20200107095554_add_signed_field_to_document_nature.xml +9 -0
  63. data/db/migrate/20200305160358_add_varieties_for_phytosanitary.xml +11 -0
  64. data/db/migrate/20200421123503_add_type_to_categories_and_variants.xml +1136 -0
  65. data/db/migrate/20200514092205_add_liter_per_hectoliter_unit.xml +4 -0
  66. data/db/migrate/20200722091859_triticale_derivative_of.xml +5 -0
  67. data/db/reference.xml +1934 -1676
  68. data/lib/onoma.rb +82 -24
  69. data/lib/onoma/item.rb +19 -3
  70. data/lib/onoma/migration/actions/base.rb +1 -5
  71. data/lib/onoma/migration/actions/item_change.rb +1 -5
  72. data/lib/onoma/migration/actions/item_creation.rb +2 -6
  73. data/lib/onoma/migration/actions/item_merging.rb +1 -5
  74. data/lib/onoma/migration/actions/item_removal.rb +1 -1
  75. data/lib/onoma/migration/actions/nomenclature_change.rb +1 -1
  76. data/lib/onoma/migration/actions/nomenclature_creation.rb +1 -1
  77. data/lib/onoma/migration/actions/nomenclature_removal.rb +1 -5
  78. data/lib/onoma/migration/actions/property_creation.rb +4 -4
  79. data/lib/onoma/migration/base.rb +38 -0
  80. data/lib/onoma/migrator.rb +13 -0
  81. data/lib/onoma/migrator/reference.rb +71 -0
  82. data/lib/onoma/migrator/translation.rb +76 -0
  83. data/lib/onoma/models/ability.rb +4 -0
  84. data/lib/onoma/models/account.rb +4 -0
  85. data/lib/onoma/models/accounting_system.rb +12 -0
  86. data/lib/onoma/models/activity_family.rb +4 -0
  87. data/lib/onoma/models/administrative_area.rb +4 -0
  88. data/lib/onoma/models/administrative_area_nature.rb +4 -0
  89. data/lib/onoma/models/analysis_nature.rb +4 -0
  90. data/lib/onoma/models/animal_life_state.rb +4 -0
  91. data/lib/onoma/models/cation_exchange_capacity_analysis_method.rb +4 -0
  92. data/lib/onoma/models/certification.rb +4 -0
  93. data/lib/onoma/models/certification_label.rb +4 -0
  94. data/lib/onoma/models/chemical_classification.rb +4 -0
  95. data/lib/onoma/models/chemical_element.rb +4 -0
  96. data/lib/onoma/models/country.rb +4 -0
  97. data/lib/onoma/models/crop_set.rb +4 -0
  98. data/lib/onoma/models/currency.rb +4 -0
  99. data/lib/onoma/models/delivery_mode.rb +4 -0
  100. data/lib/onoma/models/dimension.rb +4 -0
  101. data/lib/onoma/models/document_category.rb +4 -0
  102. data/lib/onoma/models/document_nature.rb +4 -0
  103. data/lib/onoma/models/entity_link_nature.rb +4 -0
  104. data/lib/onoma/models/event_nature.rb +4 -0
  105. data/lib/onoma/models/fence_perimeter.rb +4 -0
  106. data/lib/onoma/models/figure.rb +4 -0
  107. data/lib/onoma/models/fiscal_position.rb +4 -0
  108. data/lib/onoma/models/guide_nature.rb +4 -0
  109. data/lib/onoma/models/identifier_nature.rb +4 -0
  110. data/lib/onoma/models/indicator.rb +7 -0
  111. data/lib/onoma/models/issue_nature.rb +4 -0
  112. data/lib/onoma/models/land.rb +4 -0
  113. data/lib/onoma/models/language.rb +4 -0
  114. data/lib/onoma/models/mammalia_birth_condition.rb +4 -0
  115. data/lib/onoma/models/mammalia_reproduction_state.rb +4 -0
  116. data/lib/onoma/models/molecule.rb +4 -0
  117. data/lib/onoma/models/net_service.rb +4 -0
  118. data/lib/onoma/models/opportunity_origin.rb +4 -0
  119. data/lib/onoma/models/phosphorus_analysis_method.rb +4 -0
  120. data/lib/onoma/models/plant_life_state.rb +4 -0
  121. data/lib/onoma/models/plant_reproduction_state.rb +4 -0
  122. data/lib/onoma/models/plants_growth_level.rb +4 -0
  123. data/lib/onoma/models/procedure_action.rb +4 -0
  124. data/lib/onoma/models/procedure_category.rb +4 -0
  125. data/lib/onoma/models/procedure_nature.rb +4 -0
  126. data/lib/onoma/models/procedure_role.rb +4 -0
  127. data/lib/onoma/models/product_nature.rb +4 -0
  128. data/lib/onoma/models/product_nature_category.rb +4 -0
  129. data/lib/onoma/models/product_nature_variant.rb +4 -0
  130. data/lib/onoma/models/production_nature.rb +4 -0
  131. data/lib/onoma/models/production_system.rb +4 -0
  132. data/lib/onoma/models/production_usage.rb +4 -0
  133. data/lib/onoma/models/residue_elimination_method.rb +4 -0
  134. data/lib/onoma/models/role.rb +4 -0
  135. data/lib/onoma/models/running_cost.rb +4 -0
  136. data/lib/onoma/models/sex.rb +4 -0
  137. data/lib/onoma/models/soil_cultural_state.rb +4 -0
  138. data/lib/onoma/models/soil_nature.rb +4 -0
  139. data/lib/onoma/models/spatial_reference_system.rb +4 -0
  140. data/lib/onoma/models/tax.rb +4 -0
  141. data/lib/onoma/models/tax_nature.rb +4 -0
  142. data/lib/onoma/models/unit.rb +4 -0
  143. data/lib/onoma/models/variety.rb +31 -0
  144. data/lib/onoma/models/working_set.rb +4 -0
  145. data/lib/onoma/nomenclature.rb +19 -23
  146. data/lib/onoma/{database.rb → nomenclature_set.rb} +25 -57
  147. data/lib/onoma/{property.rb → property_nature.rb} +5 -8
  148. data/lib/onoma/record/base.rb +15 -0
  149. data/lib/onoma/reflection.rb +3 -3
  150. data/lib/onoma/version.rb +3 -1
  151. data/onoma.gemspec +19 -20
  152. metadata +156 -39
  153. data/lib/onoma/migration.rb +0 -122
  154. data/lib/onoma/migration/actions.rb +0 -9
@@ -0,0 +1,76 @@
1
+ module Onoma
2
+ module Migrator
3
+ class Translation
4
+ class << self
5
+ def run(migration)
6
+ puts "Migration #{migration.name}"
7
+ I18n.available_locales.each do |locale|
8
+ file = Onoma.root.join('config', 'locales', "#{locale.to_s}.yml")
9
+ hash = yaml_to_hash(file)
10
+ migration.each_action do |action|
11
+ ref = hash[locale.to_sym][:nomenclatures]
12
+ ref[action.nomenclature.to_sym] ||= {}
13
+ ref[action.nomenclature.to_sym][:items] ||= {}
14
+ if action.is_a?(Onoma::Migration::Actions::ItemChange) && action.new_name?
15
+ ref[action.nomenclature.to_sym][:items][action.new_name.to_sym] ||= ref[action.nomenclature.to_sym][:items].delete(action.name.to_sym)
16
+ elsif action.is_a?(Onoma::Migration::Actions::ItemMerging)
17
+ # ref[action.nomenclature.to_sym][:items][action.into.to_sym] ||= ref[action.nomenclature.to_sym][:items].delete(action.name.to_sym)
18
+ ref[action.nomenclature.to_sym][:items].delete(action.name.to_sym)
19
+ elsif action.is_a?(Onoma::Migration::Actions::NomenclatureChange) && action.changes[:name]
20
+ ref[action.changes[:name].to_sym] = ref.delete(action.nomenclature.to_sym)
21
+ elsif action.is_a?(Onoma::Migration::Actions::NomenclatureRemoval)
22
+ ref.delete(action.nomenclature.to_sym)
23
+ elsif !action.is_a?(Onoma::Migration::Actions::Base)
24
+ raise "Cannot handle: #{action.inspect}"
25
+ end
26
+ File.write(file, hash_to_yaml(hash))
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def yaml_to_hash(filename)
34
+ hash = YAML.safe_load(IO.read(filename).gsub(/^(\s*)(no|yes|false|true):(.*)$/, '\1__\2__:\3'), [], [], true)
35
+ hash.deep_symbolize_keys
36
+ end
37
+
38
+ def hash_to_yaml(hash, depth = nil)
39
+ code = hash.sort_by { |a| a[0].to_s.tr('_', ' ').strip }.map do |k, v|
40
+ next unless v
41
+ pair_to_yaml(k, v)
42
+ end.join("\n")
43
+ code = "\n" + code.indent(depth).gsub(/^\s+$/, '') unless depth.nil?
44
+ code
45
+ end
46
+
47
+ def value_to_yaml(value)
48
+ if value.is_a?(Array)
49
+ '[' + value.map { |x| value_to_yaml(x) }.join(', ') + ']'
50
+ elsif value.is_a?(Symbol)
51
+ ':' + value.to_s
52
+ elsif value.is_a?(Hash)
53
+ hash_to_yaml(value)
54
+ elsif value.is_a?(Numeric)
55
+ value.to_s
56
+ else
57
+ v = value.to_s.gsub("\\u00A0", '\\_')
58
+ value =~ /\n/ ? "|\n" + v.strip.indent : '"' + v + '"'
59
+ end
60
+ end
61
+
62
+ def pair_to_yaml(k, v)
63
+ if v.is_a?(Hash)
64
+ k.to_s + ":\n" + indent(hash_to_yaml(v))
65
+ else
66
+ k.to_s + ': ' + value_to_yaml(v)
67
+ end
68
+ end
69
+
70
+ def indent(string, depth = 1)
71
+ string.gsub(/^/, ' ' * depth)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Ability < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Account < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,12 @@
1
+ module Onoma
2
+ class AccountingSystem < Onoma::Record::Base
3
+ class << self
4
+ def with_fiscal_position
5
+ Onoma::FiscalPosition.items.values
6
+ .reduce(Set.new) {|acc, fp| acc << fp.accounting_system}
7
+ .map {|e| Onoma::AccountingSystem[e]}
8
+ .compact
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ActivityFamily < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class AdministrativeArea < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class AdministrativeAreaNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class AnalysisNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class AnimalLifeState < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class CationExchangeCapacityAnalysisMethod < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Certification < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class CertificationLabel < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ChemicalClassification < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ChemicalElement < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Country < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class CropSet < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Currency < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class DeliveryMode < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Dimension < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class DocumentCategory < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class DocumentNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class EntityLinkNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class EventNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class FencePerimeter < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Figure < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class FiscalPosition < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class GuideNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class IdentifierNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module Onoma
2
+ class Indicator < Onoma::Record::Base
3
+ class << self
4
+ delegate :each, to: :all
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class IssueNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Land < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Language < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class MammaliaBirthCondition < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class MammaliaReproductionState < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Molecule < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class NetService < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class OpportunityOrigin < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class PhosphorusAnalysisMethod < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class PlantLifeState < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class PlantReproductionState < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class PlantsGrowthLevel < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProcedureAction < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProcedureCategory < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProcedureNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProcedureRole < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProductNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProductNatureCategory < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProductNatureVariant < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProductionNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProductionSystem < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ProductionUsage < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class ResidueEliminationMethod < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Role < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class RunningCost < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Sex < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class SoilCulturalState < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class SoilNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class SpatialReferenceSystem < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Tax < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class TaxNature < Onoma::Record::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Onoma
2
+ class Unit < Onoma::Record::Base
3
+ end
4
+ end