mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-21 15:54:22 +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',
|
controller: 'ClosePeriodModalController',
|
||||||
size: 'lg',
|
size: 'lg',
|
||||||
resolve: {
|
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
|
* 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',
|
Application.Controllers.controller('ClosePeriodModalController', ['$scope', '$uibModalInstance', 'Invoice', 'AccountingPeriod', 'periods', 'lastClosingEnd','dialogs', 'growl', '_t',
|
||||||
function ($scope, $uibModalInstance, Invoice, AccountingPeriod, periods, 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 */
|
/* PUBLIC SCOPE */
|
||||||
$scope.period = {
|
$scope.period = {
|
||||||
start_at: null,
|
start_at: LAST_CLOSING,
|
||||||
end_at: null
|
end_at: YESTERDAY
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.accountingPeriods = periods;
|
$scope.accountingPeriods = periods;
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
</form>
|
</form>
|
||||||
<div>
|
<div>
|
||||||
<h4 translate>{{ 'invoices.previous_closings' }}</h4>
|
<h4 translate>{{ 'invoices.previous_closings' }}</h4>
|
||||||
<table class="table closings-table">
|
<table class="table closings-table" ng-show="accountingPeriods.length > 0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th translate>{{ 'invoices.start_date' }}</th>
|
<th translate>{{ 'invoices.start_date' }}</th>
|
||||||
@ -58,6 +58,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<div ng-show="accountingPeriods.length === 0" translate>{{ 'invoices.no_periods'}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -24,7 +24,13 @@ class API::AccountingPeriodsController < API::ApiController
|
|||||||
|
|
||||||
def last_closing_end
|
def last_closing_end
|
||||||
authorize AccountingPeriod
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# frozen_string_literal: true
|
# 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."
|
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"
|
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"
|
failed_to_close_period: "An error occurred, unable to close the accounting period"
|
||||||
|
no_periods: "No closings for now"
|
||||||
|
|
||||||
members:
|
members:
|
||||||
# management of users, labels, groups, and so on
|
# 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
|
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
|
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
|
failed_to_close_period: "An error occurred, unable to close the accounting period" # translation_missing
|
||||||
|
no_periods: "No closings for now" # translation_missing
|
||||||
|
|
||||||
members:
|
members:
|
||||||
# management of users, labels, groups, and so on
|
# 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."
|
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"
|
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"
|
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:
|
members:
|
||||||
# gestion des utilisateurs, des groupes, des étiquettes, etc.
|
# 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
|
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
|
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
|
failed_to_close_period: "An error occurred, unable to close the accounting period" # translation_missing
|
||||||
|
no_periods: "No closings for now" # translation_missing
|
||||||
|
|
||||||
members:
|
members:
|
||||||
# management of users, labels, groups, and so on
|
# management of users, labels, groups, and so on
|
||||||
|
@ -128,7 +128,7 @@ Rails.application.routes.draw do
|
|||||||
resources :price_categories
|
resources :price_categories
|
||||||
resources :spaces
|
resources :spaces
|
||||||
resources :accounting_periods do
|
resources :accounting_periods do
|
||||||
get 'last_closing_end'
|
get 'last_closing_end', on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
# i18n
|
# i18n
|
||||||
|
Loading…
x
Reference in New Issue
Block a user