Dashboard currency fix

This commit is contained in:
Hillel Coren 2020-02-20 08:31:18 +02:00
parent bcf7f296c7
commit cf9271dd96
6 changed files with 60 additions and 7 deletions

View File

@ -19,6 +19,7 @@ class UpdateReportSettings implements PersistUI {
this.filters,
this.chart,
this.group,
this.selectedGroup,
this.subgroup,
this.sortIndex,
this.sortTotalsIndex,
@ -29,6 +30,7 @@ class UpdateReportSettings implements PersistUI {
final String report;
final BuiltMap<String, String> filters;
final String group;
final String selectedGroup;
final String chart;
final String subgroup;
final int sortIndex;

View File

@ -13,6 +13,7 @@ abstract class ReportsUIState
customStartDate: '',
customEndDate: '',
group: '',
selectedGroup: '',
chart: '',
subgroup: kReportGroupDay,
filters: BuiltMap<String, String>(),
@ -25,6 +26,8 @@ abstract class ReportsUIState
String get group;
String get selectedGroup;
String get chart;
String get subgroup;

View File

@ -26,6 +26,9 @@ class _$ReportsUIStateSerializer
'group',
serializers.serialize(object.group,
specifiedType: const FullType(String)),
'selectedGroup',
serializers.serialize(object.selectedGroup,
specifiedType: const FullType(String)),
'chart',
serializers.serialize(object.chart,
specifiedType: const FullType(String)),
@ -67,6 +70,10 @@ class _$ReportsUIStateSerializer
result.group = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'selectedGroup':
result.selectedGroup = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'chart':
result.chart = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
@ -103,6 +110,8 @@ class _$ReportsUIState extends ReportsUIState {
@override
final String group;
@override
final String selectedGroup;
@override
final String chart;
@override
final String subgroup;
@ -119,6 +128,7 @@ class _$ReportsUIState extends ReportsUIState {
_$ReportsUIState._(
{this.report,
this.group,
this.selectedGroup,
this.chart,
this.subgroup,
this.customStartDate,
@ -131,6 +141,9 @@ class _$ReportsUIState extends ReportsUIState {
if (group == null) {
throw new BuiltValueNullFieldError('ReportsUIState', 'group');
}
if (selectedGroup == null) {
throw new BuiltValueNullFieldError('ReportsUIState', 'selectedGroup');
}
if (chart == null) {
throw new BuiltValueNullFieldError('ReportsUIState', 'chart');
}
@ -162,6 +175,7 @@ class _$ReportsUIState extends ReportsUIState {
return other is ReportsUIState &&
report == other.report &&
group == other.group &&
selectedGroup == other.selectedGroup &&
chart == other.chart &&
subgroup == other.subgroup &&
customStartDate == other.customStartDate &&
@ -175,7 +189,9 @@ class _$ReportsUIState extends ReportsUIState {
$jc(
$jc(
$jc(
$jc($jc($jc(0, report.hashCode), group.hashCode),
$jc(
$jc($jc($jc(0, report.hashCode), group.hashCode),
selectedGroup.hashCode),
chart.hashCode),
subgroup.hashCode),
customStartDate.hashCode),
@ -188,6 +204,7 @@ class _$ReportsUIState extends ReportsUIState {
return (newBuiltValueToStringHelper('ReportsUIState')
..add('report', report)
..add('group', group)
..add('selectedGroup', selectedGroup)
..add('chart', chart)
..add('subgroup', subgroup)
..add('customStartDate', customStartDate)
@ -209,6 +226,11 @@ class ReportsUIStateBuilder
String get group => _$this._group;
set group(String group) => _$this._group = group;
String _selectedGroup;
String get selectedGroup => _$this._selectedGroup;
set selectedGroup(String selectedGroup) =>
_$this._selectedGroup = selectedGroup;
String _chart;
String get chart => _$this._chart;
set chart(String chart) => _$this._chart = chart;
@ -238,6 +260,7 @@ class ReportsUIStateBuilder
if (_$v != null) {
_report = _$v.report;
_group = _$v.group;
_selectedGroup = _$v.selectedGroup;
_chart = _$v.chart;
_subgroup = _$v.subgroup;
_customStartDate = _$v.customStartDate;
@ -269,6 +292,7 @@ class ReportsUIStateBuilder
new _$ReportsUIState._(
report: report,
group: group,
selectedGroup: selectedGroup,
chart: chart,
subgroup: subgroup,
customStartDate: customStartDate,

View File

@ -89,11 +89,34 @@ class DashboardPanels extends StatelessWidget {
? () => viewModel.onOffsetChanged(-1)
: null,
),
if (hasMultipleCurrencies)
if (hasMultipleCurrencies) ...[
Expanded(
child: SizedBox(),
),
DropdownButtonHideUnderline(
child: DropdownButton<String>(
items: memoizedGetCurrencyIds(company, clientMap, groupMap)
.map((currencyId) => DropdownMenuItem<String>(
child: Text(currencyId == kCurrencyAll
? localization.all
: viewModel.currencyMap[currencyId]?.code),
value: currencyId,
))
.toList(),
onChanged: (currencyId) =>
viewModel.onCurrencyChanged(currencyId),
value: state.dashboardUIState.currencyId,
),
),
SizedBox(
width: 12,
),
]
/*
Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
SizedBox(width: 8.0),
Spacer(),
DropdownButtonHideUnderline(
child: DropdownButton<String>(
items: memoizedGetCurrencyIds(company, clientMap, groupMap)
@ -111,7 +134,8 @@ class DashboardPanels extends StatelessWidget {
),
SizedBox(width: 16.0),
],
),
),
*/
],
),
);

View File

@ -115,7 +115,7 @@ class ReportsScreen extends StatelessWidget {
),
body: ListView(
key: ValueKey(
'${viewModel.state.isSaving}_${reportsUIState.report}_${reportsUIState.group}'),
'${viewModel.state.isSaving}_${reportsUIState.report}_${reportsUIState.group}_${reportsUIState.selectedGroup}'),
children: <Widget>[
Flex(
direction: isMobile(context) ? Axis.vertical : Axis.horizontal,
@ -947,7 +947,7 @@ class ReportResult {
store.dispatch(
UpdateReportSettings(
report: reportState.report,
group: '',
selectedGroup: filter,
customStartDate: customStartDate,
customEndDate: customEndDate,
filters: reportState.filters

View File

@ -25,7 +25,7 @@ double getExchangeRateWithMap(BuiltMap<String, CurrencyEntity> currencyMap,
}
if (toCurrency == baseCurrency) {
return 1 / fromCurrency.exchangeRate;
return 1 / (fromCurrency.exchangeRate ?? 1);
}
return toCurrency.exchangeRate * (1 / fromCurrency.exchangeRate);