mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
Fix a bug: if multi VAT no value is filled in, the general rate can't apply
This commit is contained in:
parent
c5ba1afe8d
commit
4d3fe6aa2a
@ -13,6 +13,7 @@
|
||||
- Fix a bug: enable admins to be invited to collaborate on projects
|
||||
- Fix a bug: hide some links to create an account if public registrations is disabled
|
||||
- Fix a bug: unable to save user validation if admin click save user profile button after switch user valitation
|
||||
- Fix a bug: if multi VAT no value is filled in, the general rate can't apply
|
||||
- Fix a security issue: updated rack to 2.2.3.1 to fix [CVE-2022-30123](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-30123) and [CVE-2022-30122](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-30122)
|
||||
|
||||
|
||||
|
@ -530,6 +530,13 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
||||
|
||||
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
|
||||
|
||||
$scope.rateValue = function (value) {
|
||||
if (value.rate === 'null' || value.value === 'undefined' || value.rate === 'NaN') {
|
||||
return '';
|
||||
}
|
||||
return value.rate;
|
||||
};
|
||||
|
||||
const initialize = function () {
|
||||
rateHistory.setting.history.forEach(function (rate) {
|
||||
$scope.history.push({ date: rate.created_at, rate: rate.value, user: rate.user });
|
||||
@ -544,7 +551,8 @@ Application.Controllers.controller('InvoicesController', ['$scope', '$state', 'I
|
||||
});
|
||||
return editMultiVATModalInstance.result.then(function (result) {
|
||||
['Machine', 'Space', 'Training', 'Event', 'Subscription'].forEach(rateType => {
|
||||
Setting.update({ name: `invoice_VAT-rate_${rateType}` }, { value: result.multiVAT[`rate${rateType}`] + '' }, function (data) {
|
||||
const value = _.isFinite(result.multiVAT[`rate${rateType}`]) ? result.multiVAT[`rate${rateType}`] + '' : '';
|
||||
Setting.update({ name: `invoice_VAT-rate_${rateType}` }, { value }, function (data) {
|
||||
return growl.success(_t('app.admin.invoices.VAT_rate_successfully_saved'));
|
||||
}
|
||||
, function (error) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
<td>
|
||||
<span class="no-user-label" ng-show="value.enabled === false" translate>{{'app.admin.invoices.VAT_disabled'}}</span>
|
||||
<span class="no-user-label" ng-show="value.enabled === true" translate>{{'app.admin.invoices.VAT_enabled'}}</span>
|
||||
<span ng-show="value.rate">{{value.rate}}</span>
|
||||
<span ng-show="value.rate">{{rateValue(value)}}</span>
|
||||
</td>
|
||||
<td>{{value.date | amDateFormat:'L LT'}}</td>
|
||||
<td>{{value.user.name}}<span class="no-user-label" ng-hide="value.user" translate>{{ 'app.admin.invoices.deleted_user' }}</span></td>
|
||||
|
@ -72,7 +72,7 @@ class VatHistoryService
|
||||
.history_values.where('created_at >= ?', first_vat_rate_by_type.created_at)
|
||||
.order(created_at: 'ASC')
|
||||
vat_rate_by_type.each do |rate|
|
||||
if rate.value.blank?
|
||||
if rate.value.blank? || rate.value == 'null' || rate.value == 'undefined' || rate.value == 'NaN'
|
||||
# if, at some point in the history, a blank rate was set, the general VAT rate is used instead
|
||||
vat_rate = Setting.find_by(name: 'invoice_VAT-rate')
|
||||
.history_values.where('created_at < ?', rate.created_at)
|
||||
|
Loading…
x
Reference in New Issue
Block a user