Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Jun 21, 2024
2 parents dc39038 + 776313c commit 26a0789
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 34 deletions.
2 changes: 2 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const String kWhiteLabelUrl =
const String kPrivacyPolicyURL = 'https://www.invoiceninja.com/privacy-policy';
const String kTermsOfServiceURL = 'https://www.invoiceninja.com/terms';
const String kBankingURL = 'https://invoiceninja.com/banking';
const String kReferralURL = 'https://invoiceninja.com/referrals';
const String kTransifexURL =
'https://www.transifex.com/invoice-ninja/invoice-ninja';
const String kWebhookSiteURL = 'https://requestcatcher.com';
Expand Down Expand Up @@ -505,6 +506,7 @@ const String kNotificationsPurchaseOrderSent = 'purchase_order_sent';
const String kNotificationsPurchaseOrderViewed = 'purchase_order_viewed';
const String kNotificationsPurchaseOrderAccepted = 'purchase_order_accepted';
const String kNotificationsInventoryThreshold = 'inventory_threshold';
const String kNotificationsTaskAssigned = 'task_assigned';

const kNotificationEvents = [
kNotificationsInvoiceCreated,
Expand Down
4 changes: 4 additions & 0 deletions lib/data/models/serializers.g.dart

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

5 changes: 3 additions & 2 deletions lib/data/models/settings_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ abstract class SettingsEntity
static const EMAIL_SENDING_METHOD_SMTP = 'smtp';

static const LOCK_INVOICES_OFF = 'off';
static const LOCK_INVOICES_SENT = 'when_sent';
static const LOCK_INVOICES_PAID = 'when_paid';
static const LOCK_INVOICES_WHEN_SENT = 'when_sent';
static const LOCK_INVOICES_WHEN_PAID = 'when_paid';
static const LOCK_INVOICES_END_OF_MONTH = 'end_of_month';

static const AUTO_BILL_ALWAYS = 'always';
static const AUTO_BILL_OPT_IN = 'optin';
Expand Down
1 change: 0 additions & 1 deletion lib/data/models/static/static_data_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class StaticDataFields {
static const String gateways = 'gateways';
static const String gatewayTypes = 'gateway_types';
static const String fonts = 'fonts';
static const String banks = 'banks';
static const String bulkUpdates = 'bulk_updates';
}

Expand Down
15 changes: 14 additions & 1 deletion lib/data/models/user_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ abstract class UserEntity extends Object
languageId: '',
userCompany: userCompany,
userLoggedInNotification: true,
referralCode: '',
referralMeta: BuiltMap<String, int>(),
);
}

Expand Down Expand Up @@ -215,8 +217,17 @@ abstract class UserEntity extends Object
@BuiltValueField(wireName: 'user_logged_in_notification')
bool get userLoggedInNotification;

@BuiltValueField(wireName: 'referral_code')
String get referralCode;

@BuiltValueField(wireName: 'referral_meta')
BuiltMap<String, int> get referralMeta;

String get fullName => (firstName + ' ' + lastName).trim();

String get referralUrl =>
'https://app.invoicing.co/#/register?rc=$referralCode';

bool canEdit(BaseEntity entity) =>
entity.createdUserId == id || entity.assignedUserId == id;

Expand Down Expand Up @@ -347,7 +358,9 @@ abstract class UserEntity extends Object
..lastEmailAddress = ''
..oauthUserToken = ''
..languageId = ''
..userLoggedInNotification = true;
..userLoggedInNotification = true
..referralCode = ''
..referralMeta.replace(BuiltMap<String, int>());

static Serializer<UserEntity> get serializer => _$userEntitySerializer;
}
49 changes: 49 additions & 0 deletions lib/data/models/user_model.g.dart

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

16 changes: 14 additions & 2 deletions lib/redux/app/app_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:invoiceninja_flutter/constants.dart';
import 'package:invoiceninja_flutter/ui/bank_account/bank_account_screen.dart';
import 'package:invoiceninja_flutter/ui/schedule/schedule_screen.dart';
import 'package:invoiceninja_flutter/ui/transaction_rule/transaction_rule_screen.dart';
import 'package:invoiceninja_flutter/utils/formatting.dart';
import 'package:redux/redux.dart';

// Project imports:
Expand Down Expand Up @@ -1344,13 +1345,24 @@ void editEntity({
final client = state.clientState.get(invoice.clientId);
final settings = getClientSettings(state, client);

if (settings.lockInvoices == SettingsEntity.LOCK_INVOICES_PAID &&
final today = DateTime.now();
final todayValue = '${today.year}-${today.month}';
final date = convertSqlDateToDateTime(invoice.date);
final dateValue = '${date.year}-${date.month}';

if (settings.lockInvoices ==
SettingsEntity.LOCK_INVOICES_WHEN_PAID &&
invoice.isPaid) {
showMessageDialog(message: localization!.paidInvoicesArelocked);
} else if (settings.lockInvoices ==
SettingsEntity.LOCK_INVOICES_SENT &&
SettingsEntity.LOCK_INVOICES_WHEN_SENT &&
invoice.isSent) {
showMessageDialog(message: localization!.sentInvoicesArelocked);
} else if (settings.lockInvoices ==
SettingsEntity.LOCK_INVOICES_END_OF_MONTH &&
dateValue != todayValue) {
showMessageDialog(
message: localization!.invoicesLockedEndOfMonth);
} else {
store.dispatch(EditInvoice(
invoice: entity,
Expand Down
Loading

0 comments on commit 26a0789

Please sign in to comment.