Purchase orders

This commit is contained in:
Hillel Coren 2022-07-07 08:47:22 +03:00
parent 50d045ed79
commit 8824370249
8 changed files with 85 additions and 60 deletions

View File

@ -134,7 +134,6 @@ abstract class ExpenseEntity extends Object
? client.settings.currencyId // TODO handle group currency ? client.settings.currencyId // TODO handle group currency
: (state?.company?.currencyId ?? kDefaultCurrencyId), : (state?.company?.currencyId ?? kDefaultCurrencyId),
documents: BuiltList<DocumentEntity>(), documents: BuiltList<DocumentEntity>(),
purchaseOrderId: '',
taxName1: '', taxName1: '',
taxName2: '', taxName2: '',
taxName3: '', taxName3: '',
@ -307,9 +306,6 @@ abstract class ExpenseEntity extends Object
@BuiltValueField(wireName: 'recurring_id') @BuiltValueField(wireName: 'recurring_id')
String get recurringId; String get recurringId;
@BuiltValueField(wireName: 'purchase_order_id')
String get purchaseOrderId;
@BuiltValueField(wireName: 'frequency_id') @BuiltValueField(wireName: 'frequency_id')
String get frequencyId; String get frequencyId;
@ -830,7 +826,6 @@ abstract class ExpenseEntity extends Object
// ignore: unused_element // ignore: unused_element
static void _initializeBuilder(ExpenseEntityBuilder builder) => builder static void _initializeBuilder(ExpenseEntityBuilder builder) => builder
..entityType = EntityType.expense ..entityType = EntityType.expense
..purchaseOrderId = ''
..frequencyId = '' ..frequencyId = ''
..lastSentDate = '' ..lastSentDate = ''
..nextSendDate = '' ..nextSendDate = ''

View File

