cam32

Top-level module of cam32 package.

cam32.__version__

PyCAM32’s version string.

cam32.metadata

sqlalchemy.MetaData instance, which presumably has been reflected from the CAM32 database.

cam32.get_table_names()

Returns a sorted list of table names found in the database. This exists mostly for ad-hoc convenience, e.g. in a python shell.

Session

class cam32.Session(*args, **kwargs)

A SQLAlchemy-based session to the database.

Note

This Session class overrides the default flush() method to prevent any attempts to write to the database from actually being made. This is done simply to avoid “accidents” whereby writing is unintentionally attempted, in turn causing SQLBase security to raise an exception.

Customer(customer_number)

Convenience function to retrieve a cam32.Customer by its number.

Department(department_number)

Convenience function to retrieve a cam32.Department by its number.

DepartmentClass(department_number, class_number)

Convenience function to retrieve a cam32.DepartmentClass by its number and that of its department.

DepartmentSubclass(department_number, class_number, subclass_number)

Convenience function to retrieve a cam32.DepartmentSubclass by its number and those of its department and class.

InventoryItem(item_number)

Convenience function to retrieve a cam32.InventoryItem by its number.

Invoice(store_number, invoice_number)

Convenience function to retrieve a cam32.SalesLogHeader by its number and that of its store.

PurchaseOrder(store_number, order_number)

Convenience function to retrieve a cam32.PurchaseOrder by its number and that of its store.

Store(store_number)

Convenience function to retrieve a cam32.Store by its number.

Vendor(vendor_number)

Convenience function to retrieve a cam32.Vendor by its number.

Classes

These represent various types of data found in the CAM32 database.

AuthorizedUser

class cam32.AuthorizedUser(**kwargs)

Represents an authorized user within a customer account.

activation_date

The activation date for the user.

allow_check

Whether the user may pay via check.

allow_store_charge

Whether the user may pay via store charge.

customer_number

The customer number to which the user belongs.

expiration_date

The expiration date for the user.

first_name

The user’s first name.

last_name

The user’s last name.

middle_name

The user’s middle name.

name_suffix

The user’s name suffix.

user_id

The ID of the user.

Customer

class cam32.Customer(**kwargs)

Represents a customer.

address1

First line of the customer’s address.

address2

The second line of the customer’s address.

authorized_users

A list of cam32.AuthorizedUser instances attached to the customer.

birth_date

The customer’s birth date.

Note

This attribute’s value is not formatted in any way, but comes back exactly as it exists in the database. This means that it is a string with no mask applied, e.g. a birthday of 1978-04-20 will come back as "042078". See cam32.Customer.get_birth_date() for a way to retrieve a true datetime.date instance.

birth_day

The “day” portion of the cam32.Customer.birth_date as an integer, or None if the underlying data is missing.

birth_month

The “month” portion of the cam32.Customer.birth_date as an integer, or None if the underlying data is missing.

birth_year

The assumed year portion of the cam32.Customer.birth_date.

This value is “guessed” upon inspection of the birth_date attribute, since the underlying data has only 2 digits for the year, in classic “Y2K” style.

If the birth_date value doesn’t even include a year portion, then this attribute will return None. Otherwise it will return an integer according to the following heuristic:

If the year value within the context of the current century would equate to a year later than the current one, then it is assumed to belong to the previous century. Otherwise, i.e. if the year within the context of the current century is still less than or equal to the current actual year, then the current century is assumed.

charge_type

The customer’s “charge type”. This will be one of the following values:

  • C = Charge Only
  • M = Mail List Only
  • B = Both

Note

This is not to be confused with the cam32.Customer.type!

city

The city in which the customer lives.

code

The customer’s “code”. This is a user-defined field.

codes

A list of cam32.CustomerCode instances attached to the customer.

company_name

The name of the company with which the customer is associated.

credit_balance

The customer’s account balance.

credit_limit

The customer’s credit limit for store charges. Note that if this is set to zero, the customer will not be allowed to do store charges at all.

customer_number

The customer’s number.

discount_percent

The percentage by which the customer’s purchases are discounted.

effective_date

The effective starting date for the cam32.Customer.recurring_amount, if applicable.

email_address

The customer’s email address.

