Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Mar 17, 2023
2 parents 64037aa + 764255e commit 88ed86f
Show file tree
Hide file tree
Showing 25 changed files with 179 additions and 75 deletions.
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CURRENT_PROJECT_VERSION = 109;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = NPC44Y2C98;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -373,7 +373,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.109;
MARKETING_VERSION = 5.0.110;
PRODUCT_BUNDLE_IDENTIFIER = com.invoiceninja.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down Expand Up @@ -497,7 +497,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CURRENT_PROJECT_VERSION = 109;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = NPC44Y2C98;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -506,7 +506,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.109;
MARKETING_VERSION = 5.0.110;
PRODUCT_BUNDLE_IDENTIFIER = com.invoiceninja.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -524,7 +524,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CURRENT_PROJECT_VERSION = 109;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = NPC44Y2C98;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -533,7 +533,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.109;
MARKETING_VERSION = 5.0.110;
PRODUCT_BUNDLE_IDENTIFIER = com.invoiceninja.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down
3 changes: 2 additions & 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.109';
const String kClientVersion = '5.0.110';
const String kMinServerVersion = '5.0.4';

const String kAppName = 'Invoice Ninja';
Expand Down Expand Up @@ -925,3 +925,4 @@ const String kActivityRestorePurchaseOrder = '134';
const String kActivityEmailPurchaseOrder = '135';
const String kActivityViewPurchaseOrder = '136';
const String kActivityAcceptPurchaseOrder = '137';
const String kActivityEmailPayment = '138';
2 changes: 2 additions & 0 deletions lib/data/models/invoice_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ abstract class InvoiceEntity extends Object
if (isPurchaseOrder &&
[
kPurchaseOrderStatusAccepted,
kPurchaseOrderStatusReceived,
].contains(statusId)) {
return true;
}
Expand Down Expand Up @@ -929,6 +930,7 @@ abstract class InvoiceEntity extends Object
if (status.id == statusId || status.id == calculatedStatusId) {
return true;
} else if (status.id == kInvoiceStatusUnpaid &&
isInvoice &&
isUnpaid &&
isSent &&
!isCancelledOrReversed) {
Expand Down
22 changes: 20 additions & 2 deletions lib/data/models/task_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,27 @@ abstract class TaskEntity extends Object
return false;
}

final date = convertDateTimeToSqlDate(taskTimes.first.startDate.toLocal());
final taskStartDate =
convertDateTimeToSqlDate(taskTimes.first.startDate.toLocal());
if (startDate.compareTo(taskStartDate) <= 0 &&
endDate.compareTo(taskStartDate) >= 0) {
return true;
}

final completedTimes = taskTimes.where((element) => !element.isRunning);

return startDate.compareTo(date) <= 0 && endDate.compareTo(date) >= 0;
if (completedTimes.isNotEmpty) {
final lastTaskTime = completedTimes.last;
final taskEndDate =
convertDateTimeToSqlDate(lastTaskTime.endDate.toLocal());

if (startDate.compareTo(taskEndDate) <= 0 &&
endDate.compareTo(taskEndDate) >= 0) {
return true;
}
}

return false;
}

int get startTimestamp {
Expand Down
7 changes: 4 additions & 3 deletions lib/data/repositories/task_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ class TaskRepository {
return taskResponse.data;
}

Future<BuiltList<TaskEntity>> loadList(
Credentials credentials, int createdAt, bool filterDeleted) async {
final url = credentials.url + '/tasks?created_at=$createdAt';
Future<BuiltList<TaskEntity>> loadList(Credentials credentials, int page,
int createdAt, bool filterDeleted) async {
final url = credentials.url +
'/tasks?per_page=$kMaxRecordsPerPage&page=$page&created_at=$createdAt';

/* Server is incorrect if client isn't set
if (filterDeleted) {
Expand Down
9 changes: 9 additions & 0 deletions lib/redux/app/app_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ void createEntity({
bool force = false,
Completer completer,
Completer cancelCompleter,
BaseEntity filterEntity,
}) {
final store = StoreProvider.of<AppState>(context);
final state = store.state;
Expand All @@ -1038,6 +1039,14 @@ void createEntity({
store.dispatch(ToggleEditorLayout(entity.entityType));
}

if (filterEntity != null) {
if (uiState.filterEntityType != filterEntity.entityType ||
uiState.filterEntityId != filterEntity.id) {
store.dispatch(ClearEntitySelection(entityType: entity.entityType));
store.dispatch(FilterByEntity(entity: filterEntity));
}
}

switch (entity.entityType) {
case EntityType.client:
store.dispatch(EditClient(
Expand Down
16 changes: 8 additions & 8 deletions lib/redux/credit/credit_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ Future handleCreditAction(
final localization = AppLocalization.of(context);
final credit = credits.first as InvoiceEntity;
final creditIds = credits.map((credit) => credit.id).toList();
final client = state.clientState.get(credit.clientId);

switch (action) {
case EntityAction.edit:
Expand Down Expand Up @@ -497,7 +498,7 @@ Future handleCreditAction(
TextButton(
onPressed: () {
Navigator.of(context).pop();
editEntity(entity: state.clientState.get(credit.clientId));
editEntity(entity: client);
},
child: Text(localization.editClient.toUpperCase()))
]);
Expand Down Expand Up @@ -587,13 +588,12 @@ Future handleCreditAction(
case EntityAction.applyCredit:
createEntity(
context: context,
entity: PaymentEntity(
state: state, client: state.clientState.get(credit.clientId))
.rebuild((b) => b
..typeId = kPaymentTypeCredit
..credits.addAll(credits
.map((credit) => PaymentableEntity.fromCredit(credit))
.toList())),
entity: PaymentEntity(state: state, client: client).rebuild((b) => b
..typeId = kPaymentTypeCredit
..credits.addAll(credits
.map((credit) => PaymentableEntity.fromCredit(credit))
.toList())),
filterEntity: client,
);
break;
case EntityAction.download:
Expand Down
16 changes: 8 additions & 8 deletions lib/redux/invoice/invoice_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
final localization = AppLocalization.of(context);
final invoice = invoices.first as InvoiceEntity;
final invoiceIds = invoices.map((invoice) => invoice.id).toList();
final client = state.clientState.get(invoice.clientId);

switch (action) {
case EntityAction.edit:
Expand Down Expand Up @@ -616,7 +617,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
TextButton(
onPressed: () {
Navigator.of(context).pop();
editEntity(entity: state.clientState.get(invoice.clientId));
editEntity(entity: client);
},
child: Text(localization.editClient.toUpperCase()))
]);
Expand Down Expand Up @@ -694,13 +695,12 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
case EntityAction.newPayment:
createEntity(
context: context,
entity: PaymentEntity(
state: state, client: state.clientState.get(invoice.clientId))
.rebuild((b) => b
..invoices.addAll(invoices
.where((invoice) => !(invoice as InvoiceEntity).isPaid)
.map((invoice) => PaymentableEntity.fromInvoice(invoice))
.toList())),
entity: PaymentEntity(state: state, client: client).rebuild((b) => b
..invoices.addAll(invoices
.where((invoice) => !(invoice as InvoiceEntity).isPaid)
.map((invoice) => PaymentableEntity.fromInvoice(invoice))
.toList())),
filterEntity: client,
);
break;
case EntityAction.download:
Expand Down
3 changes: 2 additions & 1 deletion lib/redux/task/task_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ class LoadTaskActivity {
}

class LoadTasks {
LoadTasks({this.completer});
LoadTasks({this.completer, this.page = 1});

final Completer completer;
final int page;
}

class LoadTaskRequest implements StartLoading {}
Expand Down
15 changes: 12 additions & 3 deletions lib/redux/task/task_middleware.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Flutter imports:
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:invoiceninja_flutter/constants.dart';

// Package imports:
import 'package:redux/redux.dart';
Expand Down Expand Up @@ -284,16 +285,24 @@ Middleware<AppState> _loadTasks(TaskRepository repository) {
repository
.loadList(
state.credentials,
action.page,
state.createdAtLimit,
state.filterDeletedClients,
)
.then((data) {
store.dispatch(LoadTasksSuccess(data));

if (action.completer != null) {
action.completer.complete(null);
if (data.length == kMaxRecordsPerPage) {
store.dispatch(LoadTasks(
completer: action.completer,
page: action.page + 1,
));
} else {
if (action.completer != null) {
action.completer.complete(null);
}
store.dispatch(LoadVendors());
}
store.dispatch(LoadVendors());
}).catchError((Object error) {
print(error);
store.dispatch(LoadTasksFailure(error));
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/app/entity_dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ class _EntityDropdownState extends State<EntityDropdown> {
builder: (BuildContext context) {
return EntityDropdownDialog(
entityMap: _entityMap,
entityList: widget.entityList ?? _entityMap.keys.toList(),
entityList: (widget.entityList ?? _entityMap.keys)
.where((elementId) => !widget.excludeIds.contains(elementId))
.toList(),
onSelected: (entity, [update = true]) {
if (entity?.id == widget.entityId) {
return;
Expand Down
15 changes: 10 additions & 5 deletions lib/ui/app/history_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ class _HistoryListTileState extends State<HistoryListTile> {
].contains(history.entityType)) {
title = Text(localization.lookup(history.entityType.toString()));
if (history.entityType == EntityType.reports) {
subtitle =
Text(localization.lookup(state.uiState.reportsUIState.report));
subtitle = Text(
localization.lookup(state.uiState.reportsUIState.report),
style: Theme.of(context).textTheme.bodySmall,
);
} else if (history.entityType == EntityType.settings) {
subtitle =
Text(localization.lookup(history.id ?? kSettingsCompanyDetails));
subtitle = Text(
localization.lookup(history.id ?? kSettingsCompanyDetails),
style: Theme.of(context).textTheme.bodySmall,
);
}
} else {
entity = state.getEntityMap(history.entityType)[history.id] as BaseEntity;
Expand Down Expand Up @@ -158,7 +162,7 @@ class _HistoryListTileState extends State<HistoryListTile> {
key: ValueKey('__${history.id}_${history.entityType}__'),
leading: Icon(getEntityIcon(history.entityType)),
title: Row(
crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
Expand All @@ -168,6 +172,7 @@ class _HistoryListTileState extends State<HistoryListTile> {
subtitle,
],
)),
SizedBox(width: 8),
Flexible(
child: LiveText(
() => timeago.format(history.dateTime,
Expand Down
11 changes: 7 additions & 4 deletions lib/ui/purchase_order/purchase_order_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ class PurchaseOrderListItem extends StatelessWidget {
),
SizedBox(width: 10),
Text(
formatNumber(purchaseOrder.amount, context),
formatNumber(
purchaseOrder.amount,
context,
vendorId: vendor.id,
),
style: textStyle,
textAlign: TextAlign.end,
),
Expand Down Expand Up @@ -198,10 +202,9 @@ class PurchaseOrderListItem extends StatelessWidget {
SizedBox(width: 4),
Text(
formatNumber(
purchaseOrder.balance > 0
? purchaseOrder.balance
: purchaseOrder.amount,
purchaseOrder.amount,
context,
vendorId: vendor.id,
),
style: Theme.of(context).textTheme.subtitle1),
],
Expand Down
19 changes: 11 additions & 8 deletions lib/ui/reports/reports_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ class ReportsScreen extends StatelessWidget {
]
];

final entities = reportResult.entities ?? [];
final firstEntity = entities.isNotEmpty ? entities.first : null;
if (entities.length > kMaxEntitiesPerBulkAction) {
entities.removeRange(kMaxEntitiesPerBulkAction, entities.length);
final cappedEntities = [...reportResult.entities ?? []];
final firstEntity = cappedEntities.isNotEmpty ? cappedEntities.first : null;
if (cappedEntities.length > kMaxEntitiesPerBulkAction) {
cappedEntities.removeRange(
kMaxEntitiesPerBulkAction, cappedEntities.length);
}

final chartChildren = [
Expand Down Expand Up @@ -382,16 +383,18 @@ class ReportsScreen extends StatelessWidget {
multiselect: true),
entity: firstEntity,
onSelected: (context, action) {
final entities = action.applyMaxLimit
? cappedEntities
: reportResult.entities;
confirmCallback(
context: context,
message: localization.lookup(action.toString()) +
' • ' +
(reportResult.entities.length == 1
(entities.length == 1
? '1 ${localization.lookup(firstEntity.entityType.toString())}'
: '${reportResult.entities.length} ${localization.lookup(firstEntity.entityType.plural)}'),
: '${entities.length} ${localization.lookup(firstEntity.entityType.plural)}'),
callback: (_) {
handleEntitiesActions(
reportResult.entities, action);
handleEntitiesActions(entities, action);
});
}),
),
Expand Down
Loading

0 comments on commit 88ed86f

Please sign in to comment.