@ -213,9 +213,6 @@ class _$ExpenseEntitySerializer implements StructuredSerializer<ExpenseEntity> {
'number', 'number',
serializers.serialize(object.number, serializers.serialize(object.number,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
'purchase_order_id',
serializers.serialize(object.purchaseOrderId,
specifiedType: const FullType(String)),
'frequency_id', 'frequency_id',
serializers.serialize(object.frequencyId, serializers.serialize(object.frequencyId,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
@ -515,10 +512,6 @@ class _$ExpenseEntitySerializer implements StructuredSerializer<ExpenseEntity> {
result.recurringId = serializers.deserialize(value, result.recurringId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'purchase_order_id':
result.purchaseOrderId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'frequency_id': case 'frequency_id':
result.frequencyId = serializers.deserialize(value, result.frequencyId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
@ -948,8 +941,6 @@ class _$ExpenseEntity extends ExpenseEntity {
@override @override
final String recurringId; final String recurringId;
@override @override
final String purchaseOrderId;
@override
final String frequencyId; final String frequencyId;
@override @override
final String lastSentDate; final String lastSentDate;
@ -1022,7 +1013,6 @@ class _$ExpenseEntity extends ExpenseEntity {
this.documents, this.documents,
this.number, this.number,
this.recurringId, this.recurringId,
this.purchaseOrderId,
this.frequencyId, this.frequencyId,
this.lastSentDate, this.lastSentDate,
this.nextSendDate, this.nextSendDate,
@ -1096,8 +1086,6 @@ class _$ExpenseEntity extends ExpenseEntity {
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
documents, 'ExpenseEntity', 'documents'); documents, 'ExpenseEntity', 'documents');
BuiltValueNullFieldError.checkNotNull(number, 'ExpenseEntity', 'number'); BuiltValueNullFieldError.checkNotNull(number, 'ExpenseEntity', 'number');
BuiltValueNullFieldError.checkNotNull(
purchaseOrderId, 'ExpenseEntity', 'purchaseOrderId');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
frequencyId, 'ExpenseEntity', 'frequencyId'); frequencyId, 'ExpenseEntity', 'frequencyId');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -1164,7 +1152,6 @@ class _$ExpenseEntity extends ExpenseEntity {
documents == other.documents && documents == other.documents &&
number == other.number && number == other.number &&
recurringId == other.recurringId && recurringId == other.recurringId &&
purchaseOrderId == other.purchaseOrderId &&
frequencyId == other.frequencyId && frequencyId == other.frequencyId &&
lastSentDate == other.lastSentDate && lastSentDate == other.lastSentDate &&
nextSendDate == other.nextSendDate && nextSendDate == other.nextSendDate &&
@ -1202,12 +1189,12 @@ class _$ExpenseEntity extends ExpenseEntity {
$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, privateNotes.hashCode), publicNotes.hashCode), shouldBeInvoiced.hashCode), invoiceDocuments.hashCode), transactionId.hashCode), transactionReference.hashCode), bankId.hashCode), currencyId.hashCode), categoryId.hashCode), amount.hashCode), date.hashCode), paymentDate.hashCode), exchangeRate.hashCode), invoiceCurrencyId.hashCode), paymentTypeId.hashCode), taxName1.hashCode), taxName2.hashCode), taxRate1.hashCode), taxRate2.hashCode), taxName3.hashCode), taxRate3.hashCode), clientId.hashCode), invoiceId.hashCode), vendorId.hashCode), projectId.hashCode), statusId.hashCode), customValue1.hashCode), customValue2.hashCode), customValue3.hashCode), customValue4.hashCode), taxAmount1.hashCode), taxAmount2.hashCode), taxAmount3.hashCode), usesInclusiveTaxes.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(0, privateNotes.hashCode), publicNotes.hashCode), shouldBeInvoiced.hashCode), invoiceDocuments.hashCode), transactionId.hashCode), transactionReference.hashCode), bankId.hashCode), currencyId.hashCode), categoryId.hashCode), amount.hashCode), date.hashCode), paymentDate.hashCode), exchangeRate.hashCode), invoiceCurrencyId.hashCode), paymentTypeId.hashCode), taxName1.hashCode), taxName2.hashCode), taxRate1.hashCode), taxRate2.hashCode), taxName3.hashCode), taxRate3.hashCode), clientId.hashCode), invoiceId.hashCode), vendorId.hashCode), projectId.hashCode), statusId.hashCode), customValue1.hashCode), customValue2.hashCode), customValue3.hashCode), customValue4.hashCode), taxAmount1.hashCode), taxAmount2.hashCode), taxAmount3.hashCode),
calculateTaxByAmount.hashCode), usesInclusiveTaxes.hashCode),
documents.hashCode), calculateTaxByAmount.hashCode),
number.hashCode), documents.hashCode),
recurringId.hashCode), number.hashCode),
purchaseOrderId.hashCode), recurringId.hashCode),
frequencyId.hashCode), frequencyId.hashCode),
lastSentDate.hashCode), lastSentDate.hashCode),
nextSendDate.hashCode), nextSendDate.hashCode),
@ -1265,7 +1252,6 @@ class _$ExpenseEntity extends ExpenseEntity {
..add('documents', documents) ..add('documents', documents)
..add('number', number) ..add('number', number)
..add('recurringId', recurringId) ..add('recurringId', recurringId)
..add('purchaseOrderId', purchaseOrderId)
..add('frequencyId', frequencyId) ..add('frequencyId', frequencyId)
..add('lastSentDate', lastSentDate) ..add('lastSentDate', lastSentDate)
..add('nextSendDate', nextSendDate) ..add('nextSendDate', nextSendDate)
@ -1451,11 +1437,6 @@ class ExpenseEntityBuilder
String get recurringId => _$this._recurringId; String get recurringId => _$this._recurringId;
set recurringId(String recurringId) => _$this._recurringId = recurringId; set recurringId(String recurringId) => _$this._recurringId = recurringId;
String _purchaseOrderId;
String get purchaseOrderId => _$this._purchaseOrderId;
set purchaseOrderId(String purchaseOrderId) =>
_$this._purchaseOrderId = purchaseOrderId;
String _frequencyId; String _frequencyId;
String get frequencyId => _$this._frequencyId; String get frequencyId => _$this._frequencyId;
set frequencyId(String frequencyId) => _$this._frequencyId = frequencyId; set frequencyId(String frequencyId) => _$this._frequencyId = frequencyId;
@ -1566,7 +1547,6 @@ class ExpenseEntityBuilder
_documents = $v.documents.toBuilder(); _documents = $v.documents.toBuilder();
_number = $v.number; _number = $v.number;
_recurringId = $v.recurringId; _recurringId = $v.recurringId;
_purchaseOrderId = $v.purchaseOrderId;
_frequencyId = $v.frequencyId; _frequencyId = $v.frequencyId;
_lastSentDate = $v.lastSentDate; _lastSentDate = $v.lastSentDate;
_nextSendDate = $v.nextSendDate; _nextSendDate = $v.nextSendDate;
@ -1649,7 +1629,6 @@ class ExpenseEntityBuilder
documents: documents.build(), documents: documents.build(),
number: BuiltValueNullFieldError.checkNotNull(number, 'ExpenseEntity', 'number'), number: BuiltValueNullFieldError.checkNotNull(number, 'ExpenseEntity', 'number'),
recurringId: recurringId, recurringId: recurringId,
purchaseOrderId: BuiltValueNullFieldError.checkNotNull(purchaseOrderId, 'ExpenseEntity', 'purchaseOrderId'),
frequencyId: BuiltValueNullFieldError.checkNotNull(frequencyId, 'ExpenseEntity', 'frequencyId'), frequencyId: BuiltValueNullFieldError.checkNotNull(frequencyId, 'ExpenseEntity', 'frequencyId'),
lastSentDate: BuiltValueNullFieldError.checkNotNull(lastSentDate, 'ExpenseEntity', 'lastSentDate'), lastSentDate: BuiltValueNullFieldError.checkNotNull(lastSentDate, 'ExpenseEntity', 'lastSentDate'),
nextSendDate: BuiltValueNullFieldError.checkNotNull(nextSendDate, 'ExpenseEntity', 'nextSendDate'), nextSendDate: BuiltValueNullFieldError.checkNotNull(nextSendDate, 'ExpenseEntity', 'nextSendDate'),

View File

@ -163,6 +163,7 @@ abstract class InvoiceEntity extends Object
taxAmount: 0, taxAmount: 0,
poNumber: '', poNumber: '',
projectId: '', projectId: '',
expenseId: '',
vendorId: vendor?.id ?? '', vendorId: vendor?.id ?? '',
date: convertDateTimeToSqlDate(), date: convertDateTimeToSqlDate(),
dueDate: '', dueDate: '',
@ -294,6 +295,7 @@ abstract class InvoiceEntity extends Object
..remainingCycles = -1 ..remainingCycles = -1
..invoiceId = '' ..invoiceId = ''
..projectId = '' ..projectId = ''
..expenseId = ''
..subscriptionId = '' ..subscriptionId = ''
..number = '' ..number = ''
..date = convertDateTimeToSqlDate() ..date = convertDateTimeToSqlDate()
@ -403,6 +405,9 @@ abstract class InvoiceEntity extends Object
@BuiltValueField(wireName: 'project_id') @BuiltValueField(wireName: 'project_id')
String get projectId; String get projectId;
@BuiltValueField(wireName: 'expense_id')
String get expenseId;
@override @override
@BuiltValueField(wireName: 'vendor_id') @BuiltValueField(wireName: 'vendor_id')
String get vendorId; String get vendorId;
@ -1008,8 +1013,12 @@ abstract class InvoiceEntity extends Object
} }
if (isPurchaseOrder) { if (isPurchaseOrder) {
if (userCompany.canCreate(EntityType.expense)) { if (expenseId.isEmpty) {
actions.add(EntityAction.convertToExpense); if (userCompany.canCreate(EntityType.expense)) {
actions.add(EntityAction.convertToExpense);
}
} else {
actions.add(EntityAction.viewExpense);
} }
if (statusId == kPurchaseOrderStatusAccepted) { if (statusId == kPurchaseOrderStatusAccepted) {
actions.add(EntityAction.addToInventory); actions.add(EntityAction.addToInventory);
@ -1417,6 +1426,7 @@ abstract class InvoiceEntity extends Object
..activities.replace(BuiltList<ActivityEntity>()) ..activities.replace(BuiltList<ActivityEntity>())
..paidToDate = 0 ..paidToDate = 0
..projectId = '' ..projectId = ''
..expenseId = ''
..vendorId = '' ..vendorId = ''
..autoBillEnabled = false ..autoBillEnabled = false
..subscriptionId = ''; ..subscriptionId = '';

View File

@ -141,6 +141,9 @@ class _$InvoiceEntitySerializer implements StructuredSerializer<InvoiceEntity> {
'project_id', 'project_id',
serializers.serialize(object.projectId, serializers.serialize(object.projectId,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
'expense_id',
serializers.serialize(object.expenseId,
specifiedType: const FullType(String)),
'vendor_id', 'vendor_id',
serializers.serialize(object.vendorId, serializers.serialize(object.vendorId,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
@ -449,6 +452,10 @@ class _$InvoiceEntitySerializer implements StructuredSerializer<InvoiceEntity> {
result.projectId = serializers.deserialize(value, result.projectId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'expense_id':
result.expenseId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'vendor_id': case 'vendor_id':
result.vendorId = serializers.deserialize(value, result.vendorId = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
@ -1410,6 +1417,8 @@ class _$InvoiceEntity extends InvoiceEntity {
@override @override
final String projectId; final String projectId;
@override @override
final String expenseId;
@override
final String vendorId; final String vendorId;
@override @override
final String subscriptionId; final String subscriptionId;
@ -1551,6 +1560,7 @@ class _$InvoiceEntity extends InvoiceEntity {
this.paidToDate, this.paidToDate,
this.clientId, this.clientId,
this.projectId, this.projectId,
this.expenseId,
this.vendorId, this.vendorId,
this.subscriptionId, this.subscriptionId,
this.statusId, this.statusId,
@ -1626,6 +1636,8 @@ class _$InvoiceEntity extends InvoiceEntity {
clientId, 'InvoiceEntity', 'clientId'); clientId, 'InvoiceEntity', 'clientId');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
projectId, 'InvoiceEntity', 'projectId'); projectId, 'InvoiceEntity', 'projectId');
BuiltValueNullFieldError.checkNotNull(
expenseId, 'InvoiceEntity', 'expenseId');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
vendorId, 'InvoiceEntity', 'vendorId'); vendorId, 'InvoiceEntity', 'vendorId');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -1733,6 +1745,7 @@ class _$InvoiceEntity extends InvoiceEntity {
paidToDate == other.paidToDate && paidToDate == other.paidToDate &&
clientId == other.clientId && clientId == other.clientId &&
projectId == other.projectId && projectId == other.projectId &&
expenseId == other.expenseId &&
vendorId == other.vendorId && vendorId == other.vendorId &&
subscriptionId == other.subscriptionId && subscriptionId == other.subscriptionId &&
statusId == other.statusId && statusId == other.statusId &&
@ -1820,7 +1833,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($jc($jc($jc($jc($jc(0, amount.hashCode), balance.hashCode), paidToDate.hashCode), clientId.hashCode), projectId.hashCode), vendorId.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($jc($jc(0, amount.hashCode), balance.hashCode), paidToDate.hashCode), clientId.hashCode), projectId.hashCode), expenseId.hashCode), vendorId.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), remainingCycles.hashCode),
dueDateDays.hashCode), dueDateDays.hashCode),
invoiceId.hashCode), invoiceId.hashCode),
@ -1850,6 +1863,7 @@ class _$InvoiceEntity extends InvoiceEntity {
..add('paidToDate', paidToDate) ..add('paidToDate', paidToDate)
..add('clientId', clientId) ..add('clientId', clientId)
..add('projectId', projectId) ..add('projectId', projectId)
..add('expenseId', expenseId)
..add('vendorId', vendorId) ..add('vendorId', vendorId)
..add('subscriptionId', subscriptionId) ..add('subscriptionId', subscriptionId)
..add('statusId', statusId) ..add('statusId', statusId)
@ -1944,6 +1958,10 @@ class InvoiceEntityBuilder
String get projectId => _$this._projectId; String get projectId => _$this._projectId;
set projectId(String projectId) => _$this._projectId = projectId; set projectId(String projectId) => _$this._projectId = projectId;
String _expenseId;
String get expenseId => _$this._expenseId;
set expenseId(String expenseId) => _$this._expenseId = expenseId;
String _vendorId; String _vendorId;
String get vendorId => _$this._vendorId; String get vendorId => _$this._vendorId;
set vendorId(String vendorId) => _$this._vendorId = vendorId; set vendorId(String vendorId) => _$this._vendorId = vendorId;
@ -2246,6 +2264,7 @@ class InvoiceEntityBuilder
_paidToDate = $v.paidToDate; _paidToDate = $v.paidToDate;
_clientId = $v.clientId; _clientId = $v.clientId;
_projectId = $v.projectId; _projectId = $v.projectId;
_expenseId = $v.expenseId;
_vendorId = $v.vendorId; _vendorId = $v.vendorId;
_subscriptionId = $v.subscriptionId; _subscriptionId = $v.subscriptionId;
_statusId = $v.statusId; _statusId = $v.statusId;
@ -2344,14 +2363,15 @@ class InvoiceEntityBuilder
clientId, 'InvoiceEntity', 'clientId'), clientId, 'InvoiceEntity', 'clientId'),
projectId: BuiltValueNullFieldError.checkNotNull( projectId: BuiltValueNullFieldError.checkNotNull(
projectId, 'InvoiceEntity', 'projectId'), projectId, 'InvoiceEntity', 'projectId'),
expenseId: BuiltValueNullFieldError.checkNotNull(
expenseId, 'InvoiceEntity', 'expenseId'),
vendorId: BuiltValueNullFieldError.checkNotNull( vendorId: BuiltValueNullFieldError.checkNotNull(
vendorId, 'InvoiceEntity', 'vendorId'), vendorId, 'InvoiceEntity', 'vendorId'),
subscriptionId: BuiltValueNullFieldError.checkNotNull( subscriptionId: BuiltValueNullFieldError.checkNotNull(
subscriptionId, 'InvoiceEntity', 'subscriptionId'), subscriptionId, 'InvoiceEntity', 'subscriptionId'),
statusId: BuiltValueNullFieldError.checkNotNull( statusId:
statusId, 'InvoiceEntity', 'statusId'), BuiltValueNullFieldError.checkNotNull(statusId, 'InvoiceEntity', 'statusId'),
number: number: BuiltValueNullFieldError.checkNotNull(number, 'InvoiceEntity', 'number'),
BuiltValueNullFieldError.checkNotNull(number, 'InvoiceEntity', 'number'),
discount: BuiltValueNullFieldError.checkNotNull(discount, 'InvoiceEntity', 'discount'), discount: BuiltValueNullFieldError.checkNotNull(discount, 'InvoiceEntity', 'discount'),
poNumber: BuiltValueNullFieldError.checkNotNull(poNumber, 'InvoiceEntity', 'poNumber'), poNumber: BuiltValueNullFieldError.checkNotNull(poNumber, 'InvoiceEntity', 'poNumber'),
date: BuiltValueNullFieldError.checkNotNull(date, 'InvoiceEntity', 'date'), date: BuiltValueNullFieldError.checkNotNull(date, 'InvoiceEntity', 'date'),

View File

@ -105,6 +105,7 @@ class EntityAction extends EnumClass {
static const EntityAction resendInvite = _$resendInvite; static const EntityAction resendInvite = _$resendInvite;
static const EntityAction disconnect = _$disconnect; static const EntityAction disconnect = _$disconnect;
static const EntityAction viewInvoice = _$viewInvoice; static const EntityAction viewInvoice = _$viewInvoice;
static const EntityAction viewExpense = _$viewExpense;
static const EntityAction changeStatus = _$changeStatus; static const EntityAction changeStatus = _$changeStatus;
static const EntityAction addToInvoice = _$addToInvoice; static const EntityAction addToInvoice = _$addToInvoice;
static const EntityAction cancel = _$cancel; static const EntityAction cancel = _$cancel;

View File

@ -72,6 +72,7 @@ const EntityAction _$invoiceProject = const EntityAction._('invoiceProject');
const EntityAction _$resendInvite = const EntityAction._('resendInvite'); const EntityAction _$resendInvite = const EntityAction._('resendInvite');
const EntityAction _$disconnect = const EntityAction._('disconnect'); const EntityAction _$disconnect = const EntityAction._('disconnect');
const EntityAction _$viewInvoice = const EntityAction._('viewInvoice'); const EntityAction _$viewInvoice = const EntityAction._('viewInvoice');
const EntityAction _$viewExpense = const EntityAction._('viewExpense');
const EntityAction _$changeStatus = const EntityAction._('changeStatus'); const EntityAction _$changeStatus = const EntityAction._('changeStatus');
const EntityAction _$addToInvoice = const EntityAction._('addToInvoice'); const EntityAction _$addToInvoice = const EntityAction._('addToInvoice');
const EntityAction _$cancel = const EntityAction._('cancel'); const EntityAction _$cancel = const EntityAction._('cancel');
@ -199,6 +200,8 @@ EntityAction _$valueOf(String name) {
return _$disconnect; return _$disconnect;
case 'viewInvoice': case 'viewInvoice':
return _$viewInvoice; return _$viewInvoice;
case 'viewExpense':
return _$viewExpense;
case 'changeStatus': case 'changeStatus':
return _$changeStatus; return _$changeStatus;
case 'addToInvoice': case 'addToInvoice':
@ -278,6 +281,7 @@ final BuiltSet<EntityAction> _$values =
_$resendInvite, _$resendInvite,
_$disconnect, _$disconnect,
_$viewInvoice, _$viewInvoice,
_$viewExpense,
_$changeStatus, _$changeStatus,
_$addToInvoice, _$addToInvoice,
_$cancel, _$cancel,

View File

@ -377,6 +377,26 @@ class MarkPurchaseOrderSentFailure implements StopSaving {
final Object error; final Object error;
} }
class ConvertPurchaseOrdersToExpensesRequest implements StartSaving {
ConvertPurchaseOrdersToExpensesRequest(this.completer, this.purchaseOrderIds);
final Completer completer;
final List<String> purchaseOrderIds;
}
class ConvertPurchaseOrdersToExpensesSuccess
implements StopSaving, PersistData {
ConvertPurchaseOrdersToExpensesSuccess(this.purchaseOrders);
final List<InvoiceEntity> purchaseOrders;
}
class ConvertPurchaseOrdersToExpensesFailure implements StopSaving {
ConvertPurchaseOrdersToExpensesFailure(this.error);
final Object error;
}
class AddPurchaseOrdersToInventoryRequest implements StartSaving { class AddPurchaseOrdersToInventoryRequest implements StartSaving {
AddPurchaseOrdersToInventoryRequest(this.completer, this.purchaseOrderIds); AddPurchaseOrdersToInventoryRequest(this.completer, this.purchaseOrderIds);
@ -589,27 +609,13 @@ void handlePurchaseOrderAction(BuildContext context,
purchaseOrderIds)); purchaseOrderIds));
break; break;
case EntityAction.convertToExpense: case EntityAction.convertToExpense:
final vendor = state.vendorState.get(purchaseOrder.vendorId); store.dispatch(ConvertPurchaseOrdersToExpensesRequest(
final client = state.clientState.get(purchaseOrder.clientId); snackBarCompleter<Null>(
final project = state.projectState.get(purchaseOrder.projectId); context,
editEntity( purchaseOrders.length == 1
entity: ExpenseEntity( ? localization.convertedToExpense
state: state, : localization.convertedToExpenses),
vendor: vendor, purchaseOrderIds));
client: client,
project: project,
).rebuild((b) => b
..purchaseOrderId = purchaseOrder.id
..amount = purchaseOrder.usesInclusiveTaxes
? purchaseOrder.amount
: purchaseOrder.netAmount
..taxRate1 = purchaseOrder.taxRate1
..taxName1 = purchaseOrder.taxName1
..taxRate2 = purchaseOrder.taxRate2
..taxName2 = purchaseOrder.taxName2
..taxRate3 = purchaseOrder.taxRate3
..taxName3 = purchaseOrder.taxName3
..usesInclusiveTaxes = purchaseOrder.usesInclusiveTaxes));
break; break;
case EntityAction.markSent: case EntityAction.markSent:
store.dispatch(MarkPurchaseOrdersSentRequest( store.dispatch(MarkPurchaseOrdersSentRequest(

View File

@ -16,6 +16,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
'converted_to_expense': 'Successfully converted to expense',
'converted_to_expenses': 'Successfully converted to expenses',
'convert_to_expense': 'Convert to Expense', 'convert_to_expense': 'Convert to Expense',
'add_to_inventory': 'Add to Inventory', 'add_to_inventory': 'Add to Inventory',
'added_purchase_order_to_inventory': 'added_purchase_order_to_inventory':
@ -70933,6 +70935,14 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['convert_to_expense'] ?? _localizedValues[localeCode]['convert_to_expense'] ??
_localizedValues['en']['convert_to_expense']; _localizedValues['en']['convert_to_expense'];
String get convertedToExpense =>
_localizedValues[localeCode]['converted_to_expense'] ??
_localizedValues['en']['converted_to_expense'];
String get convertedToExpenses =>
_localizedValues[localeCode]['converted_to_expenses'] ??
_localizedValues['en']['converted_to_expenses'];
// STARTER: lang field - do not remove comment // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {