Class: Edi::Commercehub::PackingSlipReaderCostcoCa
- Inherits:
-
BaseEdiService
- Object
- BaseService
- BaseEdiService
- Edi::Commercehub::PackingSlipReaderCostcoCa
- Defined in:
- app/services/edi/commercehub/packing_slip_reader_costco_ca.rb
Overview
Takes a packing slip from The Home Depot cnada and parses the PO # number from it
Sample file in extras/edi/samples/thd_ca/sample-packing-slip.pdf
Constant Summary
Constants included from RequestIdentifiable
RequestIdentifiable::REQUEST_ID_HEADERS
Constants included from AddressAbbreviator
AddressAbbreviator::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseEdiService
Attributes inherited from BaseService
Instance Method Summary collapse
Methods inherited from BaseEdiService
#amazon_feed_product_type, #duplicate_po_already_notified?, #initialize, #mark_duplicate_po_as_notified, #onboard_ordered_catalog_items, #report_order_creation_issues, #safe_process_edi_communication_log
Methods included from RequestIdentifiable
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, #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.find { |s| s =~ /^008\d{11}/ }&.scan(/\d/)&.join rescue StandardError => e logger.error "Unable to process file #{file_path}, #{e}" ErrorReporting.error e end identity end |