get_birth_date(year=None, month=None, day=None)

Convenience method to retrieve a datetime.date instance from some date parts. For each parameter, the current customer’s attribute will be used if no value is explicitly provided.

last_purchase_date

The last date on which the customer made a purchase.

late_percent

According to CAM32’s tool tip, this is the annual percentage for late charges.

mail_code

The customer’s mail code (or mail type).

name

The customer’s (full) name.

note_lines

A list of cam32.CustomerNoteLine objects attached to this customer.

This attribute invokes a query which is not cached, FYI.

notes

A list of cam32.CustomerNote objects attached to this customer.

This attribute invokes a query which is not cached, FYI.

phone_number

The customer’s phone number.

price_code

The pricing code for the customer. This attribute’s meaning depends on its value:

If the value is between 1 and 6 inclusive, it corresponds to an inventory price level.

If the value is between 11 to 24 inclusive, it corresponds with one of the pricing matrices found in System Definition -> Define Pricing Matrix.

purchaser_name_required

Boolean indicating whether or not the cashier will be prompted to enter a “purchaser name” when starting a transaction sold to this customer.

recurring_amount

An amount to be applied to the customer’s account on a recurring (presumably monthly) basis.

sex

The customer’s gender. This will be one of the following values:

  • M = Male
  • F = Female
  • N = Not Applicable
state

The state in which the customer lives.

tax_percent

The tax rate for the customer.

According to CAM32’s tool tip for this field, the value may be interpreted in one of two ways:

Tax Level:
If the value is a whole number between 1 and 9 inclusive, then it should be taken to represent one of the levels found in System Definition -> Point of Sale -> Sales Tax Categories.
Tax Percentage:
Any other value is assumed to be a literal percentage amount.
terms

The number of days a customer is allowed to defer payment on an invoice.

According to CAM32’s tool tip for this field, a value of 99 is assumed to mean C.O.D.

type

The customer’s “type”. This will be one of the following values:

  • B = Balance Forward
  • O = Open Item

(See the CAM32 documentation for a somewhat reasonable explanation of these terms.)

wholesale

Boolean indicating whether or not the customer is considered a “wholesale” customer. If True, then sales to the customer will involve “wholesale” invoices.

zip_code

The customer’s ZIP code.

CustomerCode

class cam32.CustomerCode(**kwargs)

Represents a “custom code” for a customer.

customer_number

The customer number with which the code is associated.

data

The data (i.e. actual value) of the code.

sequence_number

The sequence number (i.e. ordinal) for the code.

CustomerNote

class cam32.CustomerNote(customer, lines=[], **kwargs)

Represents a (possibly multi-line) note attached to a customer.

customer_number

The customer number to which the note is attached.

date

The date when the note was first created.

store_number

The store number where the note was first created.

text

The text of the note as a continuous string (i.e. with embedded newline characters, if applicable).

time

The time when the note was first created.

CustomerNoteLine

class cam32.CustomerNoteLine(**kwargs)

Represents a single line within a customer note.

customer_number

The customer number to which the note is attached.

date

The date when the note was first created.

line_number

The line number for this line of the note.

store_number

The store number where the note was first created.

text

The text of this line of the note.

time

The time when the note was first created.

Department

class cam32.Department(**kwargs)

Represents a department within a store.

department_number

The number of the department, unique within the store.

name

The name of the department.

store_number

The store number with which the department is associated.

DepartmentClass

class cam32.DepartmentClass(**kwargs)

Represents a “class” within a department.

class_number

The number of the class, unique within the department.

department_number

The department number with which the class is associated.

description

The description (i.e. name) of the class.

subclasses

A list of cam32.DepartmentSubclass instances belonging to the class.

DepartmentSubclass

class cam32.DepartmentSubclass(**kwargs)

Represents a “subclass” within a class, within a department.

class_

The cam32.DepartmentClass instance to which this subclass belongs.

class_number

The class number with which the subclass is associated.

department_number

The department number with which the subclass is associated.

description

The description (i.e. name) of the subclass.

subclass_number

The number for the subclass, unique within its parent class.

InventoryCrossRef

class cam32.InventoryCrossRef(**kwargs)

An “inventory cross-reference” entry.

These can represent different things, depending on their cam32.InventoryCrossRef.type attribute.

data

The data (i.e. actual value) of the entry.

item

The cam32.InventoryItem with which the entry is associated.

item_number

The item number with which the entry is associated.

sequence_number

The sequence number (i.e. ordinal) for the entry.

This is presumed to be unique within the context of a particular cam32.InventoryCrossRef.type for a particular cam32.InventoryItem.

type

The type of data which the entry represents. This can be one of the following values:

  • 1 = Description
  • 2 = Code Field
  • 3 = Location
  • 4 = UPC (scancode)
  • 5 = Manufacturer Code
  • 6 = Code Field 2 (old UPC)
  • 7 = Vendor Stock Number
vendor_number

The vendor number with which the entry is associated.

InventoryItem

class cam32.InventoryItem(*args, **kwargs)

Represents an item (i.e. product) within the Inventory File.

append

A boolean indicating whether the item is part of an “append” sequence.

append_number

The “append number” (i.e. “quantity price level”) for the item.

The meaning of this attribute will vary somewhat, depending on the value of cam32.InventoryItem.append:

If append is False, then append_number doesn’t actually mean anything and should be ignored.

However, if append is True, then append_number will contain the “quantity price level” setting for the item (found within the item’s Inventory Flag Definition).

base_item_number

The value of this attribute will vary depending on whether or not the item if part of an “append” sequence.

If the item is part of an append sequence, this attribute returns the item number of the base (quantity price level 0) item.

Otherwise, None is returned.

calculate_quantity

A boolean indicating whether the item’s “sold quantity” should be calculated at the POS based on the price of the item.

case_quantity

The case quantity for the item, as an integer.

class_number

The class number to which the item belongs, if applicable.

code

The “code field” for the item, the meaning of which is user-defined.

comments_attached

A boolean indicating whether the item has attached comment(s). See also the cam32.InventoryItem.comments attribute.

comments

Returns a list of cam32.ItemComment instances attached to the item.

Note

This attribute will return whatever is found in the database, regardless of the value of cam32.InventoryItem.comments_attached.

commission

A boolean indicating whether the sales of the item produce a commission.

composite

A boolean indicating whether “composite” scancodes are used with the item.

cost

The (last) cost for the item, as a decimal.Decimal instance rounded to 3 places.

date_added

The date when the item was first added to the database.

delete

A boolean indicating whether the item is marked for deletion.

department_number

The department number to which the item belongs.

description

The description for the item.

discountable

A boolean indicating whether a discount(s) may be applied to the item at the POS.

flex_plan

A boolean indicating whether the item may be purchased with a flexible spending account (FSA).

food_stampable

A boolean indicating whether the item may be purchased with food stamps.

has_long_description

A boolean indicating whether the item has a “long” description.

history_flag

A boolean indicating whether or not “History” is checked within the item’s Inventory Flag Definition.

inventoried

A boolean indicating whether inventory figures are tracked for the item.

item_label_format

The label format number assigned to the item.

item_number

The number for the item, unique within the store.

is_kit

A boolean indicating whether the item is a “kit”.

is_kit_part

A boolean indicating whether the item is part of a “kit”.

kit

Returns a reference to the cam32.Kit instance associated with the item, if any.

kit_parents

Returns a list of cam32.InventoryItem instances (which in turn should have valid cam32.Kit instances associated with them) to which this item belongs.

last_receipt

The date when the item was last received on a purchase order.

last_sold

The date when the item was last sold to a customer.

legal_purchase_age

The minimum age required for a customer to be allowed to purchase the item, if applicable.

location

The location for the item. This field is user-defined.

max_stocking_level

The maximum stocking level for the item.

mfr_part_number

The “manufacturer part number” for the item.

mtd_cog_sold

The month-to-date cost of goods sold (in decimal dollars) for the item.

mtd_quantity_sold

The month-to-date quantity sold (in decimal units) for the item.

mtd_value_sold

The month-to-date value sold (in decimal dollars) for the item.

multi_vendor

A dictionary of cam32.MultiVendor instances for the item, keyed by vendor number.

on_hand

The “balance on hand” figure for the item, as a decimal.Decimal instance rounded to 3 places.

on_order

The “balance on order” figure for the item, as a decimal.Decimal instance rounded to 3 places.

on_sale

A boolean indicating whether the item is on sale (promotion) today.

open_plu

A boolean indicating whether the item is considered an “open PLU”. If it is, the cashier will be prompted to provide a description for the item when it is rang at the POS.

price1

The “level 1” price for the item, as a decimal.Decimal instance rounded to 3 places.

price2

The “level 2” price for the item, as a decimal.Decimal instance rounded to 3 places.

price3

The “level 3” price for the item, as a decimal.Decimal instance rounded to 3 places.

price4

The “level 4” price for the item, as a decimal.Decimal instance rounded to 3 places.

price5

The “level 5” price for the item, as a decimal.Decimal instance rounded to 3 places.

price6

The “level 6” price for the item, as a decimal.Decimal instance rounded to 3 places.

promo_start_date

The start date for the item’s current promotion, if applicable.

promo_stop_date

The ending date for the item’s current promotion, if applicable.

protect_reorder_point

A boolean indicating whether purchasing is allowed to recalculate the reorder point for the item.

rental

A boolean indicating whether the item is a “rental” item.

reorder_point

The reorder point for the item, as an integer.

requested

A boolean indicating whether the item is “requested”.

scale_compulsion

A boolean indicating whether the cashier must be “compelled” to weigh the item with a scale at the POS.

scancodes

A list of scancodes for the item, as strings.

secondary_code

The item’s “code 2 field”, the meaning of which is user-defined.

stocked

A boolean indicating whether the item is stocked within a store.

subclass_number

The subclass number to which the item belongs, if applicable.

tax_flag

A 1-character string containing the item’s tax level, e.g. “N” or “1”.

unit_control

A boolean indicating whether the item falls under unit control.

unit_of_sale

The unit of sale for the item.

This is typically a 2-character value, e.g. “EA” or “LB”.

vendor

The (primary) cam32.Vendor instance with which the item is associated, or None if not applicable.

vendor_number

The (primary) vendor number for the item.

ytd_cog_sold

The year-to-date cost of goods sold (in decimal dollars) for the item.

ytd_quantity_scrapped

The year-to-date quantity scrapped (in integer units) for the item.

ytd_quantity_sold

The year-to-date quantity sold (in decimal units) for the item.

ytd_value_scrapped

The year-to-date value scrapped (in decimal dollars) for the item.

ytd_value_sold

The year-to-date value sold (in decimal dollars) for the item.

ItemComment

class cam32.ItemComment(item_number=None, ordinal=None, print_flag=None, text=None)

Represents a comment attached to a cam32.InventoryItem.

item_number

The item number to which the comment is attached.

ordinal

The ordinal number for the comment (will be between 1 and 4).

print_flag

The print flag for the comment. This will be one of:

  • D - Display at point of sale.
  • P - Print on receipt.
  • B - Display and print at point of sale.
  • N - Do not use at point of sale.
text

The text of the comment.

Kit

class cam32.Kit(item, *args, **kwargs)

Represents a kit item, or more specifically, the kit aspect(s) of an otherwise “normal” instance of cam32.InventoryItem.

item

References the cam32.InventoryItem instance with which the kit is associated.

item_number

Returns the kit’s main item number.

parts

References a list of cam32.KitPart instances which belong to the kit.

replacement_cost

The replacement cost for the kit.

KitData

class cam32.KitData(**kwargs)

Represents a kit data record as it actually exists in the database. (A more Pythonic representation is to be found in the cam32.Kit class.)

item_number

The kit’s main item number.

itemXX_item_number

There are 30 such attributes for each KIT_DATA record. The above attribute name is not actually valid; the real attributes include:

  • item1_item_number
  • item2_item_number
  • ...
  • item30_item_number

Each attribute returns the item number for the kit part.

itemXX_quantity

Same scenario as for cam32.KitData.itemXX_item_number, except returns the kit part’s quantity value.

itemXX_star

Same scenario as for cam32.KitData.itemXX_item_number, except returns the kit part’s “star” value (whatever that is).

record_number

The record number for the kit data record.

replacement_cost

Returns the replacement cost for the kit as a 4-digit decimal.

