Skip to content

Commit

Permalink
fix(stock): parsing issues in StockValueReport
Browse files Browse the repository at this point in the history
Fixes a few parsing issues (dates, currencies) in the Stock Value
Report.
  • Loading branch information
jniles committed Apr 7, 2022
1 parent aa59dc6 commit cd2d002
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ angular.module('bhima.controllers')
StockValueConfigController.$inject = [
'$sce', 'NotifyService', 'BaseReportService',
'AppCache', 'reportData', '$state',
'LanguageService', 'moment',
'LanguageService', 'moment', 'SessionService',
];

function StockValueConfigController(
$sce, Notify, SavedReports,
AppCache, reportData, $state, Languages, moment,
AppCache, reportData, $state, Languages, moment, Session,
) {

const vm = this;
Expand All @@ -19,6 +19,7 @@ function StockValueConfigController(
vm.reportDetails = {
dateTo : new Date(),
excludeZeroValue : 0,
currency_id : Session.enterprise.currency_id,
};

// Default values
Expand Down Expand Up @@ -52,10 +53,6 @@ function StockValueConfigController(
vm.reportDetails.currency_id = currency.id;
};

vm.onExcludeZeroValue = () => {
vm.reportDetails.exclude_zero_value = vm.excludeZeroValue;
};

vm.preview = function preview(form) {
if (form.$invalid) { return 0; }

Expand All @@ -67,6 +64,8 @@ function StockValueConfigController(
dateTo,
};

cache.reportDetails = angular.copy(vm.reportDetails);

return SavedReports.requestPreview(reportUrl, reportData.id, angular.copy(options))
.then((result) => {
vm.previewGenerated = true;
Expand All @@ -92,6 +91,7 @@ function StockValueConfigController(
function checkCachedConfiguration() {
if (cache.reportDetails) {
vm.reportDetails = angular.copy(cache.reportDetails);
vm.dateTo = new Date(); // always default to today
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ <h3 translate>REPORT.STOCK_VALUE.TITLE</h3>

<div class="checkbox">
<label>
<input type="checkbox" ng-true-value="1" ng-false-value="0"
ng-model="ReportConfigCtrl.reportDetails.excludeZeroValue"
ng-change="ReportConfigCtrl.onExcludeZeroValue()">
<input type="checkbox" ng-true-value="1" ng-false-value="0" ng-model="ReportConfigCtrl.reportDetails.excludeZeroValue">
<span translate>REPORT.STOCK_VALUE.EXCLUDE_INVENTORIES_ZERO_VALUE</span>
</label>
</div>
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/stock/reports/stock/value.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function reporting(_options, session) {
const options = (typeof (_options.params) === 'string') ? JSON.parse(_options.params) : _options;

data.dateTo = options.dateTo;
data.isEnterpriseCurrency = options.currency_id === session.enterprise.currency_id;
data.isEnterpriseCurrency = Number(options.currency_id) === session.enterprise.currency_id;

const depot = await db.one('SELECT * FROM depot WHERE uuid = ?', [db.bid(options.depot_uuid)]);
const exchangeRate = await Exchange.getExchangeRate(enterpriseId, options.currency_id, new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{{date dateTo}}
</h4>

{{#unless isEntepriseCurrency}}
{{#unless isEnterpriseCurrency}}
{{> exchangeRate rate=exchangeRate currencyId=currency_id}}
{{/unless}}

Expand Down

0 comments on commit cd2d002

Please sign in to comment.