Bugfix job role info allocation
This commit is contained in:
@@ -16,7 +16,7 @@ class Job < ApplicationRecord
|
||||
validate :acceptable_pdf
|
||||
|
||||
before_save :update_status_changed_at, if: :will_save_change_to_status?
|
||||
before_save :update_user_status_infos, if: :will_save_change_to_status?
|
||||
before_save :update_user_status_infos, if: -> { will_save_change_to_status? || new_record? }
|
||||
|
||||
before_save :set_cost_qm
|
||||
before_save :calc_cost, if: :printed_pages_changes?
|
||||
@@ -205,6 +205,10 @@ class Job < ApplicationRecord
|
||||
self.operator_lastname = nil
|
||||
end
|
||||
|
||||
def operator_infos_set?
|
||||
self.operator && self.operator_firstname && self.operator_lastname
|
||||
end
|
||||
|
||||
def set_cashier_infos
|
||||
self.paid_at = Time.now
|
||||
self.cashier = current_user unless self.cashier
|
||||
@@ -226,25 +230,23 @@ class Job < ApplicationRecord
|
||||
end
|
||||
|
||||
def update_user_status_infos
|
||||
if status_changed?
|
||||
case status.to_sym
|
||||
when :open
|
||||
reset_operator_and_cashier_infos
|
||||
self.printed_at = nil
|
||||
self.paid_at = nil
|
||||
when :printing
|
||||
clear_cashier_infos
|
||||
set_operator_infos
|
||||
self.printed_at = nil
|
||||
when :pickup
|
||||
clear_cashier_infos
|
||||
self.printed_at = Time.now unless self.printed_at
|
||||
when :paid
|
||||
set_operator_infos unless self.operator
|
||||
self.printed_at = Time.now unless self.printed_at
|
||||
set_cashier_infos unless self.cashier
|
||||
self.paid_at = Time.now unless self.paid_at
|
||||
end
|
||||
case status.to_sym
|
||||
when :open
|
||||
reset_operator_and_cashier_infos
|
||||
self.printed_at = nil
|
||||
self.paid_at = nil
|
||||
when :printing
|
||||
clear_cashier_infos
|
||||
set_operator_infos
|
||||
self.printed_at = nil
|
||||
when :pickup
|
||||
clear_cashier_infos
|
||||
self.printed_at = Time.now unless self.printed_at
|
||||
when :paid
|
||||
set_operator_infos unless operator_infos_set?
|
||||
self.printed_at = Time.now unless self.printed_at
|
||||
set_cashier_infos
|
||||
self.paid_at = Time.now
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user