OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Budget Relations UI (#19576)
Klaus Zandersa03bc8836e41
diff --git a/modules/budgets/app/controllers/budget_relations_controller.rb b/modules/budgets/app/components/budgets/child_budgets_row_component.rbsimilarity index 65%rename from modules/budgets/app/controllers/budget_relations_controller.rbrename to modules/budgets/app/components/budgets/child_budgets_row_component.rbindex c73b8532f11..b283249fb09 100644--- a/modules/budgets/app/controllers/budget_relations_controller.rb+++ b/modules/budgets/app/components/budgets/child_budgets_row_component.rb@@ -28,38 +28,34 @@# See COPYRIGHT and LICENSE files for more details.#++-class BudgetRelationsController < ApplicationController- include AttachableServiceCall-- before_action :find_budget, only: %i[index edit update new create destroy]- before_action :authorize-- menu_item :budgets-- def index- @parent_relations = @budget.parent_budget_relations.includes(parent_budget: :project)- @child_relations = @budget.child_budget_relations.includes(child_budget: :project)- end-- def new- end-- def edit- end-- def create- end-- def update- end-- def destroy- end-- private-- def find_budget- @budget = Budget.includes(:project, :author).find_by(id: params[:budget_id])- @project = @budget.project if @budget+module Budgets+ class ChildBudgetsRowComponent < ::OpPrimer::BorderBoxRowComponent+ def budget_relation+ model+ end++ def budget+ budget_relation.child_budget+ end++ def id+ link_to "##{budget.id}", budget_path(budget)+ end++ def subject+ link_to budget.subject, budget_path(budget)+ end++ def project+ link_to budget.project.name, project_path(budget.project)+ end++ def relation_type+ I18n.t(budget_relation.relation_type, scope: %i[activerecord attributes budget_relation relation_types])+ end++ def budget_amount+ number_to_currency(budget.budget)+ endendenddiff --git a/modules/budgets/app/components/budgets/child_budgets_table_component.rb b/modules/budgets/app/components/budgets/child_budgets_table_component.rbnew file mode 100644index 00000000000..cffbb38a800--- /dev/null+++ b/modules/budgets/app/components/budgets/child_budgets_table_component.rb@@ -0,0 +1,70 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module Budgets+ class ChildBudgetsTableComponent < ::OpPrimer::BorderBoxTableComponent+ columns :id, :subject, :project, :relation_type, :budget_amount+ main_column :subject, :proejct, :relation_type, :budget_amount++ def sortable?+ false+ end++ def paginated?+ false+ end++ def has_actions?+ false+ end++ def empty_row_message+ I18n.t :no_results_title_text+ end++ def row_class+ Budgets::ChildBudgetsRowComponent+ end++ def mobile_title+ I18n.t(:label_budget_child_budgets)+ end++ def headers+ [+ [:id, { caption: Budget.human_attribute_name(:id) }],+ [:subject, { caption: Budget.human_attribute_name(:subject) }],+ [:project, { caption: Budget.human_attribute_name(:project) }],+ [:relation_type, { caption: BudgetRelation.human_attribute_name(:relation_type) }],+ [:budget_amount, { caption: Budget.human_attribute_name(:budget) }]+ ]+ end+ end+enddiff --git a/modules/budgets/app/components/budgets/parent_page_header_component.rb b/modules/budgets/app/components/budgets/parent_page_header_component.rbnew file mode 100644index 00000000000..8525edb658d--- /dev/null+++ b/modules/budgets/app/components/budgets/parent_page_header_component.rb@@ -0,0 +1,59 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++module Budgets+ class ParentPageHeaderComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers+ include ApplicationHelper++ def initialize(budget:, project:)+ super++ @budget = budget+ @project = project+ end++ def breadcrumb_items+ [+ { href: project_overview_path(@project.id), text: @project.name },+ { href: projects_budgets_path(@project.id), text: t(:label_budget_plural) },+ { href: budget_path(@budget.id), text: t(:label_budget_id, id: @budget.id) },+ t(:button_manage_parent)+ ]+ end++ def call+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { t(:button_manage_parent) }+ header.with_breadcrumbs(breadcrumb_items)+ end+ end+ end+enddiff --git a/modules/budgets/app/components/budgets/show_page_header_component.html.erb b/modules/budgets/app/components/budgets/show_page_header_component.html.erbindex 14de313d793..52bba5f1a95 100644--- a/modules/budgets/app/components/budgets/show_page_header_component.html.erb+++ b/modules/budgets/app/components/budgets/show_page_header_component.html.erb@@ -18,6 +18,21 @@t(:button_update)endend+ if authorize_for(:budgets, :parent) && @budget.project.parent_id.present?+ header.with_action_button(+ tag: :a,+ mobile_icon: "git-pull-request",+ mobile_label: t(:button_manage_parent),+ size: :medium,+ href: url_for({ controller: "budgets", action: "parent", id: @budget }),+ aria: { label: t(:button_manage_parent) },+ data: { test_selector: "budget-parent-button" },+ title: t(:button_manage_parent)+ ) do |button|+ button.with_leading_visual_icon(icon: "git-pull-request")+ t(:button_manage_parent)+ end+ endif authorize_for(:budgets, :copy)header.with_action_button(tag: :a,diff --git a/modules/budgets/app/controllers/budgets_controller.rb b/modules/budgets/app/controllers/budgets_controller.rbindex 21b263e90ea..15f971b6188 100644--- a/modules/budgets/app/controllers/budgets_controller.rb+++ b/modules/budgets/app/controllers/budgets_controller.rb@@ -29,7 +29,7 @@class BudgetsController < ApplicationControllerinclude AttachableServiceCall- before_action :find_budget, only: %i[show edit update copy destroy_info]+ before_action :find_budget, only: %i[show edit update copy destroy_info parent update_parent destroy_parent]before_action :find_budgets, only: :destroybefore_action :check_and_update_belonging_work_packages, only: :destroybefore_action :find_project_by_project_id, only: %i[new create update_material_budget_item update_labor_budget_item]@@ -74,6 +74,8 @@ class BudgetsController < ApplicationControllerdef show@edit_allowed = User.current.allowed_in_project?(:edit_budgets, @project)+ @child_budget_relations = @budget.child_budget_relations.includes(child_budget: :project)+respond_to do |format|format.html { render action: "show", layout: !request.xhr? }end@@ -102,6 +104,10 @@ class BudgetsController < ApplicationControllerrender action: :new, layout: !request.xhr?end+ def edit+ @budget.attributes = permitted_params.budget if params[:budget]+ end+def createcall = attachable_create_call ::Budgets::CreateService,args: permitted_params.budget.merge(project: @project)@@ -115,10 +121,6 @@ class BudgetsController < ApplicationControllerendend- def edit- @budget.attributes = permitted_params.budget if params[:budget]- end-def updatecall = attachable_update_call ::Budgets::UpdateService,model: @budget,@@ -193,11 +195,40 @@ class BudgetsController < ApplicationControllerendend+ def parent+ @parent_projects = @project.ancestors+ @budget_candidates = Budget.visible(User.current).where(project_id: @parent_projects)++ @parent_budget_relation = @budget.parent_budget_relation || BudgetRelation.new+ end++ def update_parent+ parent_relation = @budget.parent_budget_relation || @budget.build_parent_budget_relation++ if parent_relation.update(budget_relation_params)+ flash[:notice] = t(:notice_successful_update)+ redirect_to budget_path(@budget)+ else+ flash[:error] = t(:notice_failed_update)+ render action: :parent, status: :unprocessable_entity+ end+ end++ def destroy_parent+ if @budget.parent_budget_relation.destroy+ flash[:notice] = t(:notice_relation_destroyed)+ redirect_to budget_path(@budget), method: :get+ else+ flash[:error] = t(:notice_failed_delete)+ render action: :parent, status: :unprocessable_entity+ end+ end+privatedef find_budget# This function comes directly from issues_controller.rb (Redmine 0.8.4)- @budget = Budget.includes(:project, :author).find_by(id: params[:id])+ @budget = Budget.includes(:project, :author).find(params[:id])@project = @budget.project if @budgetend@@ -234,6 +265,10 @@ class BudgetsController < ApplicationControllerresponseend+ def budget_relation_params+ params.expect(budget_relation: %i[parent_budget_id relation_type])+ end+def default_budget_sort{"id" => "#{Budget.table_name}.id",diff --git a/modules/budgets/app/models/budget.rb b/modules/budgets/app/models/budget.rbindex 7a8b2d2bc70..74f89bde307 100644--- a/modules/budgets/app/models/budget.rb+++ b/modules/budgets/app/models/budget.rb@@ -46,10 +46,12 @@ class Budget < ApplicationRecordhas_many :cost_entries, through: :work_packageshas_many :time_entries, through: :work_packages- has_many :parent_budget_relations, class_name: "BudgetRelation",- foreign_key: "child_budget_id",- dependent: :destroy,- inverse_of: :child_budget+ has_one :parent_budget_relation, class_name: "BudgetRelation",+ foreign_key: "child_budget_id",+ dependent: :destroy,+ inverse_of: :child_budget++ has_one :parent_budget, through: :parent_budget_relation, source: :parent_budgethas_many :child_budget_relations, class_name: "BudgetRelation",foreign_key: "parent_budget_id",diff --git a/modules/budgets/app/models/budget_relation.rb b/modules/budgets/app/models/budget_relation.rbindex 2d2a3e49556..c55c142e672 100644--- a/modules/budgets/app/models/budget_relation.rb+++ b/modules/budgets/app/models/budget_relation.rb@@ -32,7 +32,8 @@ class BudgetRelation < ApplicationRecordbelongs_to :parent_budget, class_name: "Budget"belongs_to :child_budget, class_name: "Budget"- enum :relation_type, { add: "add", subtract: "subtract" }+ enum :relation_type, { add: "add", subtract: "subtract" }, default: :subtractvalidates :child_budget, uniqueness: true+ validates :child_budget, :parent_budget, :relation_type, presence: trueenddiff --git a/modules/budgets/app/views/budget_relations/index.html.erb b/modules/budgets/app/views/budget_relations/index.html.erbdeleted file mode 100644index d55ed1eeac5..00000000000--- a/modules/budgets/app/views/budget_relations/index.html.erb+++ /dev/null@@ -1,5 +0,0 @@-<h1>Hallo Welt</h1>--<%= @child_relations.inspect %>--<%= @parent_relations.inspect %>diff --git a/modules/budgets/app/views/budgets/_form.html.erb b/modules/budgets/app/views/budgets/_form.html.erbindex b9d39f5d825..780a0a3804a 100644--- a/modules/budgets/app/views/budgets/_form.html.erb+++ b/modules/budgets/app/views/budgets/_form.html.erb@@ -48,9 +48,6 @@ See COPYRIGHT and LICENSE files for more details.inputmode: :decimal,container_class: "-wide",value: unitless_currency_number(@budget.supplementary_amount) %>- <span class="form-label">- <%= Setting.costs_currency %>- </span></div><div class="form--field">diff --git a/modules/budgets/app/views/budgets/parent.html.erb b/modules/budgets/app/views/budgets/parent.html.erbnew file mode 100644index 00000000000..c67e4ad9ee6--- /dev/null+++ b/modules/budgets/app/views/budgets/parent.html.erb@@ -0,0 +1,70 @@+<% html_title "#{t(:button_manage_parent)} #{t(:label_budget_id, id: @budget.id)}: #{@budget.subject}" %>++<%= render Budgets::ParentPageHeaderComponent.new(budget: @budget, project: @project) %>+<%-+ parent_budget_relation = @parent_budget_relation+ parent_candidates = @budget_candidates+%>+<%=+ primer_form_with(scope: :budget_relation, action: :update_parent, method: :post) do |budget_parent_form|+ render_inline_form(budget_parent_form) do |form|+ form.html_content do+ render(Primer::Beta::Subhead.new(hide_border: true)) do |subhead|+ subhead.with_heading(tag: :h3, size: :medium) { I18n.t("budgets.parent_relation.heading") }+ subhead.with_description { I18n.t("budgets.parent_relation.description") }+ end+ end++ form.select_list(+ name: :parent_budget_id,+ label: BudgetRelation.human_attribute_name(:parent_budget),+ required: true,+ input_width: :large+ ) do |select|+ parent_candidates.each do |budget|+ select.option(+ label: "#{budget.project.name}: ##{budget.id} - #{budget.subject}",+ value: budget.id,+ selected: budget.id == parent_budget_relation.parent_budget_id+ )+ end+ end++ form.radio_button_group(name: :relation_type) do |group|+ group.radio_button(+ value: :add,+ checked: parent_budget_relation.add?,+ label: I18n.t("budgets.relation_types.add.label"),+ caption: I18n.t("budgets.relation_types.add.helptext")+ )++ group.radio_button(+ value: :subtract,+ checked: parent_budget_relation.subtract?,+ label: I18n.t("budgets.relation_types.subtract.label"),+ caption: I18n.t("budgets.relation_types.subtract.helptext")+ )+ end++ form.submit(name: :submit, label: I18n.t(:button_set_parent))+ end+ end+%>++<% if @budget.parent_budget_relation.present? %>+ <%= render(Primer::Beta::Subhead.new(mt: 5, hide_border: true)) do |subhead|+ subhead.with_heading(tag: :h3, size: :medium) { I18n.t("budgets.delete_parent_relation.heading") }+ subhead.with_description { I18n.t("budgets.delete_parent_relation.description") }+ end %>++<%= render Primer::Beta::Button.new(+ tag: :a,+ scheme: :danger,+ title: I18n.t(:button_delete_link_to_parent),+ href: parent_budget_path(@budget),+ data: { "method" => :delete }+ ) do |button|+ button.with_leading_visual_icon(icon: :trash)+ I18n.t(:button_delete_link_to_parent)+ end %>+<% end %>diff --git a/modules/budgets/app/views/budgets/show.html.erb b/modules/budgets/app/views/budgets/show.html.erbindex 25484402d2b..1ab8350047b 100644--- a/modules/budgets/app/views/budgets/show.html.erb+++ b/modules/budgets/app/views/budgets/show.html.erb@@ -40,6 +40,7 @@ See COPYRIGHT and LICENSE files for more details.<div class="grid-block"><div class="grid-content medium-6"><%= render(AttributeGroups::AttributeGroupComponent.new) do |component|+ component.with_header(title: I18n.t(:label_budget_details))component.with_attribute(key: Budget.human_attribute_name(:type), value: @budget.type_label)component.with_attribute(key: Budget.human_attribute_name(:fixed_date), value: format_date(@budget.fixed_date))component.with_attribute(@@ -50,6 +51,17 @@ See COPYRIGHT and LICENSE files for more details.key: Budget.human_attribute_name(:state),value: @budget.state.present? ? I18n.t(@budget.state, scope: %i[activerecord attributes budget states]) : "-")+ component.with_attribute(+ key: Budget.human_attribute_name(:parent_budget),+ value: if @budget.parent_budget_relation.present?+ link_to(+ "#{@budget.parent_budget.project.name}: #{@budget.parent_budget.subject} (#{I18n.t(@budget.parent_budget_relation.relation_type, scope: %i[activerecord attributes budget_relation relation_types])})",+ budget_path(@budget.parent_budget)+ )+ else+ "-"+ end+ )component.with_attribute(key: Budget.human_attribute_name(:description),value: content_tag(:div, class: "op-uc-container") do@@ -61,7 +73,7 @@ See COPYRIGHT and LICENSE files for more details.<div class="grid-content medium-6"><%= render(AttributeGroups::AttributeGroupComponent.new) do |component|- component.with_header(title: "Totals")+ component.with_header(title: I18n.t(:label_budget_totals))component.with_attribute(key: Budget.human_attribute_name(:supplementary_amount),value: number_to_currency(@budget.supplementary_amount)@@ -74,6 +86,12 @@ See COPYRIGHT and LICENSE files for more details.key: Budget.human_attribute_name(:labor_budget),value: number_to_currency(@budget.labor_budget))+ if @budget.child_budget_relations.add.any?+ component.with_attribute(+ key: Budget.human_attribute_name(:budget_added_by_children),+ value: number_to_currency(@budget.budget_added_by_children)+ )+ endcomponent.with_attribute(key: Budget.human_attribute_name(:budget),value: content_tag(:strong, number_to_currency(@budget.budget))@@ -82,10 +100,12 @@ See COPYRIGHT and LICENSE files for more details.key: Budget.human_attribute_name(:spent),value: number_to_currency(@budget.spent * -1))- component.with_attribute(- key: Budget.human_attribute_name(:allocated_to_children),- value: number_to_currency(@budget.allocated_to_children * -1)- )+ if @budget.child_budget_relations.subtract.any?+ component.with_attribute(+ key: Budget.human_attribute_name(:allocated_to_children),+ value: number_to_currency(@budget.allocated_to_children * -1)+ )+ endcomponent.with_attribute(key: Budget.human_attribute_name(:available),value: content_tag(:strong, number_to_currency(@budget.available))@@ -99,24 +119,12 @@ See COPYRIGHT and LICENSE files for more details.<%= render partial: "budget_items" %>-<h2>Child Budgets</h2>- <table>- <tr>- <th>Budget</th>- <th>Projekt</th>- <th>Art</th>- <th>Betrag</th>- </tr>--<%- @budget.child_budget_relations.includes(child_budget: :project).find_each do |rel| -%>-<tr>- <td> <%= link_to rel.child_budget.subject, budget_path(rel.child_budget) %> </td>- <td> <%= link_to rel.child_budget.project.name, project_path(rel.child_budget.project) %> </td>- <td> <%= rel.relation_type %> </td>- <td> <%= number_to_currency(rel.child_budget.budget) %></td>- </tr>-<%- end %>- </table>+<fieldset class="form--fieldset">+ <legend class="form--fieldset-legend">+ <%= I18n.t(:label_budget_child_budgets) %>+ </legend>+ <%= render(Budgets::ChildBudgetsTableComponent.new(rows: @child_budget_relations)) %>+</fieldset></div>diff --git a/modules/budgets/config/locales/de.yml b/modules/budgets/config/locales/de.ymlnew file mode 100644index 00000000000..9d5983df7f4--- /dev/null+++ b/modules/budgets/config/locales/de.yml@@ -0,0 +1,53 @@+de:+ activerecord:+ attributes:+ budget:+ parent_budget: "Übergeordnetes Budget"+ supplementary_amount: "Basisbetrag"+ budget_added_by_children: "Von Unterbudgets übernommen"+ allocated_to_children: "Zugewiesen an Unterbudgets"+ state: "Status"+ states:+ planned: "Geplant"+ draft: "Entwurf"+ submitted: "Eingereicht"+ approved: "Genehmigt"+ rejected: "Abgelehnt"+ budget_relation:+ parent_budget: "Übergeordnetes Budget"+ child_budget: "Unterbudget"+ relation_type: "Verbindung zu diesem Budget"+ relation_types:+ add: "Betrag wird hinzugefügt"+ subtract: "Betrag wird abgezogen"+ project:+ ancestor_or_self: "Projekt (inkl. untergeordnete)"+ label_budget_child_budgets: "Unterbudgets"+ label_budget_totals: "Summen"+ label_budget_details: "Budget Informationen"+ label_budget_planned: "Geplantes Budget"+ label_budget_allocated: "Zugewiesen an Unterbudgets"+ label_budget_available: "Verfügbares Budget"+ label_budget_spent: "Ausgegebenes Budget"+ label_budget_spent_ratio: "Ausgegebenes Budget (Anteil)"++ notice_relation_destroyed: "Die Verknüpfung wurde erfolgreich entfernt."++ button_manage_parent: "Übergeordnetes Budget verwalten"+ button_set_parent: "Übergeordnetes Budget setzen"+ button_delete_link_to_parent: "Verknüpfung zum übergeordneten Budget entfernen"++ budgets:+ parent_relation:+ heading: "Verknüpfe dieses Budget mit einem übergeordneten Budget"+ description: "Hiermit wird eine Abhängigkeit von diesem Budget zu seinem übergeordneten Budget hergestellt. Je nach Art der Beziehung wird der budgetierte Betrag zum Budget übergeordneten Budget hinzugefügt oder abgezogen."+ delete_parent_relation:+ heading: "Verknüpfung zum übergeordneten Budget entfernen"+ description: "Hiermit wird die Verknüpfung zum übergeordneten Budget entfernt. Der budgetierte oder verfügbare Betrag des übergeordneten Budgets und aller seiner Vorgänger wird ebenfalls geändert!"+ relation_types:+ add:+ label: "Betrag zum übergeordneten Budget hinzufügen"+ helptext: "Der Betrag dieses Budgets wird zum geplanten Betrag des übergeordneten Budget hinzugefügt. Gleichzeitig wird der Betrag an dieses Budget zugewiesen. Der verfügbare Betrag des übergeordneten Budgets ändert sich dadurch nicht."+ subtract:+ label: "Betrag vom übergeordneten Budget abziehen"+ helptext: "Der Betrag dieses Budgets wird vom geplanten Betrag des übergeordneten Budgets abgezogen und diesem Budget zugewiesen. Der verfügbare Betrag des übergeordneten Budgets reduziert sich dadurch."diff --git a/modules/budgets/config/locales/en.yml b/modules/budgets/config/locales/en.ymlindex 06afef217ea..a7235bc9631 100644--- a/modules/budgets/config/locales/en.yml+++ b/modules/budgets/config/locales/en.yml@@ -37,6 +37,7 @@ en:author: "Author"available: "Available"allocated_to_children: "Allocated"+ budget_added_by_children: "Added by children"budget: "Planned"budget_ratio: "Spent (ratio)"description: "Description"@@ -47,6 +48,7 @@ en:labor_budget: "Planned labor costs"material_budget: "Planned unit costs"supplementary_amount: "Supplementary amount"+ parent_budget: "Parent budget"state: "State"states:planned: "Planned"@@ -56,6 +58,13 @@ en:rejected: "Rejected"work_package:budget_subject: "Budget title"+ budget_relation:+ parent_budget: "Parent budget"+ child_budget: "Child budget"+ relation_type: "Relation to this"+ relation_types:+ add: "add budget to parent"+ subtract: "allocated budget from parent"models:budget: "Budget"material_budget_item: "Unit"@@ -72,6 +81,9 @@ en:button_add_cost_type: "Add cost type"button_cancel_edit_budget: "Cancel editing budget"button_cancel_edit_costs: "Cancel editing costs"+ button_manage_parent: "Manage parent budget"+ button_set_parent: "Set parent"+ button_delete_link_to_parent: "Delete link to parent budget"caption_labor: "Labor"caption_labor_costs: "Actual labor costs"@@ -98,9 +110,13 @@ en:label_example_placeholder: "e.g., %{decimal}"label_view_all_budgets: "View all budgets"label_yes: "Yes"+ label_budget_child_budgets: "Child budgets"+ label_budget_totals: "Totals"+ label_budget_details: "Budget details"notice_budget_conflict: "Work packages must be of the same project."notice_no_budgets_available: "No budgets available."+ notice_relation_destroyed: "The budget relation has been removed."permission_edit_budgets: "Edit budgets"permission_view_budgets: "View budgets"@@ -109,3 +125,18 @@ en:text_budget_reassign_to: "Reassign them to this budget:"text_budget_delete: "Delete the budget from all work packages"text_budget_destroy_assigned_wp: "There are %{count} work packages assigned to this budget. What do you want to do?"++ budgets:+ parent_relation:+ heading: "Mark this project as a child budget to another budget"+ description: "This will set up a dependency from this budget to its parent. Depending on the type of relation, the budgeted amount will be added to or subtracted from the parent's budget."+ delete_parent_relation:+ heading: "Delete parent budget relation"+ description: "This will remove the dependency from this budget to its parent. The budgeted amount of the parent budget and all its ancestors will also change!"+ relation_types:+ add:+ label: "Add budget to parent"+ helptext: "The budgeted amount for this budget will be added to the parent's budget and also mark the amount as allocated to this budget."+ subtract:+ label: "Subtract budget from parent"+ helptext: "The budgeted amount for this budget will be subtracted from the parent's budget and marked as allocated to this budget."diff --git a/modules/budgets/config/routes.rb b/modules/budgets/config/routes.rbindex f0dd5f2e5ba..bfe1716e7ed 100644--- a/modules/budgets/config/routes.rb+++ b/modules/budgets/config/routes.rb@@ -35,9 +35,12 @@ Rails.application.routes.draw doendresources :budgets, only: %i[show update destroy edit] do- resources :budget_relations, path: :relations, except: %i[show]-- get :copy, on: :member- get :destroy_info, on: :member+ member do+ get :parent+ post :parent, to: "budgets#update_parent"+ delete :parent, to: "budgets#destroy_parent"+ get :copy+ get :destroy_info+ endendenddiff --git a/modules/budgets/lib/budgets/engine.rb b/modules/budgets/lib/budgets/engine.rbindex df6516acbc6..66b4f7b242b 100644--- a/modules/budgets/lib/budgets/engine.rb+++ b/modules/budgets/lib/budgets/engine.rb@@ -9,15 +9,11 @@ module Budgetsbundled: true doproject_module :budgets dopermission :view_budgets,- {- budgets: %i[index show],- budget_relations: %i[index]- },+ { budgets: %i[index show] },permissible_on: :projectpermission :edit_budgets,{- budgets: %i[index show edit update destroy destroy_info new create copy],- budget_relations: %i[index edit update new create destroy]+ budgets: %i[index show edit update destroy destroy_info new create copy parent destroy_parent update_parent]},permissible_on: :projectend