import rt 3.4.4
[freeside.git] / rt / docs / design_docs / realflow.txt
1 - I have a MonitoredQueue that sets tickets to "Monitored"
2   if its subject matches /monitored/.
3   
4 - I want to have a kind of Ticket that are 'Monitored'.
5 - I want all monitored tickets, when they are overdue for
6   14 days, to:
7     - send notification to manager
8     - mark as stalled
9 - I want all monitored tickets, when they are overdue for
10   28 days, to:
11     - mark as rejected
12 - I want to query all tickets that are monitored as such
13 - I want to modify 14 => 15 and have it affect all existing
14   tickets that are monitored
15
16 {
17 - I want to add a new "overdue for 27 days, add a 'ultimatum'
18   correspondence to it" rule for all monitored tickets.
19 - I want to add a new "overdue for 27 days, add a 'ultimatum'
20   correspondence to it" rule for all _new_ monitored tickets
21   without affecting existing ones.
22 }
23
24 - The user of OrderRequest queue needs to fill a numeric "CF",
25   called "Price".
26 - On creation, it needs to create following approvals:
27     - "Manager" approval if CF.Price is > 1000
28     - "President" approval if CF.Price is > 2000
29 - When all of "M", "P" are resolved (if any, or if there were none
30   to begin with), Create a new approval, "Finance".
31 - If any approvals above is rejected, reject the original ticket.
32 - If "Finance" is resolved, resolve original ticket.
33 - If "Finance" is rejected, create an approval for "CEO".
34 - If "CEO" is resolved, resolve the original ticket.
35 - If "CEO" is rejected, reject the original ticket.
36
37 [RuleAction CreateTicketWithRuleset]
38   -> ReleaseMyLockOnRuleset $ruleset
39   -> UnlessLockOnRuleset $ruleset
40      # i.e. if no active tickets still have a lock on it
41      -> ForceCreateTicketWithRuleset $ruleset
42
43 [Queue OrderRequest]
44   -> Condition: OnCreate
45      Action: AddTicketRuleSet "PurchaseApproval"
46              # Triggers immediately
47
48 [RuleSet: PurchaseApproval]
49   -> Condition: OnCreate 
50      Condition: CF.Price > 1000
51      Action: CreateTicketWithRuleset "ManagerApproval"
52   -> Condition: OnCreate 
53      Condition: CF.Price > 2000
54      Action: CreateTicketWithRuleset "PresidentApproval"
55   -> Condition: OnCreate 
56      Action: CreateTicketWithRuleset "FinanceApproval"
57   -> Condition: OnReject
58      Action: DeleteTree
59
60 [RuleSet: ManagerApproval]
61   -> Condition: OnCreate
62      Action: Prohibit Ruleset "FinanceApproval"
63   -> Condition: OnResolve
64      Action: CreateTicketWithRuleset "FinanceApproval"
65   -> Condition: OnReject
66      Action: RejectTicket TOP
67
68 [RuleSet: PresidentApproval]
69   -> Condition: OnCreate
70      Action: Prohibit CreateTicketWithRuleset "FinanceApproval"
71   -> Condition: OnResolve
72      Action: CreateTicketWithRuleset "FinanceApproval"
73   -> Condition: OnReject
74      Action: RejectTicket TOP
75
76 [RuleSet: FinanceApproval]
77   -> Condition: OnCreate
78      Action: Prohibit RuleSet "CEOApproval"
79   -> Condition: OnResolve
80      Action: ResolveTicket TOP
81   -> Condition: OnReject
82      Action: CreateTicketWithRuleset "CEOApproval"
83
84 [RuleSet: CEOApproval]
85   -> Condition: OnResolve
86      Action: ResolveTicket TOP
87   -> Condition: OnReject
88      Action: RejectTicket TOP
89
90
91
92 Prohibit Ticket Operation:
93                 Ruleset CEOApproval
94
95
96
97
98
99
100
101       ,--------.
102 [TOP] --> [M] --> [F]
103     ` `-> [P] -'
104      `
105       `-> [X] --> [Y]
106   
107
108 [TOP] => [Approval]
109             -> Queue: B
110               -> Rule: yyy
111             -> Workflow: W
112               -> Stage: Approval
113               -> Rule: xxx
114
115 isa_ok( $Approval->Type, 'RT::Ticket' );
116 is( $Approval->Workflow->Name, 'W' );
117 is( $Approval->Stage->Name, 'Approval' );
118
119 [Queue: A]
120   -> Workflow: W
121
122 [Workflow: W]
123   -> Stage: TOP
124   -> Stage: Approval
125   -> Stage: SUCCESS
126   -> Stage: FAIL
127
128 "RuleCollections"
129
130 [Stage: TOP]
131   -> Rule: OnCreate RunStage Approval
132
133 ok( TicketA->Rules->HasEntry($ApprovalRule) )
134 ok( TicketB->Rules->HasEntry($ApprovalRule) )
135
136 [Rule: Approval]
137   -> Rule: OnResolve RunStage SUCCESS
138   -> Rule: OnReject RunStage FAIL
139
140 [Stage: SUCCESS]
141   -> Rule: OnCreate SetStatus('resolved') TOP
142
143 [Stage: FAIL]
144   -> Rule: OnCreate SetStatus('rejected') TOP
145
146 [Unassociated]
147   - Rule FOO: OnAnything {
148         CreateTicketIfNotBlocked StageFOO
149         AddLink DependedOnBy TOP to Stage1
150         AssignRule DoStage2 to Stage1
151         AssignRule DoStage3 to Stage1
152     }
153   - Rule BAR: OnAnything {
154         CreateTicketIfNotBlocked StageBAR
155         DoSomethingBizzare
156     }
157
158      ,==> [Stage0] ==>.
159     ,                  .
160 [TOP] ==> [Stage1] ==> [Stage3]
161     `                  '
162      `==> [Stage2] ==>'
163
164 OnTransaction:
165     $self->Ticket->Queues->Scrips->Apply
166
167 OnTransaction:
168     $self->Ticket->Queues->Scrips->Apply
169                  ->Scrips->Apply
170
171 OnTransaction:
172     $self->Ticket->Queues->Scrips->Apply
173                  ->Stages->Scrips->Apply
174
175 [QueueX]
176  - Rule:
177     OnCreate: 
178         RunRule FOO
179
180 [QueueY]
181  - Rule:
182     OnWhatever: 
183         RunRule FOO
184
185
186 [TOP] => [Stage1] => [Stage2] => [END]
187                `- => [Stage3] => [END]
188                 ` -> [Stage4]
189
190 [Stages]
191  ->