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:
parent
0a684c8e13
commit
4af3e19cd0
@ -614,8 +614,8 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
|
||||
/**
|
||||
* Controller used in the modal window allowing an admin to close an accounting period
|
||||
*/
|
||||
Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$uibModalInstance', 'Invoice', 'growl', '_t',
|
||||
function ($scope, $uibModalInstance, Invoice, growl, _t) {
|
||||
Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$uibModalInstance', 'Invoice', 'AccountingPeriod', 'growl', '_t',
|
||||
function ($scope, $uibModalInstance, Invoice, AccountingPeriod, growl, _t) {
|
||||
/* PUBLIC SCOPE */
|
||||
$scope.period = {
|
||||
start_date: null,
|
||||
@ -636,10 +636,10 @@ Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$ui
|
||||
/**
|
||||
* Callback to open the datepicker
|
||||
*/
|
||||
$scope.openDatePicker = function ($event, pickedId) {
|
||||
$scope.openDatePicker = function ($event, pickerId) {
|
||||
$event.preventDefault();
|
||||
$event.stopPropagation();
|
||||
$scope.datePicker[`${pickedId}Opened`] = true;
|
||||
$scope.datePicker[`${pickerId}Opened`] = true;
|
||||
};
|
||||
|
||||
/**
|
||||
|
31
app/controllers/api/accounting_periods_controller.rb
Normal file
31
app/controllers/api/accounting_periods_controller.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user