Add default expense payment type id
This commit is contained in:
parent
01151fdfcf
commit
95d0961d3b
|
|
@ -126,7 +126,7 @@ abstract class ExpenseEntity extends Object
|
||||||
paymentDate: (company?.markExpensesPaid ?? false)
|
paymentDate: (company?.markExpensesPaid ?? false)
|
||||||
? convertDateTimeToSqlDate()
|
? convertDateTimeToSqlDate()
|
||||||
: '',
|
: '',
|
||||||
paymentTypeId: '',
|
paymentTypeId: company?.settings?.defaultExpensePaymentTypeId ?? '',
|
||||||
exchangeRate: 1,
|
exchangeRate: 1,
|
||||||
currencyId: (vendor != null && vendor.hasCurrency)
|
currencyId: (vendor != null && vendor.hasCurrency)
|
||||||
? vendor.currencyId
|
? vendor.currencyId
|
||||||
|
|
|
||||||
|
|
@ -992,6 +992,10 @@ abstract class SettingsEntity
|
||||||
@BuiltValueField(wireName: 'e_invoice_type')
|
@BuiltValueField(wireName: 'e_invoice_type')
|
||||||
String get eInvoiceType;
|
String get eInvoiceType;
|
||||||
|
|
||||||
|
@nullable
|
||||||
|
@BuiltValueField(wireName: 'default_expense_payment_type_id')
|
||||||
|
String get defaultExpensePaymentTypeId;
|
||||||
|
|
||||||
bool get hasAddress => address1 != null && address1.isNotEmpty;
|
bool get hasAddress => address1 != null && address1.isNotEmpty;
|
||||||
|
|
||||||
bool get hasLogo => companyLogo != null && companyLogo.isNotEmpty;
|
bool get hasLogo => companyLogo != null && companyLogo.isNotEmpty;
|
||||||
|
|
|
||||||
|
|
@ -1520,6 +1520,13 @@ class _$SettingsEntitySerializer
|
||||||
..add(serializers.serialize(value,
|
..add(serializers.serialize(value,
|
||||||
specifiedType: const FullType(String)));
|
specifiedType: const FullType(String)));
|
||||||
}
|
}
|
||||||
|
value = object.defaultExpensePaymentTypeId;
|
||||||
|
if (value != null) {
|
||||||
|
result
|
||||||
|
..add('default_expense_payment_type_id')
|
||||||
|
..add(serializers.serialize(value,
|
||||||
|
specifiedType: const FullType(String)));
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2404,6 +2411,10 @@ class _$SettingsEntitySerializer
|
||||||
result.eInvoiceType = serializers.deserialize(value,
|
result.eInvoiceType = serializers.deserialize(value,
|
||||||
specifiedType: const FullType(String)) as String;
|
specifiedType: const FullType(String)) as String;
|
||||||
break;
|
break;
|
||||||
|
case 'default_expense_payment_type_id':
|
||||||
|
result.defaultExpensePaymentTypeId = serializers.deserialize(value,
|
||||||
|
specifiedType: const FullType(String)) as String;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2914,6 +2925,8 @@ class _$SettingsEntity extends SettingsEntity {
|
||||||
final bool showTaskItemDescription;
|
final bool showTaskItemDescription;
|
||||||
@override
|
@override
|
||||||
final String eInvoiceType;
|
final String eInvoiceType;
|
||||||
|
@override
|
||||||
|
final String defaultExpensePaymentTypeId;
|
||||||
|
|
||||||
factory _$SettingsEntity([void Function(SettingsEntityBuilder) updates]) =>
|
factory _$SettingsEntity([void Function(SettingsEntityBuilder) updates]) =>
|
||||||
(new SettingsEntityBuilder()..update(updates))._build();
|
(new SettingsEntityBuilder()..update(updates))._build();
|
||||||
|
|
@ -3134,7 +3147,8 @@ class _$SettingsEntity extends SettingsEntity {
|
||||||
this.shareInvoiceQuoteColumns,
|
this.shareInvoiceQuoteColumns,
|
||||||
this.allowBillableTaskItems,
|
this.allowBillableTaskItems,
|
||||||
this.showTaskItemDescription,
|
this.showTaskItemDescription,
|
||||||
this.eInvoiceType})
|
this.eInvoiceType,
|
||||||
|
this.defaultExpensePaymentTypeId})
|
||||||
: super._();
|
: super._();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -3369,7 +3383,8 @@ class _$SettingsEntity extends SettingsEntity {
|
||||||
shareInvoiceQuoteColumns == other.shareInvoiceQuoteColumns &&
|
shareInvoiceQuoteColumns == other.shareInvoiceQuoteColumns &&
|
||||||
allowBillableTaskItems == other.allowBillableTaskItems &&
|
allowBillableTaskItems == other.allowBillableTaskItems &&
|
||||||
showTaskItemDescription == other.showTaskItemDescription &&
|
showTaskItemDescription == other.showTaskItemDescription &&
|
||||||
eInvoiceType == other.eInvoiceType;
|
eInvoiceType == other.eInvoiceType &&
|
||||||
|
defaultExpensePaymentTypeId == other.defaultExpensePaymentTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __hashCode;
|
int __hashCode;
|
||||||
|
|
@ -3593,6 +3608,7 @@ class _$SettingsEntity extends SettingsEntity {
|
||||||
_$hash = $jc(_$hash, allowBillableTaskItems.hashCode);
|
_$hash = $jc(_$hash, allowBillableTaskItems.hashCode);
|
||||||
_$hash = $jc(_$hash, showTaskItemDescription.hashCode);
|
_$hash = $jc(_$hash, showTaskItemDescription.hashCode);
|
||||||
_$hash = $jc(_$hash, eInvoiceType.hashCode);
|
_$hash = $jc(_$hash, eInvoiceType.hashCode);
|
||||||
|
_$hash = $jc(_$hash, defaultExpensePaymentTypeId.hashCode);
|
||||||
_$hash = $jf(_$hash);
|
_$hash = $jf(_$hash);
|
||||||
return __hashCode ??= _$hash;
|
return __hashCode ??= _$hash;
|
||||||
}
|
}
|
||||||
|
|
@ -3820,7 +3836,8 @@ class _$SettingsEntity extends SettingsEntity {
|
||||||
..add('shareInvoiceQuoteColumns', shareInvoiceQuoteColumns)
|
..add('shareInvoiceQuoteColumns', shareInvoiceQuoteColumns)
|
||||||
..add('allowBillableTaskItems', allowBillableTaskItems)
|
..add('allowBillableTaskItems', allowBillableTaskItems)
|
||||||
..add('showTaskItemDescription', showTaskItemDescription)
|
..add('showTaskItemDescription', showTaskItemDescription)
|
||||||
..add('eInvoiceType', eInvoiceType))
|
..add('eInvoiceType', eInvoiceType)
|
||||||
|
..add('defaultExpensePaymentTypeId', defaultExpensePaymentTypeId))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4889,6 +4906,11 @@ class SettingsEntityBuilder
|
||||||
String get eInvoiceType => _$this._eInvoiceType;
|
String get eInvoiceType => _$this._eInvoiceType;
|
||||||
set eInvoiceType(String eInvoiceType) => _$this._eInvoiceType = eInvoiceType;
|
set eInvoiceType(String eInvoiceType) => _$this._eInvoiceType = eInvoiceType;
|
||||||
|
|
||||||
|
String _defaultExpensePaymentTypeId;
|
||||||
|
String get defaultExpensePaymentTypeId => _$this._defaultExpensePaymentTypeId;
|
||||||
|
set defaultExpensePaymentTypeId(String defaultExpensePaymentTypeId) =>
|
||||||
|
_$this._defaultExpensePaymentTypeId = defaultExpensePaymentTypeId;
|
||||||
|
|
||||||
SettingsEntityBuilder();
|
SettingsEntityBuilder();
|
||||||
|
|
||||||
SettingsEntityBuilder get _$this {
|
SettingsEntityBuilder get _$this {
|
||||||
|
|
@ -5110,6 +5132,7 @@ class SettingsEntityBuilder
|
||||||
_allowBillableTaskItems = $v.allowBillableTaskItems;
|
_allowBillableTaskItems = $v.allowBillableTaskItems;
|
||||||
_showTaskItemDescription = $v.showTaskItemDescription;
|
_showTaskItemDescription = $v.showTaskItemDescription;
|
||||||
_eInvoiceType = $v.eInvoiceType;
|
_eInvoiceType = $v.eInvoiceType;
|
||||||
|
_defaultExpensePaymentTypeId = $v.defaultExpensePaymentTypeId;
|
||||||
_$v = null;
|
_$v = null;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -5350,7 +5373,8 @@ class SettingsEntityBuilder
|
||||||
shareInvoiceQuoteColumns: shareInvoiceQuoteColumns,
|
shareInvoiceQuoteColumns: shareInvoiceQuoteColumns,
|
||||||
allowBillableTaskItems: allowBillableTaskItems,
|
allowBillableTaskItems: allowBillableTaskItems,
|
||||||
showTaskItemDescription: showTaskItemDescription,
|
showTaskItemDescription: showTaskItemDescription,
|
||||||
eInvoiceType: eInvoiceType);
|
eInvoiceType: eInvoiceType,
|
||||||
|
defaultExpensePaymentTypeId: defaultExpensePaymentTypeId);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
String _$failedField;
|
String _$failedField;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
// Flutter imports:
|
// Flutter imports:
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/static/static_selectors.dart';
|
||||||
|
|
||||||
// Project imports:
|
// Project imports:
|
||||||
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
|
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/entity_dropdown.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
|
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/forms/bool_dropdown_button.dart';
|
import 'package:invoiceninja_flutter/ui/app/forms/bool_dropdown_button.dart';
|
||||||
|
|
@ -43,7 +46,9 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
final viewModel = widget.viewModel;
|
final viewModel = widget.viewModel;
|
||||||
|
final state = viewModel.state;
|
||||||
final company = viewModel.company;
|
final company = viewModel.company;
|
||||||
|
final settings = viewModel.settings;
|
||||||
|
|
||||||
return EditScaffold(
|
return EditScaffold(
|
||||||
title: localization.expenseSettings,
|
title: localization.expenseSettings,
|
||||||
|
|
@ -70,6 +75,20 @@ class _ExpenseSettingsState extends State<ExpenseSettings> {
|
||||||
onChanged: (value) => viewModel.onCompanyChanged(
|
onChanged: (value) => viewModel.onCompanyChanged(
|
||||||
company.rebuild((b) => b..markExpensesPaid = value)),
|
company.rebuild((b) => b..markExpensesPaid = value)),
|
||||||
),
|
),
|
||||||
|
if (company.markExpensesPaid == true)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 20, top: 8),
|
||||||
|
child: EntityDropdown(
|
||||||
|
entityType: EntityType.paymentType,
|
||||||
|
entityList: memoizedPaymentTypeList(
|
||||||
|
state.staticState.paymentTypeMap),
|
||||||
|
labelText: localization.paymentType,
|
||||||
|
entityId: settings.defaultExpensePaymentTypeId,
|
||||||
|
onSelected: (paymentType) => viewModel.onSettingsChanged(
|
||||||
|
settings.rebuild((b) =>
|
||||||
|
b..defaultExpensePaymentTypeId = paymentType?.id)),
|
||||||
|
),
|
||||||
|
),
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
activeColor: Theme.of(context).colorScheme.secondary,
|
activeColor: Theme.of(context).colorScheme.secondary,
|
||||||
title: Text(localization.convertCurrency),
|
title: Text(localization.convertCurrency),
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,12 @@ import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
// Package imports:
|
// Package imports:
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/client_model.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/group_model.dart';
|
||||||
|
import 'package:invoiceninja_flutter/data/models/settings_model.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/group/group_actions.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
|
|
||||||
// Project imports:
|
// Project imports:
|
||||||
|
|
@ -41,6 +47,8 @@ class ExpenseSettingsVM {
|
||||||
@required this.onCompanyChanged,
|
@required this.onCompanyChanged,
|
||||||
@required this.onSavePressed,
|
@required this.onSavePressed,
|
||||||
@required this.onConfigureCategoriesPressed,
|
@required this.onConfigureCategoriesPressed,
|
||||||
|
@required this.onSettingsChanged,
|
||||||
|
@required this.settings,
|
||||||
});
|
});
|
||||||
|
|
||||||
static ExpenseSettingsVM fromStore(Store<AppState> store) {
|
static ExpenseSettingsVM fromStore(Store<AppState> store) {
|
||||||
|
|
@ -49,15 +57,34 @@ class ExpenseSettingsVM {
|
||||||
return ExpenseSettingsVM(
|
return ExpenseSettingsVM(
|
||||||
state: state,
|
state: state,
|
||||||
company: state.uiState.settingsUIState.company,
|
company: state.uiState.settingsUIState.company,
|
||||||
|
settings: state.uiState.settingsUIState.settings,
|
||||||
onCompanyChanged: (company) =>
|
onCompanyChanged: (company) =>
|
||||||
store.dispatch(UpdateCompany(company: company)),
|
store.dispatch(UpdateCompany(company: company)),
|
||||||
|
onSettingsChanged: (settings) =>
|
||||||
|
store.dispatch(UpdateSettings(settings: settings)),
|
||||||
onSavePressed: (context) {
|
onSavePressed: (context) {
|
||||||
Debouncer.runOnComplete(() {
|
Debouncer.runOnComplete(() {
|
||||||
final settingsUIState = store.state.uiState.settingsUIState;
|
final settingsUIState = store.state.uiState.settingsUIState;
|
||||||
|
switch (settingsUIState.entityType) {
|
||||||
|
case EntityType.company:
|
||||||
final completer = snackBarCompleter<Null>(
|
final completer = snackBarCompleter<Null>(
|
||||||
context, AppLocalization.of(context).savedSettings);
|
context, AppLocalization.of(context).savedSettings);
|
||||||
store.dispatch(SaveCompanyRequest(
|
store.dispatch(SaveCompanyRequest(
|
||||||
completer: completer, company: settingsUIState.company));
|
completer: completer, company: settingsUIState.company));
|
||||||
|
break;
|
||||||
|
case EntityType.group:
|
||||||
|
final completer = snackBarCompleter<GroupEntity>(
|
||||||
|
context, AppLocalization.of(context).savedSettings);
|
||||||
|
store.dispatch(SaveGroupRequest(
|
||||||
|
completer: completer, group: settingsUIState.group));
|
||||||
|
break;
|
||||||
|
case EntityType.client:
|
||||||
|
final completer = snackBarCompleter<ClientEntity>(
|
||||||
|
context, AppLocalization.of(context).savedSettings);
|
||||||
|
store.dispatch(SaveClientRequest(
|
||||||
|
completer: completer, client: settingsUIState.client));
|
||||||
|
break;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onConfigureCategoriesPressed: (context) {
|
onConfigureCategoriesPressed: (context) {
|
||||||
|
|
@ -69,6 +96,8 @@ class ExpenseSettingsVM {
|
||||||
final AppState state;
|
final AppState state;
|
||||||
final Function(BuildContext) onSavePressed;
|
final Function(BuildContext) onSavePressed;
|
||||||
final CompanyEntity company;
|
final CompanyEntity company;
|
||||||
|
final SettingsEntity settings;
|
||||||
final Function(CompanyEntity) onCompanyChanged;
|
final Function(CompanyEntity) onCompanyChanged;
|
||||||
|
final Function(SettingsEntity) onSettingsChanged;
|
||||||
final Function(BuildContext) onConfigureCategoriesPressed;
|
final Function(BuildContext) onConfigureCategoriesPressed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue