Tax model
This commit is contained in:
parent
9fd6481417
commit
ad1a072a80
|
|
@ -195,107 +195,103 @@ class _TaxSettingsState extends State<TaxSettings> {
|
||||||
SizedBox(height: 12),
|
SizedBox(height: 12),
|
||||||
...taxData.regions.keys.map((region) {
|
...taxData.regions.keys.map((region) {
|
||||||
final taxDataRegion = taxData.regions[region];
|
final taxDataRegion = taxData.regions[region];
|
||||||
return Column(
|
return Column(children: [
|
||||||
children: [
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
child: Row(
|
||||||
child: Row(
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child:
|
||||||
|
Text(countryMap[region]?.name ?? region)),
|
||||||
|
Flexible(
|
||||||
|
child: AppDropdownButton<bool>(
|
||||||
|
value: taxDataRegion.taxAll,
|
||||||
|
onChanged: (dynamic value) {
|
||||||
|
viewModel.onCompanyChanged(company.rebuild(
|
||||||
|
(b) => b
|
||||||
|
..taxData.regions[region] =
|
||||||
|
taxDataRegion.rebuild(
|
||||||
|
(b) => b..taxAll = value)));
|
||||||
|
},
|
||||||
|
items: [
|
||||||
|
DropdownMenuItem<bool>(
|
||||||
|
child: ListTile(
|
||||||
|
dense: true,
|
||||||
|
title: Text(localization.taxAll),
|
||||||
|
),
|
||||||
|
value: true,
|
||||||
|
),
|
||||||
|
DropdownMenuItem<bool>(
|
||||||
|
child: ListTile(
|
||||||
|
dense: true,
|
||||||
|
title: Text(localization.taxSelected),
|
||||||
|
subtitle: Text(
|
||||||
|
'${taxDataRegion.subregions.keys.where((element) => taxDataRegion.subregions[element].applyTax).length} ${localization.selected}'),
|
||||||
|
),
|
||||||
|
value: false,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(minWidth: 120),
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_showDetails[region] =
|
||||||
|
!_showDetails[region];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text(_showDetails[region]
|
||||||
|
? localization.hideDetails
|
||||||
|
: localization.showDetails)),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_showDetails[region]) ...[
|
||||||
|
SizedBox(height: 8),
|
||||||
|
...taxDataRegion.subregions.keys.map((subregion) {
|
||||||
|
final taxDataSubregion =
|
||||||
|
taxDataRegion.subregions[subregion];
|
||||||
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child:
|
child: CheckboxListTile(
|
||||||
Text(countryMap[region]?.name ?? region)),
|
title: Text(region == kTaxRegionUnitedStates
|
||||||
Flexible(
|
? subregion
|
||||||
child: AppDropdownButton<bool>(
|
: (countryMap[subregion]?.name ??
|
||||||
value: taxDataRegion.taxAll,
|
subregion)),
|
||||||
onChanged: (dynamic value) {
|
subtitle: Text(
|
||||||
viewModel.onCompanyChanged(
|
'${taxDataSubregion.taxName}: ${formatNumber(taxDataSubregion.taxRate, context, formatNumberType: FormatNumberType.percent) + (taxDataSubregion.reducedTaxRate != 0 ? ' • ' + formatNumber(taxDataSubregion.reducedTaxRate, context, formatNumberType: FormatNumberType.percent) : '')}',
|
||||||
company.rebuild((b) => b
|
),
|
||||||
..taxData.regions[region] =
|
controlAffinity:
|
||||||
taxDataRegion.rebuild(
|
ListTileControlAffinity.leading,
|
||||||
(b) => b..taxAll = value)));
|
value: taxDataRegion.taxAll ||
|
||||||
},
|
taxDataSubregion.applyTax,
|
||||||
items: [
|
onChanged: taxDataRegion.taxAll
|
||||||
DropdownMenuItem<bool>(
|
? null
|
||||||
child: ListTile(
|
: (value) {
|
||||||
dense: true,
|
viewModel.onCompanyChanged(company.rebuild((b) => b
|
||||||
title: Text(localization.taxAll),
|
..taxData.replace(taxData.rebuild((b) => b
|
||||||
),
|
..regions[region] =
|
||||||
value: true,
|
taxDataRegion.rebuild((b) => b
|
||||||
),
|
..subregions[subregion] =
|
||||||
DropdownMenuItem<bool>(
|
taxDataSubregion.rebuild(
|
||||||
child: ListTile(
|
(b) => b
|
||||||
dense: true,
|
..applyTax = value))))));
|
||||||
title: Text(localization.taxSelected),
|
},
|
||||||
subtitle: Text(
|
),
|
||||||
'${taxDataRegion.subregions.keys.where((element) => taxDataRegion.subregions[element].applyTax).length} ${localization.selected}'),
|
|
||||||
),
|
|
||||||
value: false,
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
ConstrainedBox(
|
TextButton(
|
||||||
constraints: BoxConstraints(minWidth: 120),
|
onPressed: () {
|
||||||
child: TextButton(
|
//
|
||||||
onPressed: () {
|
},
|
||||||
setState(() {
|
child: Text(localization.edit))
|
||||||
_showDetails[region] =
|
|
||||||
!_showDetails[region];
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Text(_showDetails[region]
|
|
||||||
? localization.hideDetails
|
|
||||||
: localization.showDetails)),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
),
|
}).toList(),
|
||||||
if (_showDetails[region])
|
|
||||||
...taxDataRegion.subregions.keys.map((subregion) {
|
|
||||||
final taxDataSubregion =
|
|
||||||
taxDataRegion.subregions[subregion];
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Checkbox(
|
|
||||||
value: taxDataRegion.taxAll ||
|
|
||||||
taxDataSubregion.applyTax,
|
|
||||||
onChanged: taxDataRegion.taxAll
|
|
||||||
? null
|
|
||||||
: (value) {
|
|
||||||
viewModel.onCompanyChanged(company.rebuild((b) => b
|
|
||||||
..taxData.replace(taxData.rebuild((b) => b
|
|
||||||
..regions[region] =
|
|
||||||
taxDataRegion.rebuild((b) => b
|
|
||||||
..subregions[subregion] =
|
|
||||||
taxDataSubregion.rebuild((b) => b
|
|
||||||
..applyTax =
|
|
||||||
value))))));
|
|
||||||
}),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Text(region == kTaxRegionUnitedStates
|
|
||||||
? subregion
|
|
||||||
: (countryMap[subregion]?.name ??
|
|
||||||
subregion)),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'${taxDataSubregion.taxName}: ${formatNumber(taxDataSubregion.taxRate, context, formatNumberType: FormatNumberType.percent)}',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
taxDataSubregion.reducedTaxRate != 0
|
|
||||||
? '${localization.reducedRate}: ${formatNumber(taxDataSubregion.reducedTaxRate, context, formatNumberType: FormatNumberType.percent)}'
|
|
||||||
: '',
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
],
|
],
|
||||||
);
|
]);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue