1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

Merge branch 'dev' into host

This commit is contained in:
Sylvain 2019-01-14 15:00:55 +01:00
commit eb69822ce0
9 changed files with 64 additions and 8 deletions

View File

@ -302,11 +302,15 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
},
active () {
return $scope.invoice.VAT.active;
},
history () {
return Setting.get({ name: 'invoice_VAT-rate', history: true }).$promise;
}
},
controller: ['$scope', '$uibModalInstance', 'rate', 'active', function ($scope, $uibModalInstance, rate, active) {
controller: ['$scope', '$uibModalInstance', 'rate', 'active', 'history', function ($scope, $uibModalInstance, rate, active, history) {
$scope.rate = rate;
$scope.isSelected = active;
$scope.history = history.setting.history;
$scope.ok = function () { $uibModalInstance.close({ rate: $scope.rate, active: $scope.isSelected }); };
return $scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };

View File

@ -388,6 +388,26 @@
<input id="vatRate" type="number" ng-model="rate" class="form-control" min="0" max="100"/>
</div>
</div>
<div class="m-t-lg">
<h4 translate>{{ 'invoices.VAT_history' }}</h4>
<table class="table">
<head>
<tr>
<th translate>{{ 'invoices.VAT_rate' }}</th>
<th translate>{{ 'invoices.changed_at' }}</th>
<th translate>{{ 'invoices.changed_by' }}</th>
</tr>
</head>
<tbody>
<tr ng-repeat="value in history">
<td>{{value.value}} %</td>
<td>{{value.created_at | amDateFormat:'L LT'}}</td>
<td>{{value.user.name}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-warning" ng-click="ok()" translate>{{ 'confirm' }}</button>

View File

@ -17,6 +17,7 @@ class API::SettingsController < API::ApiController
def show
@setting = Setting.find_or_create_by(name: params[:name])
@show_history = params[:history] == 'true' && current_user.admin?
end
private

View File

@ -1,3 +1,6 @@
# frozen_string_literal: true
# Main controller for the backend application. All controllers inherits from it
class ApplicationController < ActionController::Base
include Pundit
# Prevent CSRF attacks by raising an exception.
@ -14,10 +17,10 @@ class ApplicationController < ActionController::Base
# Returning 403 Forbidden if permission is denied
rescue_from Pundit::NotAuthorizedError, with: :permission_denied
def index
end
def index; end
protected
def set_csrf_cookie
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
end
@ -28,17 +31,24 @@ class ApplicationController < ActionController::Base
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) <<
{profile_attributes: [:phone, :last_name, :first_name,
:gender, :birthday, :interest, :software_mastered,
organization_attributes: [:name, address_attributes: [:address]]]}
devise_parameter_sanitizer.for(:sign_up).concat [:username, :is_allow_contact, :is_allow_newsletter, :cgu, :group_id]
{ profile_attributes: [:phone, :last_name, :first_name, :gender, :birthday, :interest, :software_mastered,
organization_attributes: [:name, address_attributes: [:address]]] }
devise_parameter_sanitizer.for(:sign_up).concat %i[username is_allow_contact is_allow_newsletter cgu group_id]
end
def default_url_options
{ :host => Rails.application.secrets.default_host, protocol: Rails.application.secrets.default_protocol }
{ host: Rails.application.secrets.default_host, protocol: Rails.application.secrets.default_protocol }
end
def permission_denied
head 403
end
# @return [User]
# This is a placeholder for Devise's current_user.
# As Devise generate the method at runtime, IDEs autocomplete features will complain about 'method not found'
def current_user
super
end
end

View File

@ -1,3 +1,12 @@
json.setting do
json.partial! 'api/settings/setting', setting: @setting
if @show_history
json.history @setting.history_values do |value|
json.extract! value, :value, :created_at
json.user do
json.id value.user_id
json.name "#{value.user.first_name} #{value.user.last_name}"
end
end
end
end

View File

@ -364,6 +364,9 @@ en:
VAT: "VAT"
enable_VAT: "Enable VAT"
VAT_rate: "VAT rate"
VAT_history: "VAT rates history"
changed_at: "Changed at"
changed_by: "By"
refund_invoice_successfully_created: "Refund invoice successfully created."
create_a_refund_on_this_invoice: "Create a refund on this invoice"
creation_date_for_the_refund: "Creation date for the refund"

View File

@ -364,6 +364,9 @@ es:
VAT: "IVA"
enable_VAT: "Habilitar IVA"
VAT_rate: "Ratio IVA"
VAT_history: "Historial de ratios de IVA"
changed_at: "Cambiado en"
changed_by: "Por"
refund_invoice_successfully_created: "Factura de reembolso creada correctamente."
create_a_refund_on_this_invoice: "Crear un reembolso en esta factura"
creation_date_for_the_refund: "Fecha de creación del reembolso"

View File

@ -364,6 +364,9 @@ fr:
VAT: "TVA"
enable_VAT: "Activer la TVA"
VAT_rate: "Taux de TVA"
VAT_history: "Historique des taux de TVA"
changed_at: "Changé le"
changed_by: "Par"
refund_invoice_successfully_created: "La facture d'avoir a bien été créée."
create_a_refund_on_this_invoice: "Générer un avoir sur cette facture"
creation_date_for_the_refund: "Date d'émission de l'avoir"

View File

@ -364,6 +364,9 @@ pt:
VAT: "VAT"
enable_VAT: "Ativar VAT"
VAT_rate: "VAT taxa"
VAT_history: "VAT rates history" #translation_missing
changed_at: "Changed at" #translation_missing
changed_by: "By" #translation_missing
refund_invoice_successfully_created: "Restituição de fatura criada com sucesso."
create_a_refund_on_this_invoice: "Criar restituição de fatura"
creation_date_for_the_refund: "Criação de data de restituição"