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

View File

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

View File

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

View File

@ -89,11 +89,34 @@ class DashboardPanels extends StatelessWidget {
? () => viewModel.onOffsetChanged(-1) ? () => viewModel.onOffsetChanged(-1)
: null, : 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( Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[ children: <Widget>[
SizedBox(width: 8.0), SizedBox(width: 8.0),
Spacer(),
DropdownButtonHideUnderline( DropdownButtonHideUnderline(
child: DropdownButton<String>( child: DropdownButton<String>(
items: memoizedGetCurrencyIds(company, clientMap, groupMap) items: memoizedGetCurrencyIds(company, clientMap, groupMap)
@ -111,7 +134,8 @@ class DashboardPanels extends StatelessWidget {
), ),
SizedBox(width: 16.0), SizedBox(width: 16.0),
], ],
), ),
*/
], ],
), ),
); );

View File

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

View File

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