@@ -9,8 +9,6 @@ module Status
99 VOIDED = 'voided'
1010 end
1111
12- class DraftedEvent < Event ; end
13-
1412 def draft ( user_id :, tenant_id :,
1513 organisation_id :, contact_id :,
1614 currency_code :, due_date :, line_items :,
@@ -51,7 +49,7 @@ def draft(user_id:, tenant_id:,
5149 quantity : line_item [ :quantity ] )
5250 end
5351
54- event = DraftedEvent . create! (
52+ event = Models :: Invoice :: DraftedEvent . create! (
5553 user_id : user_id ,
5654 tenant_id : tenant_id ,
5755 created_at : current_utc_time ,
@@ -118,8 +116,6 @@ def find_by_id(user_id:, tenant_id:, id:)
118116 }
119117 end
120118
121- class UpdatedEvent < Event ; end
122-
123119 def update ( user_id :, tenant_id :, id :,
124120 organisation_id :, contact_id :,
125121 due_date :, line_items :,
@@ -162,7 +158,7 @@ def update(user_id:, tenant_id:, id:,
162158 quantity : line_item [ :quantity ] )
163159 end
164160
165- event = UpdatedEvent . create! (
161+ event = Models :: Invoice :: UpdatedEvent . create! (
166162 user_id : user_id ,
167163 tenant_id : tenant_id ,
168164 created_at : current_utc_time ,
@@ -191,8 +187,6 @@ def update(user_id:, tenant_id:, id:,
191187 { id : invoice . id , events : [ { id : event . id , type : event . type } ] }
192188 end
193189
194- class DeletedEvent < Event ; end
195-
196190 def delete ( user_id :, tenant_id :, id :, time : ::Time )
197191 invoice = nil
198192 event = nil
@@ -204,7 +198,7 @@ def delete(user_id:, tenant_id:, id:, time: ::Time)
204198
205199 invoice . update! ( updated_at : current_utc_time , deleted_at : current_utc_time )
206200
207- event = DeletedEvent . create! (
201+ event = Models :: Invoice :: DeletedEvent . create! (
208202 user_id : user_id ,
209203 tenant_id : tenant_id ,
210204 created_at : current_utc_time ,
@@ -219,8 +213,6 @@ def delete(user_id:, tenant_id:, id:, time: ::Time)
219213 { id : invoice . id , events : [ { id : event . id , type : event . type } ] }
220214 end
221215
222- class IssuedEvent < Event ; end
223-
224216 def issue ( user_id :, tenant_id :, id :, time : ::Time )
225217 invoice = nil
226218 event = nil
@@ -235,7 +227,7 @@ def issue(user_id:, tenant_id:, id:, time: ::Time)
235227 issued_at : current_utc_time ,
236228 updated_at : current_utc_time )
237229
238- event = IssuedEvent . create! (
230+ event = Models :: Invoice :: IssuedEvent . create! (
239231 user_id : user_id ,
240232 tenant_id : tenant_id ,
241233 created_at : current_utc_time ,
@@ -251,8 +243,6 @@ def issue(user_id:, tenant_id:, id:, time: ::Time)
251243 { id : invoice . id , events : [ { id : event . id , type : event . type } ] }
252244 end
253245
254- class PaidEvent < Event ; end
255-
256246 def paid ( user_id :, tenant_id :, id :, time : ::Time )
257247 invoice = nil
258248 event = nil
@@ -268,7 +258,7 @@ def paid(user_id:, tenant_id:, id:, time: ::Time)
268258
269259 invoice . update! ( status : Invoice ::Status ::PAID , paid_at : Time . current )
270260
271- event = PaidEvent . create! (
261+ event = Models :: Invoice :: PaidEvent . create! (
272262 user_id : user_id ,
273263 tenant_id : tenant_id ,
274264 eventable : invoice ,
@@ -284,8 +274,6 @@ def paid(user_id:, tenant_id:, id:, time: ::Time)
284274 { id : invoice . id , events : [ { id : event . id , type : event . type } ] }
285275 end
286276
287- class VoidedEvent < Event ; end
288-
289277 def void ( user_id :, tenant_id :, id :, time : ::Time )
290278 invoice = nil
291279 event = nil
@@ -295,7 +283,7 @@ def void(user_id:, tenant_id:, id:, time: ::Time)
295283
296284 invoice . update! ( status : Invoice ::Status ::VOIDED )
297285
298- event = VoidedEvent . create! (
286+ event = Models :: Invoice :: VoidedEvent . create! (
299287 user_id : user_id ,
300288 tenant_id : tenant_id ,
301289 eventable : invoice ,
0 commit comments