1
0
planet_express_express/bin/process
Tim Kächele e91e12c7ea Stop reading in all content
Process the shipments month by month instead
2024-12-11 20:13:35 +01:00

19 lines
606 B
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require "planet_express_express"
require "stringio"
data = File.read(ARGV[0])
output = StringIO.new
PlanetExpressExpress::ShipmentReader.new(PlanetExpressExpress::PRICE_LIST).read_shipments(data) do |shipments|
PlanetExpressExpress::Rules.new(PlanetExpressExpress::PRICE_LIST).apply_rules(shipments)
PlanetExpressExpress::DiscountBudget.new(PlanetExpressExpress::DISCOUNT_LIMIT).limit_discounts(shipments)
PlanetExpressExpress::Formatter.new(output).format(shipments)
output.rewind
puts output.read
output.rewind
end