diff --git a/lib/data/models/invoice_model.dart b/lib/data/models/invoice_model.dart index 759eeca909a..f96dda1b536 100644 --- a/lib/data/models/invoice_model.dart +++ b/lib/data/models/invoice_model.dart @@ -1552,7 +1552,8 @@ class TaskItemFields { abstract class InvoiceItemEntity implements Built { - factory InvoiceItemEntity({String? productKey, double? quantity}) { + factory InvoiceItemEntity( + {String? productKey, double? quantity, String? typeId}) { return _$InvoiceItemEntity._( productKey: productKey ?? '', notes: '', @@ -1565,7 +1566,7 @@ abstract class InvoiceItemEntity taxRate2: 0, taxName3: '', taxRate3: 0, - typeId: TYPE_STANDARD, + typeId: typeId ?? TYPE_STANDARD, customValue1: '', customValue2: '', customValue3: '', diff --git a/lib/data/models/vendor_model.dart b/lib/data/models/vendor_model.dart index 71258a79630..be4549e44f8 100644 --- a/lib/data/models/vendor_model.dart +++ b/lib/data/models/vendor_model.dart @@ -94,6 +94,7 @@ abstract class VendorEntity extends Object number: '', isChanged: false, name: '', + displayName: '', address1: '', address2: '', city: '', @@ -164,6 +165,9 @@ abstract class VendorEntity extends Object String get name; + @BuiltValueField(wireName: 'display_name') + String get displayName; + String get address1; String get address2; @@ -469,7 +473,8 @@ abstract class VendorEntity extends Object @override String get listDisplayName { - return name; + // TODO simplify once not needed any more + return displayName.isNotEmpty ? displayName : calculateDisplayName; } @override @@ -520,6 +525,7 @@ abstract class VendorEntity extends Object ..activities.replace(BuiltList()) ..lastLogin = 0 ..languageId = '' + ..displayName = '' ..classification = ''; static Serializer get serializer => _$vendorEntitySerializer; diff --git a/lib/data/models/vendor_model.g.dart b/lib/data/models/vendor_model.g.dart index f79da094c85..3f0df455066 100644 --- a/lib/data/models/vendor_model.g.dart +++ b/lib/data/models/vendor_model.g.dart @@ -116,6 +116,9 @@ class _$VendorEntitySerializer implements StructuredSerializer { final result = [ 'name', serializers.serialize(object.name, specifiedType: const FullType(String)), + 'display_name', + serializers.serialize(object.displayName, + specifiedType: const FullType(String)), 'address1', serializers.serialize(object.address1, specifiedType: const FullType(String)), @@ -260,6 +263,10 @@ class _$VendorEntitySerializer implements StructuredSerializer { result.name = serializers.deserialize(value, specifiedType: const FullType(String))! as String; break; + case 'display_name': + result.displayName = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; case 'address1': result.address1 = serializers.deserialize(value, specifiedType: const FullType(String))! as String; @@ -790,6 +797,8 @@ class _$VendorEntity extends VendorEntity { @override final String name; @override + final String displayName; + @override final String address1; @override final String address2; @@ -860,6 +869,7 @@ class _$VendorEntity extends VendorEntity { _$VendorEntity._( {this.loadedAt, required this.name, + required this.displayName, required this.address1, required this.address2, required this.city, @@ -894,6 +904,8 @@ class _$VendorEntity extends VendorEntity { required this.id}) : super._() { BuiltValueNullFieldError.checkNotNull(name, r'VendorEntity', 'name'); + BuiltValueNullFieldError.checkNotNull( + displayName, r'VendorEntity', 'displayName'); BuiltValueNullFieldError.checkNotNull( address1, r'VendorEntity', 'address1'); BuiltValueNullFieldError.checkNotNull( @@ -958,6 +970,7 @@ class _$VendorEntity extends VendorEntity { if (identical(other, this)) return true; return other is VendorEntity && name == other.name && + displayName == other.displayName && address1 == other.address1 && address2 == other.address2 && city == other.city && @@ -998,6 +1011,7 @@ class _$VendorEntity extends VendorEntity { if (__hashCode != null) return __hashCode!; var _$hash = 0; _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, displayName.hashCode); _$hash = $jc(_$hash, address1.hashCode); _$hash = $jc(_$hash, address2.hashCode); _$hash = $jc(_$hash, city.hashCode); @@ -1039,6 +1053,7 @@ class _$VendorEntity extends VendorEntity { return (newBuiltValueToStringHelper(r'VendorEntity') ..add('loadedAt', loadedAt) ..add('name', name) + ..add('displayName', displayName) ..add('address1', address1) ..add('address2', address2) ..add('city', city) @@ -1087,6 +1102,10 @@ class VendorEntityBuilder String? get name => _$this._name; set name(String? name) => _$this._name = name; + String? _displayName; + String? get displayName => _$this._displayName; + set displayName(String? displayName) => _$this._displayName = displayName; + String? _address1; String? get address1 => _$this._address1; set address1(String? address1) => _$this._address1 = address1; @@ -1233,6 +1252,7 @@ class VendorEntityBuilder if ($v != null) { _loadedAt = $v.loadedAt; _name = $v.name; + _displayName = $v.displayName; _address1 = $v.address1; _address2 = $v.address2; _city = $v.city; @@ -1292,6 +1312,8 @@ class VendorEntityBuilder loadedAt: loadedAt, name: BuiltValueNullFieldError.checkNotNull( name, r'VendorEntity', 'name'), + displayName: BuiltValueNullFieldError.checkNotNull( + displayName, r'VendorEntity', 'displayName'), address1: BuiltValueNullFieldError.checkNotNull( address1, r'VendorEntity', 'address1'), address2: BuiltValueNullFieldError.checkNotNull( @@ -1304,12 +1326,10 @@ class VendorEntityBuilder postalCode, r'VendorEntity', 'postalCode'), countryId: BuiltValueNullFieldError.checkNotNull( countryId, r'VendorEntity', 'countryId'), - languageId: BuiltValueNullFieldError.checkNotNull( - languageId, r'VendorEntity', 'languageId'), - phone: BuiltValueNullFieldError.checkNotNull( - phone, r'VendorEntity', 'phone'), - privateNotes: - BuiltValueNullFieldError.checkNotNull(privateNotes, r'VendorEntity', 'privateNotes'), + languageId: + BuiltValueNullFieldError.checkNotNull(languageId, r'VendorEntity', 'languageId'), + phone: BuiltValueNullFieldError.checkNotNull(phone, r'VendorEntity', 'phone'), + privateNotes: BuiltValueNullFieldError.checkNotNull(privateNotes, r'VendorEntity', 'privateNotes'), publicNotes: BuiltValueNullFieldError.checkNotNull(publicNotes, r'VendorEntity', 'publicNotes'), website: BuiltValueNullFieldError.checkNotNull(website, r'VendorEntity', 'website'), number: BuiltValueNullFieldError.checkNotNull(number, r'VendorEntity', 'number'), diff --git a/lib/ui/app/pinput.dart b/lib/ui/app/pinput.dart index 10a24f088c6..9126900c430 100644 --- a/lib/ui/app/pinput.dart +++ b/lib/ui/app/pinput.dart @@ -9,7 +9,7 @@ class AppPinput extends StatelessWidget { @override Widget build(BuildContext context) { - final localization = AppLocalization.of(context); + final localization = AppLocalization.of(context)!; return Pinput( onCompleted: onCompleted, @@ -18,7 +18,7 @@ class AppPinput extends StatelessWidget { showCursor: true, androidSmsAutofillMethod: AndroidSmsAutofillMethod.smsUserConsentApi, validator: (value) => - value!.isEmpty ? localization!.pleaseEnterACode : null, + value!.isEmpty ? localization.pleaseEnterACode : null, ); } } diff --git a/lib/ui/app/pinput.dart.foss b/lib/ui/app/pinput.dart.foss index aba7a387483..802a65c9627 100644 --- a/lib/ui/app/pinput.dart.foss +++ b/lib/ui/app/pinput.dart.foss @@ -3,13 +3,13 @@ import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; class AppPinput extends StatelessWidget { - const AppPinput({Key key, this.onCompleted}) : super(key: key); + const AppPinput({Key? key, this.onCompleted}) : super(key: key); - final ValueChanged onCompleted; + final ValueChanged? onCompleted; @override Widget build(BuildContext context) { - final localization = AppLocalization.of(context); + final localization = AppLocalization.of(context)!; return DecoratedFormField( label: localization.code, diff --git a/lib/ui/invoice/edit/invoice_edit_desktop.dart b/lib/ui/invoice/edit/invoice_edit_desktop.dart index ae2ac2da13d..9120d5684c5 100644 --- a/lib/ui/invoice/edit/invoice_edit_desktop.dart +++ b/lib/ui/invoice/edit/invoice_edit_desktop.dart @@ -292,8 +292,8 @@ class InvoiceEditDesktopState extends State vendorId: invoice.vendorId, vendorState: state.vendorState, onSelected: (vendor) { - viewModel.onVendorChanged!( - context, invoice, vendor as VendorEntity); + viewModel.onVendorChanged!(context, invoice, + vendor as VendorEntity?); }, onAddPressed: (completer) => viewModel .onAddVendorPressed!(context, completer), diff --git a/lib/ui/invoice/edit/invoice_edit_details.dart b/lib/ui/invoice/edit/invoice_edit_details.dart index ba6d8aac20a..d382f1a93d9 100644 --- a/lib/ui/invoice/edit/invoice_edit_details.dart +++ b/lib/ui/invoice/edit/invoice_edit_details.dart @@ -173,7 +173,7 @@ class InvoiceEditDetailsState extends State { vendorState: state.vendorState, onSelected: (vendor) { viewModel.onVendorChanged!( - context, invoice, vendor as VendorEntity); + context, invoice, vendor as VendorEntity?); }, onAddPressed: (completer) => viewModel.onAddVendorPressed!(context, completer), diff --git a/lib/ui/invoice/edit/invoice_edit_items.dart b/lib/ui/invoice/edit/invoice_edit_items.dart index e33f8163d17..a60ad8ebd2a 100644 --- a/lib/ui/invoice/edit/invoice_edit_items.dart +++ b/lib/ui/invoice/edit/invoice_edit_items.dart @@ -252,7 +252,9 @@ class ItemEditDetailsState extends State { child: Column( children: [ DecoratedFormField( - label: localization.product, + label: widget.invoiceItem.isTask + ? localization.service + : localization.product, controller: _productKeyController, onSavePressed: widget.entityViewModel.onSavePressed, keyboardType: TextInputType.text, @@ -296,7 +298,9 @@ class ItemEditDetailsState extends State { value: _custom4Controller.text, ), DecoratedFormField( - label: localization.unitCost, + label: widget.invoiceItem.isTask + ? localization.rate + : localization.unitCost, controller: _costController, keyboardType: TextInputType.numberWithOptions(decimal: true, signed: true), @@ -304,7 +308,9 @@ class ItemEditDetailsState extends State { ), company.enableProductQuantity ? DecoratedFormField( - label: localization.quantity, + label: widget.invoiceItem.isTask + ? localization.hours + : localization.quantity, controller: _qtyController, keyboardType: TextInputType.numberWithOptions( decimal: true, signed: true), diff --git a/lib/ui/invoice/edit/invoice_item_selector.dart b/lib/ui/invoice/edit/invoice_item_selector.dart index b8795699652..168fba53347 100644 --- a/lib/ui/invoice/edit/invoice_item_selector.dart +++ b/lib/ui/invoice/edit/invoice_item_selector.dart @@ -42,7 +42,7 @@ class _InvoiceItemSelectorState extends State with SingleTickerProviderStateMixin { String? _filter; String? _filterClientId; - TabController? _tabController; + late TabController _tabController; final List _selected = []; final _textController = TextEditingController(); @@ -57,15 +57,17 @@ class _InvoiceItemSelectorState extends State @override void dispose() { _textController.dispose(); - _tabController!.dispose(); + _tabController.dispose(); super.dispose(); } void _addBlankItem(CompanyEntity company) { widget.onItemsSelected!([ InvoiceItemEntity( - quantity: - company.defaultQuantity || !company.enableProductQuantity ? 1 : 0) + quantity: + company.defaultQuantity || !company.enableProductQuantity ? 1 : 0, + typeId: _tabController.index == 1 ? InvoiceItemEntity.TYPE_TASK : null, + ) ]); Navigator.pop(context); } diff --git a/lib/ui/vendor/edit/vendor_edit_footer.dart b/lib/ui/vendor/edit/vendor_edit_footer.dart index 4d0a4697075..078e8172d8e 100644 --- a/lib/ui/vendor/edit/vendor_edit_footer.dart +++ b/lib/ui/vendor/edit/vendor_edit_footer.dart @@ -61,8 +61,8 @@ class VendorEditFooter extends StatelessWidget { padding: const EdgeInsets.only(left: 16, top: 8), child: Text( vendor.number.isEmpty - ? vendor.name - : '${vendor.number} • ${vendor.name}', + ? vendor.calculateDisplayName + : '${vendor.number} • ${vendor.calculateDisplayName}', style: TextStyle( color: state.prefState.enableDarkMode ? Colors.white diff --git a/lib/utils/app_review.dart.foss b/lib/utils/app_review.dart.foss index 713b9af7b0f..06697eb2a42 100644 --- a/lib/utils/app_review.dart.foss +++ b/lib/utils/app_review.dart.foss @@ -7,6 +7,6 @@ class AppReview { static void requestReview() => null; - static void openStoreListing() => - launch(getRateAppURL(navigatorKey.currentContext)); + static void openStoreListing() => launchUrl( + Uri.dataFromString(getRateAppURL(navigatorKey.currentContext!))); } diff --git a/lib/utils/oauth.dart.foss b/lib/utils/oauth.dart.foss index cc3c38e5139..ac91b1f0474 100644 --- a/lib/utils/oauth.dart.foss +++ b/lib/utils/oauth.dart.foss @@ -1,17 +1,17 @@ class GoogleOAuth { - static bool get isEnabled => false; - static Future signIn(Function(String, String) callback, {bool isSilent = false}) async { - // + static Future signIn(Function(String, String) callback, + {bool isSilent = false}) async { + return false; } static Future signUp(Function(String, String) callback) async { - // + return false; } static Future requestGmailScope() async { - // + return false; } /* @@ -20,11 +20,11 @@ class GoogleOAuth { } */ - static void signOut() async { + static Future signOut() async { // } - static void disconnect() async { + static Future disconnect() async { // } -} +} \ No newline at end of file