KitPart

class cam32.KitPart(data, *args, **kwargs)

Represents a part within a cam32.Kit instance.

item

Returns a reference to the cam32.InventoryItem instance associated with the kit part.

item_number

The part’s item number.

kit

References the cam32.Kit instance to which the part belongs.

ordinal

Returns the “ordinal” (or “index”) value from the part’s KIT_DATA record’s field names, i.e. a number between 1 and 30.

quantity

Returns the part’s quantity value.

record_number

Returns the record number value from the KIT_DATA record from whence this part came.

star

Returns the part’s “star” value (whatever that is).

MultiVendor

class cam32.MultiVendor(**kwargs)

Represents a “multi-vendor” entry for a cam32.InventoryItem instance.

An item might have multiple entries, but only one per vendor.

item_number

The item number with which the entry is associated.

last_cost

The cost paid when the product was last received on a purchase order.

price_break1

The cost per unit at level 1.

price_break2

The cost per unit at level 2.

price_break3

The cost per unit at level 3.

price_break4

The cost per unit at level 4.

price_break5

The cost per unit at level 5.

price_break6

The cost per unit at level 6.

price_break7

The cost per unit at level 7.

price_code

The “price code” for the entry.

See the CAM32’s Inventory Control documentation for a semi-confusing explanation of the significance of this field.

quantity_break1

The quantity which must be ordered to qualify for the level 1 price break.

quantity_break2

The quantity which must be ordered to qualify for the level 2 price break.

quantity_break3

The quantity which must be ordered to qualify for the level 3 price break.

quantity_break4

The quantity which must be ordered to qualify for the level 4 price break.

quantity_break5

The quantity which must be ordered to qualify for the level 5 price break.

quantity_break6

The quantity which must be ordered to qualify for the level 6 price break.

quantity_break7

The quantity which must be ordered to qualify for the level 7 price break.

quantity_last_received

The quantity last received on a purchase order.

stock_number

The stock number for the product, specific to a vendor.

suggested_retail

The suggested retail price for the product, specific to a vendor.

vendor

A reference to the cam32.Vendor instance with which the entry is associated.

vendor_number

The vendor number with which the entry is associated.

PDTAdjustment

class cam32.PDTAdjustment(**kwargs)

Represents a product adjustment record when recording inventory with a PDT.

cost

The cost of the product.

counted_balance

Balance-on-hand for the product which was actually counted.

counted_flag

Boolean indicating whether the product has been counted.

item_number

The item number for the adjustment.

posted_flag

Boolean indicating whether the adjustment has been posted.

price

The price of the product.

starting_balance

Balance-on-hand for the product at the time the adjustments table was initialized.

store_number

The store number for the adjustment.

PurchaseOrder

class cam32.PurchaseOrder(**kwargs)

Represents a purchase order, associated with a vendor.

buyer_name

The name of the buyer who submitted the purchase order to the vendor.

confirmation_name

The confirmation name for the purchase order.

date_ordered

The date on which the purchase order was submitted to the vendor.

date_required

The date by which the product contained on the purchase order is required for delivery.

invoice_number

The invoice number for the purchase order.

order_number

The “PO number” for the purchase order.

status

The status of the purchase order. This will be one of:

  • 'U' (unposted)
  • 'O' (posted, open)
  • 'R' (posted and received)
store_number

The store number for the purchase order.

vendor

The cam32.Vendor instance associated with the purchase order.

vendor_number

The vendor number for the purchase order.

PurchaseOrderDetail

class cam32.PurchaseOrderDetail(**kwargs)

Represents a line (detail) item within a purchase order.

case_multiplier

The case multiplier for the product.

case_quantity

The case quantity for the product.

description

The (cached) description for the product.

except_quantity_received

The excepted quantity received for the product.

item_cost

The actual cost for the product.

item_number

The item number for the product.

order_number

The “PO number” for the purchase order.

original_cost

The original (presumably expected) cost for the product, as of purchase order creation (hm, or is it posting?).

original_retail

The original retail price for the product, at the time of purchase order creation (hm, or is it posting?).

quantity_ordered

The quantity ordered for the product.

quantity_received

The quantity received for the product.

reference_number

The reference (line) number for the detail.

