This commit is contained in:
Hillel Coren 2018-12-26 12:51:08 +02:00
parent 3d3a9f8031
commit dddbb5aa16
5 changed files with 111 additions and 56 deletions

View File

@ -554,6 +554,14 @@ abstract class InvoiceItemEntity extends Object
double get discount; double get discount;
@nullable
@BuiltValueField(wireName: 'task_public_id')
int get taskId;
@nullable
@BuiltValueField(wireName: 'expense_public_id')
int get expenseId;
double get total => round(qty * cost, 2); double get total => round(qty * cost, 2);
@override @override

View File

@ -560,6 +560,18 @@ class _$InvoiceItemEntitySerializer
serializers.serialize(object.discount, serializers.serialize(object.discount,
specifiedType: const FullType(double)), specifiedType: const FullType(double)),
]; ];
if (object.taskId != null) {
result
..add('task_public_id')
..add(serializers.serialize(object.taskId,
specifiedType: const FullType(int)));
}
if (object.expenseId != null) {
result
..add('expense_public_id')
..add(serializers.serialize(object.expenseId,
specifiedType: const FullType(int)));
}
if (object.createdAt != null) { if (object.createdAt != null) {
result result
..add('created_at') ..add('created_at')
@ -659,6 +671,14 @@ class _$InvoiceItemEntitySerializer
result.discount = serializers.deserialize(value, result.discount = serializers.deserialize(value,
specifiedType: const FullType(double)) as double; specifiedType: const FullType(double)) as double;
break; break;
case 'task_public_id':
result.taskId = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'expense_public_id':
result.expenseId = serializers.deserialize(value,
specifiedType: const FullType(int)) as int;
break;
case 'created_at': case 'created_at':
result.createdAt = serializers.deserialize(value, result.createdAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
@ -1809,6 +1829,10 @@ class _$InvoiceItemEntity extends InvoiceItemEntity {
@override @override
final double discount; final double discount;
@override @override
final int taskId;
@override
final int expenseId;
@override
final int createdAt; final int createdAt;
@override @override
final int updatedAt; final int updatedAt;
@ -1837,6 +1861,8 @@ class _$InvoiceItemEntity extends InvoiceItemEntity {
this.customValue1, this.customValue1,
this.customValue2, this.customValue2,
this.discount, this.discount,
this.taskId,
this.expenseId,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
this.archivedAt, this.archivedAt,
@ -1907,6 +1933,8 @@ class _$InvoiceItemEntity extends InvoiceItemEntity {
customValue1 == other.customValue1 && customValue1 == other.customValue1 &&
customValue2 == other.customValue2 && customValue2 == other.customValue2 &&
discount == other.discount && discount == other.discount &&
taskId == other.taskId &&
expenseId == other.expenseId &&
createdAt == other.createdAt && createdAt == other.createdAt &&
updatedAt == other.updatedAt && updatedAt == other.updatedAt &&
archivedAt == other.archivedAt && archivedAt == other.archivedAt &&
@ -1935,11 +1963,8 @@ class _$InvoiceItemEntity extends InvoiceItemEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
0, $jc($jc(0, productKey.hashCode),
productKey notes.hashCode),
.hashCode),
notes
.hashCode),
cost.hashCode), cost.hashCode),
qty.hashCode), qty.hashCode),
taxName1.hashCode), taxName1.hashCode),
@ -1950,6 +1975,8 @@ class _$InvoiceItemEntity extends InvoiceItemEntity {
customValue1.hashCode), customValue1.hashCode),
customValue2.hashCode), customValue2.hashCode),
discount.hashCode), discount.hashCode),
taskId.hashCode),
expenseId.hashCode),
createdAt.hashCode), createdAt.hashCode),
updatedAt.hashCode), updatedAt.hashCode),
archivedAt.hashCode), archivedAt.hashCode),
@ -1973,6 +2000,8 @@ class _$InvoiceItemEntity extends InvoiceItemEntity {
..add('customValue1', customValue1) ..add('customValue1', customValue1)
..add('customValue2', customValue2) ..add('customValue2', customValue2)
..add('discount', discount) ..add('discount', discount)
..add('taskId', taskId)
..add('expenseId', expenseId)
..add('createdAt', createdAt) ..add('createdAt', createdAt)
..add('updatedAt', updatedAt) ..add('updatedAt', updatedAt)
..add('archivedAt', archivedAt) ..add('archivedAt', archivedAt)
@ -2036,6 +2065,14 @@ class InvoiceItemEntityBuilder
double get discount => _$this._discount; double get discount => _$this._discount;
set discount(double discount) => _$this._discount = discount; set discount(double discount) => _$this._discount = discount;
int _taskId;
int get taskId => _$this._taskId;
set taskId(int taskId) => _$this._taskId = taskId;
int _expenseId;
int get expenseId => _$this._expenseId;
set expenseId(int expenseId) => _$this._expenseId = expenseId;
int _createdAt; int _createdAt;
int get createdAt => _$this._createdAt; int get createdAt => _$this._createdAt;
set createdAt(int createdAt) => _$this._createdAt = createdAt; set createdAt(int createdAt) => _$this._createdAt = createdAt;
@ -2076,6 +2113,8 @@ class InvoiceItemEntityBuilder
_customValue1 = _$v.customValue1; _customValue1 = _$v.customValue1;
_customValue2 = _$v.customValue2; _customValue2 = _$v.customValue2;
_discount = _$v.discount; _discount = _$v.discount;
_taskId = _$v.taskId;
_expenseId = _$v.expenseId;
_createdAt = _$v.createdAt; _createdAt = _$v.createdAt;
_updatedAt = _$v.updatedAt; _updatedAt = _$v.updatedAt;
_archivedAt = _$v.archivedAt; _archivedAt = _$v.archivedAt;
@ -2116,6 +2155,8 @@ class InvoiceItemEntityBuilder
customValue1: customValue1, customValue1: customValue1,
customValue2: customValue2, customValue2: customValue2,
discount: discount, discount: discount,
taskId: taskId,
expenseId: expenseId,
createdAt: createdAt, createdAt: createdAt,
updatedAt: updatedAt, updatedAt: updatedAt,
archivedAt: archivedAt, archivedAt: archivedAt,

View File

@ -127,7 +127,7 @@ abstract class TaskEntity extends Object
return updateTaskTime(taskTime, times.length - 1); return updateTaskTime(taskTime, times.length - 1);
} }
bool get isPaid => invoiceId != null && invoiceId > 0; bool get isInvoiced => invoiceId != null && invoiceId > 0;
@override @override
EntityType get entityType { EntityType get entityType {

View File

@ -80,7 +80,8 @@ class _TaskEditDetailsState extends State<TaskEditDetails> {
children: <Widget>[ children: <Widget>[
FormCard( FormCard(
children: <Widget>[ children: <Widget>[
task.invoiceId == null ? EntityDropdown( !task.isInvoiced
? EntityDropdown(
key: Key('__client_${task.clientId}__'), key: Key('__client_${task.clientId}__'),
entityType: EntityType.client, entityType: EntityType.client,
labelText: localization.client, labelText: localization.client,
@ -98,17 +99,21 @@ class _TaskEditDetailsState extends State<TaskEditDetails> {
onAddPressed: (completer) { onAddPressed: (completer) {
viewModel.onAddClientPressed(context, completer); viewModel.onAddClientPressed(context, completer);
}, },
) : SizedBox(), )
task.invoiceId == null ? EntityDropdown( : SizedBox(),
!task.isInvoiced
? EntityDropdown(
key: Key('__project_${task.clientId}__'), key: Key('__project_${task.clientId}__'),
entityType: EntityType.project, entityType: EntityType.project,
labelText: localization.project, labelText: localization.project,
initialValue: initialValue: (state.projectState.map[task.projectId] ??
(state.projectState.map[task.projectId] ?? ProjectEntity()) ProjectEntity())
.name, .name,
entityMap: state.projectState.map, entityMap: state.projectState.map,
entityList: memoizedDropdownProjectList(state.projectState.map, entityList: memoizedDropdownProjectList(
state.projectState.list, task.clientId), state.projectState.map,
state.projectState.list,
task.clientId),
onSelected: (selected) { onSelected: (selected) {
final project = selected as ProjectEntity; final project = selected as ProjectEntity;
viewModel.onChanged(task.rebuild((b) => b viewModel.onChanged(task.rebuild((b) => b
@ -118,7 +123,8 @@ class _TaskEditDetailsState extends State<TaskEditDetails> {
onAddPressed: (completer) { onAddPressed: (completer) {
viewModel.onAddProjectPressed(context, completer); viewModel.onAddProjectPressed(context, completer);
}, },
) : SizedBox(), )
: SizedBox(),
TextFormField( TextFormField(
maxLines: 4, maxLines: 4,
controller: _descriptionController, controller: _descriptionController,

View File

@ -69,7 +69,7 @@ class _TaskViewState extends State<TaskView> {
final widgets = <Widget>[ final widgets = <Widget>[
TwoValueHeader( TwoValueHeader(
backgroundColor: backgroundColor:
task.isPaid ? Colors.green : task.isRunning ? Colors.blue : null, task.isInvoiced ? Colors.green : task.isRunning ? Colors.blue : null,
label1: localization.duration, label1: localization.duration,
value1: formatDuration(task.calculateDuration), value1: formatDuration(task.calculateDuration),
label2: localization.amount, label2: localization.amount,