1 # For an online version, see http://wiki.bestpractical.com/?RulesetWorkflow
3 _*This is a design document for a work in progress.
4 It describes features that do not exist today and may never exist*_
8 * The user of PurchaseOrder queue fill in a numeric "CF", called "Price".
9 * On creation, it needs to create following approvals:
10 ** "ManagerApproval" if CF.Price is > 1000
11 ** "PresidentApproval" if CF.Price is > 2000
12 * When all of "M", "P" are resolved (or if there were none to begin with), Create "FinanceApproval".
13 * If any approvals above is rejected, reject the original ticket.
14 * If "FinanceApproval" is resolved, resolve original ticket.
15 * If "FinanceApproval" is rejected, create an approval for "CEOApproval".
16 * If "CEOApproval" is resolved, resolve the original ticket.
17 * If "CEOApproval" is rejected, reject the original ticket.
21 ,----------. ,---------------------->[DONE]
23 [TOP]-+-?---->[M]---->[F] |
25 `-?->[P]-+-' `-(!)->[C]-----------------'
27 | | `-(!)---------->[FAIL]
29 `-(!)----------------------------------'
33 Note that "Scrips" are now called "Rules".
35 === RuleAction "AquireMyLocks"
37 FOREACH $Scrip IN $TicketObj->Scrips
38 WHERE $Scrip.Action.Type == "TryCreateTicketWithRuleset"
39 DO LockRuleset $Scrip.Action.Argument
41 === RuleAction "TryCreateTicketWithRuleset"
43 DO ReleaseMyLockOnRuleset $Argument
44 UNLESS RulesetLocked $Argument
45 DO CreateTicketWithRuleset $Argument
47 === RuleAction "CreateTicketWithRuleset"
49 GIVEN $Ticket AS CreateTicket(@OtherArguments)
50 DO SetTicketRuleSet $Argument
51 DO RunTicketRuleSet $Argument
53 === GlobalRule "AquireLocks"
55 * AppliesTo: All Objects
57 * Action: AquireMyLocks
59 === Queue "PurchaseOrder"
62 ** Condition: OnCreate
63 ** Action: SetTicketRuleSet "PurchaseFlow"
64 ** Action: RunTicketRuleSet "PurchaseFlow"
66 === RuleSet "PurchaseFlow"
68 * Rule (implicitly run by AcquireMyLocks):
69 ** Condition: OnCreate
70 ** Action: LockRuleSet "ManagerApproval"
71 ** Action: LockRuleSet "PresidentApproval"
72 ** Action: LockRuleSet "FinanceApproval"
75 ** Condition: OnCreate
76 ** Condition: CF.Price > 1000
77 ** Action: TryCreateTicketWithRuleset "ManagerApproval"
80 ** Condition: OnCreate
81 ** Condition: CF.Price > 2000
82 ** Action: TryCreateTicketWithRuleset "PresidentApproval"
85 ** Condition: OnCreate
86 ** Condition: "Finance" is not blocked
87 ** Action: TryCreateTicketWithRuleset "FinanceApproval"
90 ** Condition: OnReject
93 === RuleSet: "ManagerApproval"
95 * Rule (implicitly run by AcquireMyLocks):
96 ** Condition: OnCreate
97 ** Action: LockRuleSet "FinanceApproval"
100 ** Condition: OnResolve
101 ** Action: TryCreateTicketWithRuleset "FinanceApproval"
104 ** Condition: OnReject
105 ** Action: RejectTicket "PurchaseFlow"
107 === RuleSet: "PresidentApproval"
109 * Rule (implicitly run by AcquireMyLocks):
110 ** Condition: OnCreate
111 ** Action: LockRuleSet "FinanceApproval"
114 ** Condition: OnResolve
115 ** Action: TryCreateTicketWithRuleset "FinanceApproval"
118 ** Condition: OnReject
119 ** Action: RejectTicket "PurchaseFlow"
121 === RuleSet: "FinanceApproval"
124 ** Condition: OnResolve
125 ** Action: ResolveTicket "PurchaseFlow"
128 ** Condition: OnReject
129 ** Action: ForceCreateTicketWithRuleset "CEOApproval"
131 === RuleSet: "CEOApproval"
134 ** Condition: OnResolve
135 ** Action: ResolveTicket "PurchaseFlow"
138 ** Condition: OnReject
139 ** Action: RejectTicket "PurchaseFlow"
141 ### FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD ###
143 == Another Text Description
145 * I have a MonitoredQueue that sets tickets to "Monitored" if its subject matches /monitored/.
146 * I want to have a kind of Ticket that are 'Monitored'.
147 * I want all monitored tickets, when they are overdue for 14 days, to:
148 ** Send notification to manager
150 * I want all monitored tickets, when they are overdue for 28 days, to:
152 * I want to query all tickets that are monitored as such
153 * I want to modify 14 => 15 and have it affect all existing tickets that are monitored
154 * I want to add a new "overdue for 27 days, add a 'ultimatum' correspondence to it" rule
155 ** For all monitored tickets.
156 * I want to add a new "overdue for 27 days, add a 'ultimatum' correspondence to it" rule
157 ** For all _new_ monitored tickets.
158 ** Without affecting existing ones.