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

prevent generate refund before first accounting period

This commit is contained in:
Sylvain 2019-03-27 16:46:08 +01:00
parent be6b82fda1
commit fc04886e89
2 changed files with 9 additions and 5 deletions

View File

@ -111,7 +111,8 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
controller: 'AvoirModalController',
resolve: {
invoice () { return invoice; },
closedPeriods() { return AccountingPeriod.query().$promise; }
closedPeriods() { return AccountingPeriod.query().$promise; },
lastClosingEnd() { return AccountingPeriod.lastClosingEnd().$promise; }
}
});
@ -421,7 +422,7 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
size: 'lg',
resolve: {
periods() { return AccountingPeriod.query().$promise; },
lastClosingEnd() { return AccountingPeriod.lastClosingEnd().$promise; },
lastClosingEnd() { return AccountingPeriod.lastClosingEnd().$promise; }
}
});
}
@ -549,8 +550,8 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
/**
* Controller used in the invoice refunding modal window
*/
Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModalInstance', 'invoice', 'closedPeriods', 'Invoice', 'growl', '_t',
function ($scope, $uibModalInstance, invoice, closedPeriods, Invoice, growl, _t) {
Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModalInstance', 'invoice', 'closedPeriods', 'lastClosingEnd', 'Invoice', 'growl', '_t',
function ($scope, $uibModalInstance, invoice, closedPeriods, lastClosingEnd, Invoice, growl, _t) {
/* PUBLIC SCOPE */
// invoice linked to the current refund
@ -566,6 +567,9 @@ Application.Controllers.controller('AvoirModalController', ['$scope', '$uibModal
invoice_items_ids: []
};
// End date of last closed accounting period or date of first invoice
$scope.lastClosingEnd = moment.utc(lastClosingEnd.last_end_date).toDate();
// Possible refunding methods
$scope.avoirModes = [
{ name: _t('invoices.none'), value: 'none' },

View File

@ -14,7 +14,7 @@
uib-datepicker-popup="{{datePicker.format}}"
datepicker-options="datePicker.options"
is-open="datePicker.opened"
date-disabled="isDateClosed(date, mode)"
min-date="lastClosingEnd"
placeholder="{{datePicker.format}}"
ng-click="openDatePicker($event)"
required/>