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 =>
|
||||
archivedAt != null && archivedAt > 0 && !(isDeleted ?? false);
|
||||
|
||||
bool get isEditable => !isDeleted;
|
||||
|
||||
bool userCanAccess(String userId) =>
|
||||
createdUserId == userId || assignedUserId == userId;
|
||||
|
||||
|
|
|
|||
|
|
@ -337,6 +337,21 @@ abstract class InvoiceEntity extends Object
|
|||
|
||||
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 ageInDays = 0;
|
||||
if (isPastDue) {
|
||||
|
|
|
|||
|
|
@ -740,7 +740,7 @@ void editEntityById(
|
|||
final map = store.state.getEntityMap(entityType);
|
||||
final entity = map[entityId] as BaseEntity;
|
||||
|
||||
if (entity.isDeleted) {
|
||||
if (!entity.isEditable) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class ViewScaffold extends StatelessWidget {
|
|||
userCompany.canEditEntity(entity)
|
||||
? Builder(builder: (context) {
|
||||
return EditIconButton(
|
||||
isVisible: !(entity.isDeleted ?? false),
|
||||
isVisible: entity.isEditable,
|
||||
onPressed: () =>
|
||||
editEntity(context: context, entity: entity),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue