lib/pack_material/services/complete_purchase_invoice.rb
# rubocop:disable Metrics/ClassLength
# Complete a purchase invoice and send XML representation to accounting system.
# - use the `just_show_xml` flag to check the XML output without modifying the db.
#
# @param user_name [string] the user who initiated this task.
# @param opts [Hash] { delivery_id [integer], mr_goods_returned_note_id [integer] }
# @param just_show_xml [bool] set to true to just return XML from the call without updating the db.
disable Metrics/ClassLength
Complete a purchase invoice and send XML representation to accounting system.
use the `just_show_xml` flag to check the XML output without modifying the db.
disable Metrics / ClassLength Complete a purchase invoice and send XML representation to accounting system . use the ` just_show_xml ` flag to check the XML output without modifying the db .
def call 
      return failed_response('Delivery does not exist') unless @repo.exists?(:mr_deliveries, id: @id)
      return failed_response('GRN does not exist') if @grn_id && !@dispatch_repo.exists?(:mr_goods_returned_notes, id: @grn_id)
      request_xml = @grn_id ? build_grn_xml : build_xml
      return request_xml if @just_show_xml
      log_string = @grn_id ? '_cn_xml' : '_xml'
      @log_repo.log_infodump('complete_purchase_invoice', @id, 'sending' + log_string, request_xml)
      res = make_http_call(request_xml)
      @log_repo.log_infodump('complete_purchase_invoice', @id, 'response' + log_string, res.instance.body)
      formatted_res = format_response(res.instance.body)
      @grn_id ? apply_grn_changes(formatted_res) : apply_delivery_changes(formatted_res)
    end
def call return failed_response ( 'Delivery does not exist' ) unless @repo . exists? ( :mr_deliveries , id : @id ) return failed_response ( 'GRN does not exist' ) if @grn_id && ! @dispatch_repo . exists? ( :mr_goods_returned_notes , id : @grn_id ) request_xml = @grn_id ? build_grn_xml : build_xml return request_xml if @just_show_xml log_string = @grn_id ? '_cn_xml' : '_xml' @log_repo . log_infodump ( 'complete_purchase_invoice' , @id , 'sending' + log_string , request_xml ) res = make_http_call ( request_xml ) @log_repo . log_infodump ( 'complete_purchase_invoice' , @id , 'response' + log_string , res . instance . body ) formatted_res = format_response ( res . instance . body ) @grn_id ? apply_grn_changes ( formatted_res ) : apply_delivery_changes ( formatted_res ) end
rubocop:disable Metrics/ClassLength
Complete a purchase invoice and send XML representation to accounting system.
rubocop : disable Metrics / ClassLength Complete a purchase invoice and send XML representation to accounting system .
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
user_name
<not_specific>
the user who initiated this task.
the user who initiated this task .
opts
<not_specific>
{ delivery_id [integer], mr_goods_returned_note_id [integer] }
{ delivery_id [ integer ] mr_goods_returned_note_id [ integer ] }
just_show_xml
<not_specific>
set to true to just return XML from the call without updating the db.
set to true to just return XML from the call without updating the db .