1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00

accounting periods API

This commit is contained in:
Sylvain 2019-01-07 12:47:23 +01:00
parent 0a684c8e13
commit 4af3e19cd0
2 changed files with 35 additions and 4 deletions

View File

@ -614,8 +614,8 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
/** /**
* Controller used in the modal window allowing an admin to close an accounting period * Controller used in the modal window allowing an admin to close an accounting period
*/ */
Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$uibModalInstance', 'Invoice', 'growl', '_t', Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$uibModalInstance', 'Invoice', 'AccountingPeriod', 'growl', '_t',
function ($scope, $uibModalInstance, Invoice, growl, _t) { function ($scope, $uibModalInstance, Invoice, AccountingPeriod, growl, _t) {
/* PUBLIC SCOPE */ /* PUBLIC SCOPE */
$scope.period = { $scope.period = {
start_date: null, start_date: null,
@ -636,10 +636,10 @@ Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$ui
/** /**
* Callback to open the datepicker * Callback to open the datepicker
*/ */
$scope.openDatePicker = function ($event, pickedId) { $scope.openDatePicker = function ($event, pickerId) {
$event.preventDefault(); $event.preventDefault();
$event.stopPropagation(); $event.stopPropagation();
$scope.datePicker[`${pickedId}Opened`] = true; $scope.datePicker[`${pickerId}Opened`] = true;
}; };
/** /**

View File

@ -0,0 +1,31 @@
class API::AccountingPeriodsController < API::ApiController
before_action :authenticate_user!, except: %i[index show]
before_action :set_period, only: %i[show update destroy]
def index
@accounting_periods = AccountingPeriod.all
end
def show; end
def create
authorize AccountingPeriod
@accounting_period = AccountingPeriod.new(tag_params)
if @accounting_period.save
render :show, status: :created, location: @accounting_period
else
render json: @accounting_period.errors, status: :unprocessable_entity
end
end
private
def set_period
@tag = AccountingPeriod.find(params[:id])
end
def period_params
params.require(:accounting_period).permit(:start_date, :end_date)
end
end