Module: Subledger::Store::Api::CreateAndPost

Included in:
Store
Defined in:
lib/subledger/store/api/roles/create_and_post.rb

Instance Method Summary collapse

Instance Method Details

#create_and_post(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/subledger/store/api/roles/create_and_post.rb', line 5

def create_and_post args
  dje       = args[:active_journal_entry]
  dje_lines = args[:active_lines]
  pje       = args[:posting_journal_entry]

  path = Path.for_collection( :anchor => dje ) + '/create_and_post'

  json_body = http.post do |req|
                req.url path

                unless dje.post_delay.zero?
                  req.headers['X-Subledger-Post-Slowly'] = 'true'
                end

                req.body = create_and_post_hash( dje, dje_lines )
              end.body

  new_or_initialize json_body, pje
end