add new api

This commit is contained in:
Sunandar
2017-02-03 17:56:27 +06:30
parent b4c9e8cc8e
commit 538c898e06
12 changed files with 117 additions and 75 deletions

View File

@@ -1,7 +1,7 @@
class Batch < ApplicationRecord
has_many :batch_line_item
def self.create_batch(created_by,date,order_ref, card_qty,user_id,adult_or_child)
def self.create_batch(created_by,date,order_ref, card_qty,user_id,adult_or_child,client_id)
batch = Batch.new
batch.created_by = created_by
batch.order_ref = order_ref
@@ -13,6 +13,7 @@ class Batch < ApplicationRecord
batch.qty_fail = 0
batch.user_id=user_id
batch.export_count=0
batch.client_id=client_id
batch.adult_or_child=adult_or_child.upcase
if batch.save
return batch

View File

@@ -20,7 +20,7 @@ class BatchLineItem < ApplicationRecord
return account_no
end
def self.generate_serial_no(user_id)
def self.generate_serial_no(client_id)
find_lookup=Lookup.find_by_name('generate_serial_no')
if !find_lookup.nil?
max_value=find_lookup.max_value
@@ -34,10 +34,11 @@ class BatchLineItem < ApplicationRecord
ends=sufix_len-value_len-1
sufix_str= sufix_str[start..ends]
prefix=prefix[start..2]
prefix_str=prefix.to_s + user_id.to_s
prefix_str=prefix.to_s + client_id.to_s
serial_no=prefix_str.to_s+sufix_str+max_value.to_s
return serial_no
return serial_no
end
end
def self.to_csv(user_id)