PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Ballpark Orders
# - from a voice of experience in fintech
#
# This demonstrates best practices when
# performing financial computations.
# I learned these principles through
# developing software for:
#
# * magazine subscription fulfillment
# * trading tools for a hedge fund
# * check processing for numerous banks & CUs
# * credit card processing
# * general ledger
# * enterprise management
#
# Here are the relevant principles:
#
# 1. Maintain all values as integers.
# 2. Internal amounts are all in cents.
# 3. Calculate price total and tax separately.
# 4. Handle percentages with precision.
# 5. Round to cents with Banker's Round.
# 6. Only convert to dollars for display.
- - - - -
# Define menu lookup with prices in cents
menu = {
"Water": 400, # $ 4.00
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run