Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Aug 29, 2022
2 parents b3177a6 + dae17d3 commit b2b40fe
Show file tree
Hide file tree
Showing 18 changed files with 189 additions and 48 deletions.
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,15 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CURRENT_PROJECT_VERSION = 91;
CURRENT_PROJECT_VERSION = 92;
DEVELOPMENT_TEAM = NPC44Y2C98;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.91;
MARKETING_VERSION = 5.0.92;
PRODUCT_BUNDLE_IDENTIFIER = com.invoiceninja.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -508,15 +508,15 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CURRENT_PROJECT_VERSION = 91;
CURRENT_PROJECT_VERSION = 92;
DEVELOPMENT_TEAM = NPC44Y2C98;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.91;
MARKETING_VERSION = 5.0.92;
PRODUCT_BUNDLE_IDENTIFIER = com.invoiceninja.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -534,15 +534,15 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CURRENT_PROJECT_VERSION = 91;
CURRENT_PROJECT_VERSION = 92;
DEVELOPMENT_TEAM = NPC44Y2C98;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.91;
MARKETING_VERSION = 5.0.92;
PRODUCT_BUNDLE_IDENTIFIER = com.invoiceninja.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Constants {
}

// TODO remove version once #46609 is fixed
const String kClientVersion = '5.0.91';
const String kClientVersion = '5.0.92';
const String kMinServerVersion = '5.0.4';

const String kAppName = 'Invoice Ninja';
Expand Down
7 changes: 7 additions & 0 deletions lib/data/models/entities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ abstract class ActivityEntity
@BuiltValueField(wireName: 'recurring_expense_id')
String get recurringExpenseId;

@nullable
@BuiltValueField(wireName: 'purchase_order_id')
String get purchaseOrderId;

