Class: Edi::Commercehub::PackingSlipReaderCostcoCa
- Inherits:
-
BaseEdiService
- Object
- BaseService
- BaseEdiService
- Edi::Commercehub::PackingSlipReaderCostcoCa
- Defined in:
- app/services/edi/commercehub/packing_slip_reader_costco_ca.rb
Constant Summary
Constants included from AddressAbbreviator
AddressAbbreviator::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseEdiService
Instance Method Summary collapse
Methods inherited from BaseEdiService
#duplicate_po_already_notified?, #initialize, #mark_duplicate_po_as_notified, #report_order_creation_issues, #safe_process_edi_communication_log
Methods included from AddressAbbreviator
#abbreviate_street, #collect_street_originals, #record_address_abbreviation_notes
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
This class inherits a constructor from Edi::BaseEdiService
Instance Method Details
#process(file_path, _options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/edi/commercehub/packing_slip_reader_costco_ca.rb', line 7 def process(file_path, = {}) return unless File.exist?(file_path) identity = nil begin require 'pdf/inspector' ta = PDF::Inspector::Text.analyze(File.read(file_path)) # Get an array of all strings discovered strings = ta.strings # Find the position of the PO # label identity = strings.detect { |s| s =~ /^008\d{11}/ }&.scan(/\d/)&.join rescue StandardError => exc logger.error "Unable to process file #{file_path}, #{exc}" ErrorReporting.error exc end identity end |