mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
set default dates in close modal pickers
This commit is contained in:
parent
5b13c59496
commit
d8c8e4f72f
@ -394,7 +394,8 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
||||
controller: 'ClosePeriodModalController',
|
||||
size: 'lg',
|
||||
resolve: {
|
||||
periods() { return AccountingPeriod.query().$promise; }
|
||||
periods() { return AccountingPeriod.query().$promise; },
|
||||
lastClosingEnd() { return AccountingPeriod.lastClosingEnd().$promise; },
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -617,12 +618,15 @@ 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', 'AccountingPeriod', 'periods' ,'dialogs', 'growl', '_t',
|
||||
function ($scope, $uibModalInstance, Invoice, AccountingPeriod, periods, dialogs, growl, _t) {
|
||||
Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$uibModalInstance', 'Invoice', 'AccountingPeriod', 'periods', 'lastClosingEnd','dialogs', 'growl', '_t',
|
||||
function ($scope, $uibModalInstance, Invoice, AccountingPeriod, periods, lastClosingEnd, dialogs, growl, _t) {
|
||||
const YESTERDAY = moment().subtract(1, 'day').toDate();
|
||||
const LAST_CLOSING = moment(lastClosingEnd.last_end_date).toDate();
|
||||
|
||||
/* PUBLIC SCOPE */
|
||||
$scope.period = {
|
||||
start_at: null,
|
||||
end_at: null
|
||||
start_at: LAST_CLOSING,
|
||||
end_at: YESTERDAY
|
||||
};
|
||||
|
||||
$scope.accountingPeriods = periods;
|
||||
|
@ -40,7 +40,7 @@
|
||||
</form>
|
||||
<div>
|
||||
<h4 translate>{{ 'invoices.previous_closings' }}</h4>
|
||||
<table class="table closings-table">
|
||||
<table class="table closings-table" ng-show="accountingPeriods.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th translate>{{ 'invoices.start_date' }}</th>
|
||||
@ -58,6 +58,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div ng-show="accountingPeriods.length === 0" translate>{{ 'invoices.no_periods'}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
@ -24,7 +24,13 @@ class API::AccountingPeriodsController < API::ApiController
|
||||
|
||||
def last_closing_end
|
||||
authorize AccountingPeriod
|
||||
@last_period = AccountingPeriodService.find_last_period
|
||||
last_period = AccountingPeriodService.find_last_period
|
||||
if last_period.nil?
|
||||
invoice = Invoice.order(:created_at).first
|
||||
@last_end = invoice.created_at if invoice
|
||||
else
|
||||
@last_end = last_period.end_at
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -1,3 +1,3 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.extract! @last_period, :id, :end_at
|
||||
json.last_end_date @last_end
|
||||
|
@ -416,6 +416,7 @@ en:
|
||||
confirm_close: "Do you really want to close this accounting period ? Any subsequent changes will be impossible."
|
||||
period_START_END_closed_success: "The accounting period from {{START}} to {{END}} has been successfully closed"
|
||||
failed_to_close_period: "An error occurred, unable to close the accounting period"
|
||||
no_periods: "No closings for now"
|
||||
|
||||
members:
|
||||
# management of users, labels, groups, and so on
|
||||
|
@ -416,6 +416,7 @@ es:
|
||||
confirm_close: "Do you really want to close this accounting period ? Any subsequent changes will be impossible." # translation_missing
|
||||
period_START_END_closed_success: "The accounting period from {{START}} to {{END}} has been successfully closed" # translation_missing
|
||||
failed_to_close_period: "An error occurred, unable to close the accounting period" # translation_missing
|
||||
no_periods: "No closings for now" # translation_missing
|
||||
|
||||
members:
|
||||
# management of users, labels, groups, and so on
|
||||
|
@ -416,6 +416,7 @@ fr:
|
||||
confirm_close: "Êtes-vous sur de vouloir clôturer cette période comptable ? Toute modification ultérieure sera impossible."
|
||||
period_START_END_closed_success: "La période comptable du {{START}} au {{END}} a bien été clôturée"
|
||||
failed_to_close_period: "Une erreur est survenue, impossible de clôturer la période comptable"
|
||||
no_periods: "Aucune clôture pour le moment"
|
||||
|
||||
members:
|
||||
# gestion des utilisateurs, des groupes, des étiquettes, etc.
|
||||
|
@ -416,6 +416,7 @@ pt:
|
||||
confirm_close: "Do you really want to close this accounting period ? Any subsequent changes will be impossible." # translation_missing
|
||||
period_START_END_closed_success: "The accounting period from {{START}} to {{END}} has been successfully closed" # translation_missing
|
||||
failed_to_close_period: "An error occurred, unable to close the accounting period" # translation_missing
|
||||
no_periods: "No closings for now" # translation_missing
|
||||
|
||||
members:
|
||||
# management of users, labels, groups, and so on
|
||||
|
@ -128,7 +128,7 @@ Rails.application.routes.draw do
|
||||
resources :price_categories
|
||||
resources :spaces
|
||||
resources :accounting_periods do
|
||||
get 'last_closing_end'
|
||||
get 'last_closing_end', on: :collection
|
||||
end
|
||||
|
||||
# i18n
|
||||
|
Loading…
x
Reference in New Issue
Block a user