Don’t allow editing cancelled/reversed invoices
This commit is contained in:
parent
9010a8084d
commit
c57551504f
|
|
@ -259,6 +259,8 @@ abstract class BaseEntity implements SelectableEntity {
|
||||||
bool get isArchived =>
|
bool get isArchived =>
|
||||||
archivedAt != null && archivedAt > 0 && !(isDeleted ?? false);
|
archivedAt != null && archivedAt > 0 && !(isDeleted ?? false);
|
||||||
|
|
||||||
|
bool get isEditable => !isDeleted;
|
||||||
|
|
||||||
bool userCanAccess(String userId) =>
|
bool userCanAccess(String userId) =>
|
||||||
createdUserId == userId || assignedUserId == userId;
|
createdUserId == userId || assignedUserId == userId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -337,6 +337,21 @@ abstract class InvoiceEntity extends Object
|
||||||
|
|
||||||
bool get hasInvoice => '${invoiceId ?? ''}'.isNotEmpty;
|
bool get hasInvoice => '${invoiceId ?? ''}'.isNotEmpty;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get isEditable {
|
||||||
|
if (isDeleted) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entityType == EntityType.invoice) {
|
||||||
|
if (isCancelledOrReversed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int get age {
|
int get age {
|
||||||
int ageInDays = 0;
|
int ageInDays = 0;
|
||||||
if (isPastDue) {
|
if (isPastDue) {
|
||||||
|
|
|
||||||
|
|
@ -740,7 +740,7 @@ void editEntityById(
|
||||||
final map = store.state.getEntityMap(entityType);
|
final map = store.state.getEntityMap(entityType);
|
||||||
final entity = map[entityId] as BaseEntity;
|
final entity = map[entityId] as BaseEntity;
|
||||||
|
|
||||||
if (entity.isDeleted) {
|
if (!entity.isEditable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class ViewScaffold extends StatelessWidget {
|
||||||
userCompany.canEditEntity(entity)
|
userCompany.canEditEntity(entity)
|
||||||
? Builder(builder: (context) {
|
? Builder(builder: (context) {
|
||||||
return EditIconButton(
|
return EditIconButton(
|
||||||
isVisible: !(entity.isDeleted ?? false),
|
isVisible: entity.isEditable,
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
editEntity(context: context, entity: entity),
|
editEntity(context: context, entity: entity),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue