Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Nov 10, 2021
2 parents 618ded5 + 09b07f2 commit 6588cba
Show file tree
Hide file tree
Showing 35 changed files with 328 additions and 120 deletions.
4 changes: 3 additions & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const String kLinuxUrl = 'https://download.invoiceninja.com/linux';
const String kWindowsUrl =
'https://www.microsoft.com/en-us/p/invoice-ninja/9n3f2bbcfdr6';

const String kGitHubUrl = 'https://github.com/invoiceninja/';
const String kSlackUrl = 'http://slack.invoiceninja.com';
const String kGitHubUrl = 'https://github.com/invoiceninja';
const String kTwitterUrl = 'https://twitter.com/invoiceninja';
const String kFacebookUrl = 'https://www.facebook.com/invoiceninja';
const String kYouTubeUrl =
Expand Down Expand Up @@ -130,6 +131,7 @@ const String kPaymentTypeMasterCard = '6';
const String kPaymentTypeAmEx = '7';
const String kPaymentTypeDiners = '9';
const String kPaymentTypeDiscover = '8';
const String kPaymentTypeCredit = '32';

const String kPlanFree = '';
const String kPlanPro = 'pro';
Expand Down
5 changes: 5 additions & 0 deletions lib/data/models/account_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abstract class AccountEntity
isDocker: false,
isSchedulerRunning: false,
disableAutoUpdate: false,
isMigrated: false,
defaultCompanyId: '',
trialPlan: '',
trialStarted: '',
Expand Down Expand Up @@ -63,6 +64,9 @@ abstract class AccountEntity
@BuiltValueField(wireName: 'is_docker')
bool get isDocker;

@BuiltValueField(wireName: 'is_migrated')
bool get isMigrated;

@BuiltValueField(wireName: 'is_scheduler_running')
bool get isSchedulerRunning;

Expand All @@ -88,6 +92,7 @@ abstract class AccountEntity
..isDocker = false
..isSchedulerRunning = false
..disableAutoUpdate = false
..isMigrated = false
..trialPlan = ''
..trialStarted = ''
..defaultCompanyId = '';
Expand Down
44 changes: 33 additions & 11 deletions lib/data/models/account_model.g.dart

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

2 changes: 0 additions & 2 deletions lib/data/models/company_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,6 @@ abstract class CompanyEntity extends Object

bool get hasTaxes => hasInvoiceTaxes || hasItemTaxes;

bool get isMigrated => companyKey.length == 32;

bool get isSmall => !isLarge;

bool get hasCustomSurcharge =>
Expand Down
12 changes: 8 additions & 4 deletions lib/data/models/invoice_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,6 @@ abstract class InvoiceEntity extends Object
}
}

if (isPayable && userCompany.canCreate(EntityType.payment)) {
actions.add(EntityAction.newPayment);
}

if (!isSent && !isRecurring) {
actions.add(EntityAction.markSent);
}
Expand All @@ -879,6 +875,14 @@ abstract class InvoiceEntity extends Object
actions.add(EntityAction.markPaid);
}

if (isPayable && userCompany.canCreate(EntityType.payment)) {
if (isCredit) {
actions.add(EntityAction.applyCredit);
} else {
actions.add(EntityAction.newPayment);
}
}

if (isQuote && (invoiceId ?? '').isEmpty) {
actions.add(EntityAction.convertToInvoice);
}
Expand Down
7 changes: 5 additions & 2 deletions lib/data/models/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class EntityAction extends EnumClass {
static const EntityAction cloneToRecurring = _$cloneToRecurring;
static const EntityAction convertToInvoice = _$convertToInvoice;
static const EntityAction approve = _$approve;
static const EntityAction apply = _$apply;
static const EntityAction applyCredit = _$applyCredit;
static const EntityAction applyPayment = _$applyPayment;
static const EntityAction download = _$download;
static const EntityAction bulkDownload = _$bulkDownload;
static const EntityAction emailInvoice = _$emailInvoice;
Expand All @@ -83,7 +84,7 @@ class EntityAction extends EnumClass {
static const EntityAction clientPortal = _$clientPortal;
static const EntityAction newPayment = _$newPayment;
static const EntityAction settings = _$settings;
static const EntityAction refund = _$refund;
static const EntityAction refundPayment = _$refundPayment;
static const EntityAction viewPdf = _$viewPdf;
static const EntityAction viewStatement = _$viewStatement;
static const EntityAction more = _$more;
Expand All @@ -105,6 +106,8 @@ class EntityAction extends EnumClass {
return toSnakeCase(super.toString());
}

bool get isEmail => toString().startsWith('email');

String toApiParam() {
final value = toString();

Expand Down
20 changes: 12 additions & 8 deletions lib/data/models/models.g.dart

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

8 changes: 6 additions & 2 deletions lib/data/models/payment_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class PaymentFields {
static const String clientId = 'client_id';
static const String invoiceId = 'invoice_id';
static const String invoiceNumber = 'invoice_number';
static const String creditNumber = 'credit_number';
static const String privateNotes = 'private_notes';
static const String exchangeRate = 'exchange_rate';
static const String convertedAmount = 'converted_amount';
Expand Down Expand Up @@ -195,6 +196,9 @@ abstract class PaymentEntity extends Object
@nullable
bool get isForInvoice;

@nullable
bool get isForCredit;

@nullable
bool get isApplying;

Expand Down Expand Up @@ -392,11 +396,11 @@ abstract class PaymentEntity extends Object
}

if (applied < amount) {
actions.add(EntityAction.apply);
actions.add(EntityAction.applyPayment);
}

if (completedAmount > 0) {
actions.add(EntityAction.refund);
actions.add(EntityAction.refundPayment);
}
}

Expand Down
Loading

0 comments on commit 6588cba

Please sign in to comment.