Add project_id to invoices

This commit is contained in:
Hillel Coren 2021-11-08 17:40:35 +02:00
parent 72fc611089
commit 010c2cefd3
4 changed files with 44 additions and 6 deletions

View File

@ -143,6 +143,7 @@ abstract class InvoiceEntity extends Object
discount: 0,
taxAmount: 0,
poNumber: '',
projectId: '',
date: convertDateTimeToSqlDate(),
dueDate: '',
publicNotes: '',
@ -249,6 +250,7 @@ abstract class InvoiceEntity extends Object
..paidToDate = 0
..remainingCycles = -1
..invoiceId = ''
..projectId = ''
..subscriptionId = ''
..number = ''
..date = convertDateTimeToSqlDate()
@ -311,6 +313,9 @@ abstract class InvoiceEntity extends Object
@BuiltValueField(wireName: 'client_id')
String get clientId;
@BuiltValueField(wireName: 'project_id')
String get projectId;
@BuiltValueField(wireName: 'subscription_id')
String get subscriptionId;
@ -1203,6 +1208,7 @@ abstract class InvoiceEntity extends Object
static void _initializeBuilder(InvoiceEntityBuilder builder) => builder
..activities.replace(BuiltList<ActivityEntity>())
..paidToDate = 0
..projectId = ''
..autoBillEnabled = false
..subscriptionId = '';

View File