retail_price

The retail price for the product.

store_number

The store number for the purchase order.

total_quantity_ordered

The total quantity ordered for the product.

total_quantity_received

The total quantity received for the product.

unit_of_measure

The (cached) unit of measure for the product.

SalesLogHeader

class cam32.SalesLogHeader(**kwargs)

Represents a “sales log header” (also known as an “invoice”) within the database.

bank_cards_amount

The total in dollars of any bank cards tendered as payment.

cash_amount

The total in dollars of any cash tendered as payment.

charge_amount

The total in dollars of any store charge tendered as payment.

check_amount

The total in dollars of any checks tendered as payment.

clerk_name

The name of the sales clerk.

cost_of_sales

The total cost of goods sold on the invoice.

coupon_amount

The total in dollars of any coupons tendered as payment.

customer

The cam32.Customer instance associated with the invoice, or None.

customer_first_name

The first name of the customer.

customer_last_name

The last name of the customer.

customer_number

The customer number for the invoice.

date_time

The date and time for the invoice.

Note

I’m not sure if this timestamp represents the invoice creation or posting time.

invoice_number

The invoice number.

non_tax_amount

The total in dollars of non-taxable goods on the invoice.

register_number

The number of the register station at which the transaction occurred.

resale_number

The resale number for the invoice.

sales_clerk_id

The ID of the sales clerk.

sales_total

The total in dollars of sales on the invoice.

store_number

The store number for the invoice.

subtotal

The pre-tax total in dollars of all goods on the invoice (taxable and otherwise).

tax_amount

The total in dollars of actual tax on the invoice.

taxable_amount

The total in dollars of taxable goods on the invoice.

tender_amount

The total in dollars of all payment tendered.

total_lines

The number of total lines on the invoice.

SalesLogDetail

class cam32.SalesLogDetail(**kwargs)

Represents a line (detail) item on an invoice, or cam32.SalesLogHeader.

class_number

The (cached) class number for the product.

department_number

The (cached) department number for the product.

description

The (cached) description for the product.

extended_price

The calculated “extended” price, i.e. “unit” price multiplied by quantity sold.

Note

Occasionally the value from this simple calculation can differ from that arrived at by CAM32. I’m not sure why it happens, but it’s neither often nor by more than a penny when it does occur.

invoice_number

The invoice number.

item

The cam32.InventoryItem instance associated with the detail, or None if the item no longer exists.

item_number

The item number for the product.

price_paid

The price (per unit) actually paid for the product.

quantity

The quantity of the product which is being sold.

reference_number

The reference (line) number for the detail.

retail_price

The (cached) retail price for the product.

store_number

The store number for the invoice.

subclass_number

The (cached) subclass number for the product.

suggested_price

The (cached) suggested price for the product.

tax_category

The (cached) tax category for the product, as an integer.

unit_cost

The (cached) unit cost for the product.

vendor_number

The (cached) vendor number for the product.

Store

class cam32.Store(**kwargs)

Represents a store.

address

The street address for the store.

city

The city in which the store is located.

email_address

The email address for the store.

fax_number

The fax number for the store.

name

The name for the store.

notes

The “notes” for the store (?).

phone_number

The phone number for the store.

price_level

The price level for the store.

state

The state in which the store is located.

store_number

The store’s number.

zip_code

The ZIP code in which the store is located.

Vendor

class cam32.Vendor(**kwargs)

Represents a vendor.

account_number

The store’s account number with the vendor.

address

The street address for the vendor.

city

The city in which the vendor is located.

contact

The name of the store’s contact within the vendor’s remittance office.

name

The name for the vendor.

phone_number

The phone number for the vendor’s remittance office.

purchase_contact

The name of the vendor’s “purchase contact” (?).

sales_address

The street address for the vendor’s sales office.

sales_city

The city in which the vendor’s sales office is located.

sales_name

The vendor’s “sales name” (?).

sales_phone_number

The phone number for the vendor’s sales office.

sales_state

The state in which the vendor’s sales office is located.

sales_zip_code

The ZIP code in which the vendor’s sales office is located.

state

The state in which the vendor is located.

vendor_number

The vendor’s number.

zip_code

The ZIP code in which the vendor is located.