Files
nemo_encoder/app/models/batch.rb
2023-08-28 14:37:04 +06:30

30 lines
791 B
Ruby

class Batch < ApplicationRecord
has_many :batch_line_item
belongs_to :client
belongs_to :product_category
belongs_to :user
def self.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id)
batch = Batch.new
batch.exported_by=""
batch.order_ref = order_ref
batch.date = date
batch.batch_start = true
batch.batch_start_time=DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
batch.qty_processing = 0
batch.qty_success = 0
batch.qty_fail = 0
batch.user_id=user_id
batch.export_count=0
batch.client_id=client_id
batch.product_category_id=product_category_id
batch.adult_or_child=adult_or_child.upcase
if batch.save
return batch
else
return nil
end
end
end