Skip to content

Commit 4ae7f7f

Browse files
committed
Add project locations. Enforce primary location has a _specified_ funding account
1 parent 2dad437 commit 4ae7f7f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

dbschema/funding-account.esdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module default {
33
overloaded name {
44
constraint exclusive;
55
}
6-
6+
77
required accountNumber: int16 {
88
constraint min_value(0);
99
constraint max_value(9);

dbschema/project.esdl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ module default {
4444
# multi link engagements := .<project[is Engagement];
4545
property engagementTotal := count(.<project[is Engagement]);
4646

47-
# link primaryLocation: Location;
48-
# link marketingLocation: Location;
49-
# link fieldRegion: FieldRegion;
47+
primaryLocation: Location;
48+
trigger enforceFundingAccount after update for each do (
49+
assert(
50+
any(__new__.primaryLocation.fundingAccount.accountNumber > 0)
51+
or not exists __new__.primaryLocation, # allow clearing
52+
message := "Project must have a primary location with a specified funding account"
53+
)
54+
);
55+
marketingLocation: Location;
56+
fieldRegion: FieldRegion;
57+
5058
link rootDirectory: Directory;
5159

5260
overloaded link projectContext: Project::Context {

0 commit comments

Comments
 (0)