summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE4
-rw-r--r--README.md4
-rw-r--r--doc/manifest_format.md65
-rw-r--r--packingslip.rb4
4 files changed, 71 insertions, 6 deletions
diff --git a/LICENSE b/LICENSE
index 243943b..f95d86c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,4 @@
-BSD 2-Clause License
-
-Copyright (c) 2023, Magenta Stripe Media
+Copyright (c) 2023-2024, Magenta Stripe Media
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
diff --git a/README.md b/README.md
index 407a0dd..ff0ebda 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ the goods you're selling (human-readable description, unit price, etc.)
order_no: 1
order_date: "2023-09-29"
-manifest:
+items:
-
catalog_no: 3
qty: 2
@@ -43,4 +43,4 @@ ship_to: |
## License
This software is released by Magenta Stripe Media under the terms of a
-2-clause BSD-style license. Refer to the LICENSE document.
+2-clause BSD-style license. Please refer to the LICENSE document.
diff --git a/doc/manifest_format.md b/doc/manifest_format.md
new file mode 100644
index 0000000..472367b
--- /dev/null
+++ b/doc/manifest_format.md
@@ -0,0 +1,65 @@
+# Magenta Stripe Media `packingslip` Documentation
+
+## Manifest file format
+
+Among the data which the `packingslip` tool takes as input is YAML file
+called the **manifest**. The manifest contains all of the data that is
+unique to a specific purchase: the exact items ordered, the address to which
+they will be shipped, etc.
+
+### Keys
+
+At the top level, the manifest is a single [mapping][1] which describes the
+particulars of the shipment.
+
+[1]: https://yaml.org/spec/1.2.2/#mapping
+
+The manifest MUST have the following keys:
+
+- `order_no` -- a unique number for your company's bookkeeping.
+- `order_date` -- the date on which the customer placed the order.
+- `items` -- a sequence of mappings which described the individual
+ line-items and the quantity ordered of each (described below)
+- `bill_to` -- the billing address for the order
+- `ship_to` -- the shipping address for the order
+
+Each individual item in the sequence of `items` is mapping with the
+following keys:
+
+- `catalog_no` -- the ID for the particular item
+- `qty` -- the quantity ordered for this particular item
+
+
+### Example manifest
+
+```yaml
+---
+order_no: 1
+order_date: "2023-09-29"
+
+items:
+ -
+ catalog_no: 3
+ qty: 2
+ -
+ catalog_no: 5
+ qty: 1
+
+bill_to: |
+ Perseus Floof
+ 57345 Calamity Court
+ Goalla Gumpy, RI 19535
+ United States
+
+ship_to: |
+ Boris M. Q. Felicity III
+ 10 Decimal Way
+ Charming, WY 79345
+ United States
+```
+
+
+## License
+
+This software is released by Magenta Stripe Media under the terms of a
+2-clause BSD-style license. Please refer to the LICENSE document.
diff --git a/packingslip.rb b/packingslip.rb
index 7373222..a5e6513 100644
--- a/packingslip.rb
+++ b/packingslip.rb
@@ -2,6 +2,8 @@
# MAGENTA STRIPE MEDIA
# Packing Slip Generator Tool
#
+# Charlotte Koch <charlotte@magentastripe.com>
+#
require 'optparse'
require 'prawn'
@@ -106,7 +108,7 @@ class MagentaStripeMedia::Manifest
@business_info = YAML.load(File.read(kwargs[:business_info]))
details = YAML.load(File.read(kwargs[:manifest_file]))
- @items = details["manifest"].map do |data|
+ @items = details["items"].map do |data|
catalog_no = sprintf("MSM-%05d", data["catalog_no"])
the_product = @catalog.detect { |product| product["CATALOG-NO"] == catalog_no }