@ -138,6 +138,9 @@ class _$InvoiceEntitySerializer implements StructuredSerializer<InvoiceEntity> {
'client_id',
serializers.serialize(object.clientId,
specifiedType: const FullType(String)),
'project_id',
serializers.serialize(object.projectId,
specifiedType: const FullType(String)),
'subscription_id',
serializers.serialize(object.subscriptionId,
specifiedType: const FullType(String)),
@ -439,6 +442,10 @@ class _$InvoiceEntitySerializer implements StructuredSerializer<InvoiceEntity> {
result.clientId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'project_id':
result.projectId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'subscription_id':
result.subscriptionId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
@ -1387,6 +1394,8 @@ class _$InvoiceEntity extends InvoiceEntity {
@override
final String clientId;
@override
final String projectId;
@override
final String subscriptionId;
@override
final String statusId;
@ -1525,6 +1534,7 @@ class _$InvoiceEntity extends InvoiceEntity {
this.balance,
this.paidToDate,
this.clientId,
this.projectId,
this.subscriptionId,
this.statusId,
this.number,
@ -1597,6 +1607,8 @@ class _$InvoiceEntity extends InvoiceEntity {
paidToDate, 'InvoiceEntity', 'paidToDate');
BuiltValueNullFieldError.checkNotNull(
clientId, 'InvoiceEntity', 'clientId');
BuiltValueNullFieldError.checkNotNull(
projectId, 'InvoiceEntity', 'projectId');
BuiltValueNullFieldError.checkNotNull(
subscriptionId, 'InvoiceEntity', 'subscriptionId');
BuiltValueNullFieldError.checkNotNull(
@ -1701,6 +1713,7 @@ class _$InvoiceEntity extends InvoiceEntity {
balance == other.balance &&
paidToDate == other.paidToDate &&
clientId == other.clientId &&
projectId == other.projectId &&
subscriptionId == other.subscriptionId &&
statusId == other.statusId &&
number == other.number &&
@ -1787,7 +1800,7 @@ class _$InvoiceEntity extends InvoiceEntity {
$jc(
$jc(
$jc(
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, amount.hashCode), balance.hashCode), paidToDate.hashCode), clientId.hashCode), subscriptionId.hashCode), statusId.hashCode), number.hashCode), discount.hashCode), poNumber.hashCode), date.hashCode), dueDate.hashCode), publicNotes.hashCode), privateNotes.hashCode), terms.hashCode), footer.hashCode), designId.hashCode), usesInclusiveTaxes.hashCode), taxName1.hashCode), taxRate1.hashCode), taxName2.hashCode), taxRate2.hashCode), taxName3.hashCode), taxRate3.hashCode), isAmountDiscount.hashCode), partial.hashCode), taxAmount.hashCode), partialDueDate.hashCode), autoBill.hashCode), customValue1.hashCode), customValue2.hashCode), customValue3.hashCode), customValue4.hashCode), customSurcharge1.hashCode), customSurcharge2.hashCode), customSurcharge3.hashCode), customSurcharge4.hashCode), customTaxes1.hashCode), customTaxes2.hashCode), customTaxes3.hashCode), customTaxes4.hashCode), exchangeRate.hashCode), reminder1Sent.hashCode), reminder2Sent.hashCode), reminder3Sent.hashCode), reminderLastSent.hashCode), frequencyId.hashCode), lastSentDate.hashCode), nextSendDate.hashCode),
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, amount.hashCode), balance.hashCode), paidToDate.hashCode), clientId.hashCode), projectId.hashCode), subscriptionId.hashCode), statusId.hashCode), number.hashCode), discount.hashCode), poNumber.hashCode), date.hashCode), dueDate.hashCode), publicNotes.hashCode), privateNotes.hashCode), terms.hashCode), footer.hashCode), designId.hashCode), usesInclusiveTaxes.hashCode), taxName1.hashCode), taxRate1.hashCode), taxName2.hashCode), taxRate2.hashCode), taxName3.hashCode), taxRate3.hashCode), isAmountDiscount.hashCode), partial.hashCode), taxAmount.hashCode), partialDueDate.hashCode), autoBill.hashCode), customValue1.hashCode), customValue2.hashCode), customValue3.hashCode), customValue4.hashCode), customSurcharge1.hashCode), customSurcharge2.hashCode), customSurcharge3.hashCode), customSurcharge4.hashCode), customTaxes1.hashCode), customTaxes2.hashCode), customTaxes3.hashCode), customTaxes4.hashCode), exchangeRate.hashCode), reminder1Sent.hashCode), reminder2Sent.hashCode), reminder3Sent.hashCode), reminderLastSent.hashCode), frequencyId.hashCode), lastSentDate.hashCode), nextSendDate.hashCode),
remainingCycles.hashCode),
dueDateDays.hashCode),
invoiceId.hashCode),
@ -1816,6 +1829,7 @@ class _$InvoiceEntity extends InvoiceEntity {
..add('balance', balance)
..add('paidToDate', paidToDate)
..add('clientId', clientId)
..add('projectId', projectId)
..add('subscriptionId', subscriptionId)
..add('statusId', statusId)
..add('number', number)
@ -1905,6 +1919,10 @@ class InvoiceEntityBuilder
String get clientId => _$this._clientId;
set clientId(String clientId) => _$this._clientId = clientId;
String _projectId;
String get projectId => _$this._projectId;
set projectId(String projectId) => _$this._projectId = projectId;
String _subscriptionId;
String get subscriptionId => _$this._subscriptionId;
set subscriptionId(String subscriptionId) =>
@ -2202,6 +2220,7 @@ class InvoiceEntityBuilder
_balance = $v.balance;
_paidToDate = $v.paidToDate;
_clientId = $v.clientId;
_projectId = $v.projectId;
_subscriptionId = $v.subscriptionId;
_statusId = $v.statusId;
_number = $v.number;
@ -2297,14 +2316,15 @@ class InvoiceEntityBuilder
paidToDate, 'InvoiceEntity', 'paidToDate'),
clientId: BuiltValueNullFieldError.checkNotNull(
clientId, 'InvoiceEntity', 'clientId'),
projectId: BuiltValueNullFieldError.checkNotNull(
projectId, 'InvoiceEntity', 'projectId'),
subscriptionId: BuiltValueNullFieldError.checkNotNull(
subscriptionId, 'InvoiceEntity', 'subscriptionId'),
statusId: BuiltValueNullFieldError.checkNotNull(
statusId, 'InvoiceEntity', 'statusId'),
number: BuiltValueNullFieldError.checkNotNull(
number, 'InvoiceEntity', 'number'),
discount: BuiltValueNullFieldError.checkNotNull(
discount, 'InvoiceEntity', 'discount'),
discount: BuiltValueNullFieldError.checkNotNull(discount, 'InvoiceEntity', 'discount'),
poNumber: BuiltValueNullFieldError.checkNotNull(poNumber, 'InvoiceEntity', 'poNumber'),
date: BuiltValueNullFieldError.checkNotNull(date, 'InvoiceEntity', 'date'),
dueDate: BuiltValueNullFieldError.checkNotNull(dueDate, 'InvoiceEntity', 'dueDate'),

View File

@ -273,7 +273,9 @@ void handleProjectAction(
createEntity(
context: context,
entity: InvoiceEntity(state: state, client: client)
.rebuild((b) => b..lineItems.addAll(items)));
.rebuild((b) => b..lineItems.addAll(items)
//..projectId = project.id
));
break;
case EntityAction.newExpense:
createEntity(

View File

@ -360,11 +360,21 @@ void handleTaskAction(
.map((task) => convertTaskToInvoiceItem(task: task, context: context))
.toList();
String projectId = '';
for (var each in tasks) {
final task = each as TaskEntity;
if (task.projectId.isNotEmpty) {
//projectId = task.projectId;
break;
}
}
if (items.isNotEmpty) {
createEntity(
context: context,
entity: InvoiceEntity(state: state, client: client)
.rebuild((b) => b..lineItems.addAll(items)));
entity: InvoiceEntity(state: state, client: client).rebuild((b) => b
..lineItems.addAll(items)
..projectId = projectId));
}
break;
case EntityAction.clone: