diff --git a/CHANGELOG.md b/CHANGELOG.md index 985870c22..7bb47391e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog Fab Manager - Fix a bug: no user can be created after the last member was deleted +- Fix a bug: unable to generate a refund (Avoir) - Fix a security issue: updated lodash to 4.17.14 to fix [CVE-2019-10744](https://github.com/lodash/lodash/pull/4336) - Fix a security issue: updated mini_magick to 4.9.4 to fix [CVE-2019-13574](https://nvd.nist.gov/vuln/detail/CVE-2019-13574) - Fix some security issues: updated bootstrap to 3.4.1 to fix [CVE-2019-8331](https://nvd.nist.gov/vuln/detail/CVE-2019-8331), [CVE-2019-14041](https://nvd.nist.gov/vuln/detail/CVE-2018-14041), and 3 other low severity CVE diff --git a/app/assets/javascripts/controllers/admin/invoices.js.erb b/app/assets/javascripts/controllers/admin/invoices.js.erb index 6e87bc394..3115f50f2 100644 --- a/app/assets/javascripts/controllers/admin/invoices.js.erb +++ b/app/assets/javascripts/controllers/admin/invoices.js.erb @@ -619,8 +619,12 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal // check that at least 1 element of the invoice is refunded $scope.avoir.invoice_items_ids = []; for (let itemId in $scope.partial) { - const refundItem = $scope.partial[itemId]; - if (refundItem) { $scope.avoir.invoice_items_ids.push(parseInt(itemId)); } + if (Object.prototype.hasOwnProperty.call($scope.partial, itemId)) { + const refundItem = $scope.partial[itemId]; + if (refundItem) { + $scope.avoir.invoice_items_ids.push(parseInt(itemId)); + } + } } if ($scope.avoir.invoice_items_ids.length === 0) { diff --git a/app/services/invoices_service.rb b/app/services/invoices_service.rb index 3a0f45e0c..127cd5359 100644 --- a/app/services/invoices_service.rb +++ b/app/services/invoices_service.rb @@ -10,7 +10,7 @@ class InvoicesService # @param filters {Hash} allowed filters: number, customer, date. def self.list(order_key, direction, page, size, filters = {}) invoices = Invoice.includes(:avoir, :invoicing_profile, invoice_items: %i[subscription invoice_item]) - .joins(:invoicing_profile) + .joins('invoicing_profile') .order("#{order_key} #{direction}") .page(page) .per(size) diff --git a/app/views/api/invoices/show.json.jbuilder b/app/views/api/invoices/show.json.jbuilder index 041d2e510..d4087a0b8 100644 --- a/app/views/api/invoices/show.json.jbuilder +++ b/app/views/api/invoices/show.json.jbuilder @@ -1,4 +1,7 @@ -json.extract! @invoice, :id, :created_at, :reference, :invoiced_type, :user_id, :avoir_date, :description +# frozen_string_literal: true + +json.extract! @invoice, :id, :created_at, :reference, :invoiced_type, :avoir_date, :description +json.user_id @invoice.invoicing_profile&.user_id json.total (@invoice.total / 100.00) json.name @invoice.user.profile.full_name json.has_avoir @invoice.refunded?