@nullable
@BuiltValueField(wireName: 'quote_id')
String get quoteId;
Expand Down Expand Up @@ -845,6 +849,7 @@ abstract class ActivityEntity
VendorEntity vendor,
InvoiceEntity recurringInvoice,
ExpenseEntity recurringExpense,
InvoiceEntity purchaseOrder,
}) {
ClientContactEntity contact;
if (client != null && contactId != null && contactId.isNotEmpty) {
Expand All @@ -868,6 +873,8 @@ abstract class ActivityEntity
activity = activity.replaceFirst(':task', task?.number ?? '');
activity = activity.replaceFirst(':expense', expense?.number ?? '');
activity = activity.replaceFirst(':vendor', vendor?.name ?? '');
activity =
activity.replaceFirst(':purchase_order', purchaseOrder?.number ?? '');
activity = activity.replaceFirst(
':recurring_expense', vendor?.name ?? ''); // TODO implement
activity = activity.replaceAll(' ', ' ');
Expand Down
37 changes: 30 additions & 7 deletions lib/data/models/entities.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/data/models/invoice_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,10 @@ abstract class InvoiceEntity extends Object
}

if (isQuote) {
if ((projectId ?? '').isEmpty) {
actions.add(EntityAction.convertToProject);
}

if ((invoiceId ?? '').isEmpty) {
if (!isApproved) {
actions.add(EntityAction.approve);
Expand Down
1 change: 1 addition & 0 deletions lib/data/models/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class EntityAction extends EnumClass {
static const EntityAction cloneToRecurring = _$cloneToRecurring;
static const EntityAction cloneToPurchaseOrder = _$cloneToPurchaseOrder;
static const EntityAction convertToInvoice = _$convertToInvoice;
static const EntityAction convertToProject = _$convertToProject;
static const EntityAction approve = _$approve;
static const EntityAction applyCredit = _$applyCredit;
static const EntityAction applyPayment = _$applyPayment;
Expand Down
5 changes: 5 additions & 0 deletions lib/data/models/models.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 31 additions & 7 deletions lib/redux/quote/quote_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -415,21 +415,40 @@ class FilterQuotesByCustom4 implements PersistUI {
final String value;
}

class ConvertQuotes implements StartSaving {
ConvertQuotes(this.completer, this.quoteIds);
class ConvertQuotesToInvoices implements StartSaving {
ConvertQuotesToInvoices(this.completer, this.quoteIds);

final List<String> quoteIds;
final Completer completer;
}

class ConvertQuoteSuccess implements StopSaving {
ConvertQuoteSuccess({this.quotes});
class ConvertQuotesToInvoicesSuccess implements StopSaving {
ConvertQuotesToInvoicesSuccess({this.quotes});

final List<InvoiceEntity> quotes;
}

class ConvertQuoteFailure implements StopSaving {
ConvertQuoteFailure(this.error);
class ConvertQuotesToInvoicesFailure implements StopSaving {
ConvertQuotesToInvoicesFailure(this.error);

final dynamic error;
}

class ConvertQuotesToProjects implements StartSaving {
ConvertQuotesToProjects(this.completer, this.quoteIds);

final List<String> quoteIds;
final Completer completer;
}

class ConvertQuotesToProjectsSuccess implements StopSaving {
ConvertQuotesToProjectsSuccess({this.quotes});

final List<InvoiceEntity> quotes;
}

class ConvertQuotesToProjectsFailure implements StopSaving {
ConvertQuotesToProjectsFailure(this.error);

final dynamic error;
}
Expand Down Expand Up @@ -496,7 +515,12 @@ Future handleQuoteAction(
launchUrl(Uri.parse(quote.invitationSilentLink));
break;
case EntityAction.convertToInvoice:
store.dispatch(ConvertQuotes(
store.dispatch(ConvertQuotesToInvoices(
snackBarCompleter<Null>(context, localization.convertedQuote),
quoteIds));
break;
case EntityAction.convertToProject:
store.dispatch(ConvertQuotesToProjects(
snackBarCompleter<Null>(context, localization.convertedQuote),
quoteIds));
break;
Expand Down
34 changes: 28 additions & 6 deletions lib/redux/quote/quote_middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ List<Middleware<AppState>> createStoreQuotesMiddleware([
final editQuote = _editQuote();
final showEmailQuote = _showEmailQuote();
final showPdfQuote = _showPdfQuote();
final convertQuote = _convertQuote(repository);
final convertQuotesToInvoices = _convertQuotesToInvoices(repository);
final convertQuotesToProjects = _convertQuotesToProjects(repository);
final approveQuote = _approveQuote(repository);
final loadQuotes = _loadQuotes(repository);
final loadQuote = _loadQuote(repository);
Expand All @@ -45,7 +46,8 @@ List<Middleware<AppState>> createStoreQuotesMiddleware([
TypedMiddleware<AppState, ViewQuoteList>(viewQuoteList),
TypedMiddleware<AppState, ViewQuote>(viewQuote),
TypedMiddleware<AppState, EditQuote>(editQuote),
TypedMiddleware<AppState, ConvertQuotes>(convertQuote),
TypedMiddleware<AppState, ConvertQuotesToInvoices>(convertQuotesToInvoices),
TypedMiddleware<AppState, ConvertQuotesToProjects>(convertQuotesToProjects),
TypedMiddleware<AppState, ApproveQuotes>(approveQuote),
TypedMiddleware<AppState, ShowEmailQuote>(showEmailQuote),
TypedMiddleware<AppState, ShowPdfQuote>(showPdfQuote),
Expand Down Expand Up @@ -223,19 +225,39 @@ Middleware<AppState> _restoreQuote(QuoteRepository repository) {
};
}

Middleware<AppState> _convertQuote(QuoteRepository repository) {
Middleware<AppState> _convertQuotesToInvoices(QuoteRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ConvertQuotes;
final action = dynamicAction as ConvertQuotesToInvoices;
repository
.bulkAction(store.state.credentials, action.quoteIds,
EntityAction.convertToInvoice)
.then((quotes) {
store.dispatch(ConvertQuoteSuccess(quotes: quotes));
store.dispatch(ConvertQuotesToInvoicesSuccess(quotes: quotes));
store.dispatch(RefreshData());
action.completer.complete(null);
}).catchError((Object error) {
print(error);
store.dispatch(ConvertQuoteFailure(error));
store.dispatch(ConvertQuotesToInvoicesFailure(error));
action.completer.completeError(error);
});

next(action);
};
}

Middleware<AppState> _convertQuotesToProjects(QuoteRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ConvertQuotesToProjects;
repository
.bulkAction(store.state.credentials, action.quoteIds,
EntityAction.convertToProject)
.then((quotes) {
store.dispatch(ConvertQuotesToProjectsSuccess(quotes: quotes));
store.dispatch(RefreshData());
action.completer.complete(null);
}).catchError((Object error) {
print(error);
store.dispatch(ConvertQuotesToProjectsFailure(error));
action.completer.completeError(error);
});

Expand Down
Loading

0 comments on commit b2b40fe

Please sign in to comment.