Support viewing invoice from quote
This commit is contained in:
parent
d12d16767d
commit
0378e4e56b
|
|
@ -897,8 +897,12 @@ abstract class InvoiceEntity extends Object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isQuote && (invoiceId ?? '').isEmpty) {
|
if (isQuote) {
|
||||||
actions.add(EntityAction.convertToInvoice);
|
if ((invoiceId ?? '').isEmpty) {
|
||||||
|
actions.add(EntityAction.convertToInvoice);
|
||||||
|
} else {
|
||||||
|
actions.add(EntityAction.viewInvoice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ class EntityAction extends EnumClass {
|
||||||
static const EntityAction invoiceProject = _$invoiceProject;
|
static const EntityAction invoiceProject = _$invoiceProject;
|
||||||
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;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ const EntityAction _$invoiceExpense = const EntityAction._('invoiceExpense');
|
||||||
const EntityAction _$invoiceProject = const EntityAction._('invoiceProject');
|
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');
|
||||||
|
|
||||||
EntityAction _$valueOf(String name) {
|
EntityAction _$valueOf(String name) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
|
@ -193,6 +194,8 @@ EntityAction _$valueOf(String name) {
|
||||||
return _$resendInvite;
|
return _$resendInvite;
|
||||||
case 'disconnect':
|
case 'disconnect':
|
||||||
return _$disconnect;
|
return _$disconnect;
|
||||||
|
case 'viewInvoice':
|
||||||
|
return _$viewInvoice;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentError(name);
|
throw new ArgumentError(name);
|
||||||
}
|
}
|
||||||
|
|
@ -259,6 +262,7 @@ final BuiltSet<EntityAction> _$values =
|
||||||
_$invoiceProject,
|
_$invoiceProject,
|
||||||
_$resendInvite,
|
_$resendInvite,
|
||||||
_$disconnect,
|
_$disconnect,
|
||||||
|
_$viewInvoice,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Serializer<EntityAction> _$entityActionSerializer =
|
Serializer<EntityAction> _$entityActionSerializer =
|
||||||
|
|
|
||||||
|
|
@ -474,6 +474,9 @@ Future handleQuoteAction(
|
||||||
snackBarCompleter<Null>(context, localization.convertedQuote),
|
snackBarCompleter<Null>(context, localization.convertedQuote),
|
||||||
quoteIds));
|
quoteIds));
|
||||||
break;
|
break;
|
||||||
|
case EntityAction.viewInvoice:
|
||||||
|
viewEntityById(entityId: quote.invoiceId, entityType: EntityType.invoice);
|
||||||
|
break;
|
||||||
case EntityAction.markSent:
|
case EntityAction.markSent:
|
||||||
store.dispatch(MarkSentQuotesRequest(
|
store.dispatch(MarkSentQuotesRequest(
|
||||||
snackBarCompleter<Null>(context, localization.markedQuoteAsSent),
|
snackBarCompleter<Null>(context, localization.markedQuoteAsSent),
|
||||||
|
|
|
||||||
|
|
@ -305,6 +305,9 @@ Middleware<AppState> _saveQuote(QuoteRepository repository) {
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(SaveQuoteSuccess(quote));
|
store.dispatch(SaveQuoteSuccess(quote));
|
||||||
}
|
}
|
||||||
|
if (action.action == EntityAction.convertToInvoice) {
|
||||||
|
store.dispatch(RefreshData());
|
||||||
|
}
|
||||||
action.completer.complete(quote);
|
action.completer.complete(quote);
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
print(error);
|
print(error);
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ class QuoteEditVM extends AbstractInvoiceEditVM {
|
||||||
EntityAction.emailQuote,
|
EntityAction.emailQuote,
|
||||||
EntityAction.viewPdf,
|
EntityAction.viewPdf,
|
||||||
EntityAction.download,
|
EntityAction.download,
|
||||||
|
EntityAction.viewInvoice,
|
||||||
].contains(action)) {
|
].contains(action)) {
|
||||||
handleEntityAction(quote, action);
|
handleEntityAction(quote, action);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -132,6 +133,7 @@ class QuoteEditVM extends AbstractInvoiceEditVM {
|
||||||
EntityAction.emailQuote,
|
EntityAction.emailQuote,
|
||||||
EntityAction.viewPdf,
|
EntityAction.viewPdf,
|
||||||
EntityAction.download,
|
EntityAction.download,
|
||||||
|
EntityAction.viewInvoice,
|
||||||
].contains(action)) {
|
].contains(action)) {
|
||||||
handleEntityAction(savedQuote, action);
|
handleEntityAction(savedQuote, action);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,9 @@ class _QuoteEditState extends State<QuoteEdit>
|
||||||
EntityAction.download,
|
EntityAction.download,
|
||||||
EntityAction.emailQuote,
|
EntityAction.emailQuote,
|
||||||
if (!invoice.isSent) EntityAction.markSent,
|
if (!invoice.isSent) EntityAction.markSent,
|
||||||
if (!invoice.isApproved) EntityAction.convertToInvoice,
|
invoice.invoiceId.isEmpty
|
||||||
|
? EntityAction.convertToInvoice
|
||||||
|
: EntityAction.viewInvoice,
|
||||||
],
|
],
|
||||||
onActionPressed: (context, action) => _onSavePressed(context, action),
|
onActionPressed: (context, action) => _onSavePressed(context, action),
|
||||||
appBarBottom: TabBar(
|
appBarBottom: TabBar(
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,8 @@ IconData getEntityActionIcon(EntityAction entityAction) {
|
||||||
return MdiIcons.lanDisconnect;
|
return MdiIcons.lanDisconnect;
|
||||||
case EntityAction.purge:
|
case EntityAction.purge:
|
||||||
return Icons.delete_forever;
|
return Icons.delete_forever;
|
||||||
|
case EntityAction.viewInvoice:
|
||||||
|
return MdiIcons.fileAccount;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue