Improve auto-taxes

This commit is contained in:
Hillel Coren 2023-07-23 22:39:58 +03:00
parent 7685d4e87f
commit c8157694be
5 changed files with 112 additions and 33 deletions

View File

@ -18,11 +18,12 @@ abstract class TaxDataEntity
geoState: '', geoState: '',
stateSalesTax: 0, stateSalesTax: 0,
taxSales: 0, taxSales: 0,
districtSalesTax: 0,
/* /*
cityUseTax: 0, cityUseTax: 0,
countyUseTax: 0, countyUseTax: 0,
district1Code: '',
district1SalesTax: 0, district1SalesTax: 0,
district1Code: '',
district1UseTax: 0, district1UseTax: 0,
district2Code: '', district2Code: '',
district2SalesTax: 0, district2SalesTax: 0,
@ -36,7 +37,6 @@ abstract class TaxDataEntity
district5Code: '', district5Code: '',
district5SalesTax: 0, district5SalesTax: 0,
district5UseTax: 0, district5UseTax: 0,
districtSalesTax: 0,
districtUseTax: 0, districtUseTax: 0,
originDestination: '', originDestination: '',
stateUseTax: 0, stateUseTax: 0,
@ -59,13 +59,13 @@ abstract class TaxDataEntity
String get cityTaxCode; String get cityTaxCode;
double get countySalesTax; double get countySalesTax;
String get countyTaxCode; String get countyTaxCode;
double get districtSalesTax;
//double get taxUse; //double get taxUse;
//String get txbService; //String get txbService;
//String get txbFreight; //String get txbFreight;
//double get stateUseTax; //double get stateUseTax;
//double get cityUseTax; //double get cityUseTax;
//double get countyUseTax; //double get countyUseTax;
//double get districtSalesTax;
//double get districtUseTax; //double get districtUseTax;
//String get district1Code; //String get district1Code;
//double get district1SalesTax; //double get district1SalesTax;
@ -95,12 +95,13 @@ abstract class TaxDataEntity
..geoPostalCode = '' ..geoPostalCode = ''
..geoState = '' ..geoState = ''
..stateSalesTax = 0 ..stateSalesTax = 0
..taxSales = 0; ..taxSales = 0
..districtSalesTax = 0;
/* /*
..cityUseTax = 0 ..cityUseTax = 0
..countyUseTax = 0 ..countyUseTax = 0
..district1Code = ''
..district1SalesTax = 0 ..district1SalesTax = 0
..district1Code = ''
..district1UseTax = 0 ..district1UseTax = 0
..district2Code = '' ..district2Code = ''
..district2SalesTax = 0 ..district2SalesTax = 0
@ -114,7 +115,6 @@ abstract class TaxDataEntity
..district5Code = '' ..district5Code = ''
..district5SalesTax = 0 ..district5SalesTax = 0
..district5UseTax = 0 ..district5UseTax = 0
..districtSalesTax = 0
..districtUseTax = 0 ..districtUseTax = 0
..originDestination = '' ..originDestination = ''
..stateUseTax = 0 ..stateUseTax = 0

View File

@ -55,6 +55,9 @@ class _$TaxDataEntitySerializer implements StructuredSerializer<TaxDataEntity> {
'countyTaxCode', 'countyTaxCode',
serializers.serialize(object.countyTaxCode, serializers.serialize(object.countyTaxCode,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
'districtSalesTax',
serializers.serialize(object.districtSalesTax,
specifiedType: const FullType(double)),
]; ];
return result; return result;
@ -112,6 +115,10 @@ class _$TaxDataEntitySerializer implements StructuredSerializer<TaxDataEntity> {
result.countyTaxCode = serializers.deserialize(value, result.countyTaxCode = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'districtSalesTax':
result.districtSalesTax = serializers.deserialize(value,
specifiedType: const FullType(double)) as double;
break;
} }
} }
@ -341,6 +348,8 @@ class _$TaxDataEntity extends TaxDataEntity {
final double countySalesTax; final double countySalesTax;
@override @override
final String countyTaxCode; final String countyTaxCode;
@override
final double districtSalesTax;
factory _$TaxDataEntity([void Function(TaxDataEntityBuilder) updates]) => factory _$TaxDataEntity([void Function(TaxDataEntityBuilder) updates]) =>
(new TaxDataEntityBuilder()..update(updates))._build(); (new TaxDataEntityBuilder()..update(updates))._build();
@ -355,7 +364,8 @@ class _$TaxDataEntity extends TaxDataEntity {
this.citySalesTax, this.citySalesTax,
this.cityTaxCode, this.cityTaxCode,
this.countySalesTax, this.countySalesTax,
this.countyTaxCode}) this.countyTaxCode,
this.districtSalesTax})
: super._() { : super._() {
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
geoPostalCode, r'TaxDataEntity', 'geoPostalCode'); geoPostalCode, r'TaxDataEntity', 'geoPostalCode');
@ -376,6 +386,8 @@ class _$TaxDataEntity extends TaxDataEntity {
countySalesTax, r'TaxDataEntity', 'countySalesTax'); countySalesTax, r'TaxDataEntity', 'countySalesTax');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
countyTaxCode, r'TaxDataEntity', 'countyTaxCode'); countyTaxCode, r'TaxDataEntity', 'countyTaxCode');
BuiltValueNullFieldError.checkNotNull(
districtSalesTax, r'TaxDataEntity', 'districtSalesTax');
} }
@override @override
@ -398,7 +410,8 @@ class _$TaxDataEntity extends TaxDataEntity {
citySalesTax == other.citySalesTax && citySalesTax == other.citySalesTax &&
cityTaxCode == other.cityTaxCode && cityTaxCode == other.cityTaxCode &&
countySalesTax == other.countySalesTax && countySalesTax == other.countySalesTax &&
countyTaxCode == other.countyTaxCode; countyTaxCode == other.countyTaxCode &&
districtSalesTax == other.districtSalesTax;
} }
@override @override
@ -414,6 +427,7 @@ class _$TaxDataEntity extends TaxDataEntity {
_$hash = $jc(_$hash, cityTaxCode.hashCode); _$hash = $jc(_$hash, cityTaxCode.hashCode);
_$hash = $jc(_$hash, countySalesTax.hashCode); _$hash = $jc(_$hash, countySalesTax.hashCode);
_$hash = $jc(_$hash, countyTaxCode.hashCode); _$hash = $jc(_$hash, countyTaxCode.hashCode);
_$hash = $jc(_$hash, districtSalesTax.hashCode);
_$hash = $jf(_$hash); _$hash = $jf(_$hash);
return _$hash; return _$hash;
} }
@ -430,7 +444,8 @@ class _$TaxDataEntity extends TaxDataEntity {
..add('citySalesTax', citySalesTax) ..add('citySalesTax', citySalesTax)
..add('cityTaxCode', cityTaxCode) ..add('cityTaxCode', cityTaxCode)
..add('countySalesTax', countySalesTax) ..add('countySalesTax', countySalesTax)
..add('countyTaxCode', countyTaxCode)) ..add('countyTaxCode', countyTaxCode)
..add('districtSalesTax', districtSalesTax))
.toString(); .toString();
} }
} }
@ -483,7 +498,14 @@ class TaxDataEntityBuilder
set countyTaxCode(String countyTaxCode) => set countyTaxCode(String countyTaxCode) =>
_$this._countyTaxCode = countyTaxCode; _$this._countyTaxCode = countyTaxCode;
TaxDataEntityBuilder(); double _districtSalesTax;
double get districtSalesTax => _$this._districtSalesTax;
set districtSalesTax(double districtSalesTax) =>
_$this._districtSalesTax = districtSalesTax;
TaxDataEntityBuilder() {
TaxDataEntity._initializeBuilder(this);
}
TaxDataEntityBuilder get _$this { TaxDataEntityBuilder get _$this {
final $v = _$v; final $v = _$v;
@ -498,6 +520,7 @@ class TaxDataEntityBuilder
_cityTaxCode = $v.cityTaxCode; _cityTaxCode = $v.cityTaxCode;
_countySalesTax = $v.countySalesTax; _countySalesTax = $v.countySalesTax;
_countyTaxCode = $v.countyTaxCode; _countyTaxCode = $v.countyTaxCode;
_districtSalesTax = $v.districtSalesTax;
_$v = null; _$v = null;
} }
return this; return this;
@ -538,7 +561,8 @@ class TaxDataEntityBuilder
cityTaxCode, r'TaxDataEntity', 'cityTaxCode'), cityTaxCode, r'TaxDataEntity', 'cityTaxCode'),
countySalesTax: countySalesTax:
BuiltValueNullFieldError.checkNotNull(countySalesTax, r'TaxDataEntity', 'countySalesTax'), BuiltValueNullFieldError.checkNotNull(countySalesTax, r'TaxDataEntity', 'countySalesTax'),
countyTaxCode: BuiltValueNullFieldError.checkNotNull(countyTaxCode, r'TaxDataEntity', 'countyTaxCode')); countyTaxCode: BuiltValueNullFieldError.checkNotNull(countyTaxCode, r'TaxDataEntity', 'countyTaxCode'),
districtSalesTax: BuiltValueNullFieldError.checkNotNull(districtSalesTax, r'TaxDataEntity', 'districtSalesTax'));
replace(_$result); replace(_$result);
return _$result; return _$result;
} }

View File

@ -45,6 +45,8 @@ class ClientRepository {
final dynamic response = await webClient.get(url, credentials.token); final dynamic response = await webClient.get(url, credentials.token);
//debugPrint('## CLIENTS: $response');
final ClientListResponse clientResponse = await compute<dynamic, dynamic>( final ClientListResponse clientResponse = await compute<dynamic, dynamic>(
SerializationUtils.deserializeWith, SerializationUtils.deserializeWith,
<dynamic>[ClientListResponse.serializer, response]); <dynamic>[ClientListResponse.serializer, response]);

View File

@ -3,6 +3,7 @@ import 'package:flutter_redux/flutter_redux.dart';
import 'package:invoiceninja_flutter/data/models/invoice_model.dart'; import 'package:invoiceninja_flutter/data/models/invoice_model.dart';
import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/utils/localization.dart'; import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/utils/strings.dart';
class InvoiceTaxDetails extends StatelessWidget { class InvoiceTaxDetails extends StatelessWidget {
const InvoiceTaxDetails({ const InvoiceTaxDetails({
@ -16,31 +17,74 @@ class InvoiceTaxDetails extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final state = StoreProvider.of<AppState>(context).state; final state = StoreProvider.of<AppState>(context).state;
final client = state.clientState.get(invoice.id); final client = state.clientState.get(invoice.clientId);
final taxData = invoice.isNew ? client.taxData : invoice.taxData; final taxData = invoice.isNew ? client.taxData : invoice.taxData;
return AlertDialog( return AlertDialog(
title: Text(localization.taxDetails), title: Text(localization.taxDetails),
content: Table( content: SizedBox(
width: 400,
child: DataTable(
columns: [
DataColumn(label: Text(localization.region)),
DataColumn(label: Text(localization.name)),
DataColumn(label: Text(localization.tax)),
],
rows: [
DataRow(cells: [
DataCell(Text(localization.state)),
DataCell(Text(taxData.geoState)),
DataCell(Text('${taxData.stateSalesTax}')),
]),
DataRow(cells: [
DataCell(Text(localization.county)),
DataCell(Text(toTitleCase(taxData.geoCounty))),
DataCell(Text('${taxData.countySalesTax}')),
]),
DataRow(cells: [
DataCell(Text(localization.city)),
DataCell(Text(toTitleCase(taxData.geoCity))),
DataCell(Text('${taxData.citySalesTax}')),
]),
DataRow(cells: [
DataCell(Text(localization.district)),
DataCell(Text('')),
DataCell(Text('${taxData.districtSalesTax}')),
]),
DataRow(cells: [
DataCell(Text(localization.total)),
DataCell(Text('')),
DataCell(Text('${taxData.taxSales}')),
]),
],
),
/*
child: Table(
children: [ children: [
TableRow(children: [ TableRow(children: [
TableCell(child: Text(localization.state)), TableCell(child: Text(localization.state)),
TableCell(child: Text(taxData.geoState)),
TableCell(child: Text('')), TableCell(child: Text('')),
]), ]),
TableRow(children: [ TableRow(children: [
TableCell(child: Text(localization.county)), TableCell(child: Text(localization.county)),
TableCell(child: Text(toTitleCase(taxData.geoCounty))),
TableCell(child: Text('')), TableCell(child: Text('')),
]), ]),
TableRow(children: [ TableRow(children: [
TableCell(child: Text(localization.city)), TableCell(child: Text(localization.city)),
TableCell(child: Text(toTitleCase(taxData.geoCity))),
TableCell(child: Text('')), TableCell(child: Text('')),
]), ]),
TableRow(children: [ TableRow(children: [
TableCell(child: Text(localization.total)), TableCell(child: Text(localization.total)),
TableCell(child: Text('')), TableCell(child: Text('')),
TableCell(child: Text('')),
]), ]),
], ],
), ),
*/
),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),

View File

@ -18,6 +18,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = { static final Map<String, Map<String, String>> _localizedValues = {
'en': { 'en': {
// STARTER: lang key - do not remove comment // STARTER: lang key - do not remove comment
'district': 'District',
'region': 'Region',
'county': 'County', 'county': 'County',
'tax_details': 'Tax Details', 'tax_details': 'Tax Details',
'activity_10_online': 'activity_10_online':
@ -105934,6 +105936,13 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['county'] ?? _localizedValues[localeCode]['county'] ??
_localizedValues['en']['county']; _localizedValues['en']['county'];
String get region =>
_localizedValues[localeCode]['region'] ??
_localizedValues['en']['region'];
String get district =>
_localizedValues[localeCode]['district'] ??
_localizedValues['en']['district'];
// STARTER: lang field - do not remove comment // STARTER: lang field - do not remove comment