{ "info": { "author": "Sean Patrick Franklin", "author_email": "sean.patrick516@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6" ], "description": "### What's new in v1.0.2\n\n* Improved parsing of easydollar.usd() to allow commas (eg '$1,000.00')\n* Changed the output of USD.__repr__ to improve readability\n* Fixed a major logical error in USD.distribute(). It should now function as intended.\n\n#### Example\n```python\ncash = usd('$5,000.67')\nprint(repr(cash)) # Output: USD(dollars=5000, cents=67)\n```\n\n\n# easydollar | py\n###### written by Sean Franklin (sean.patrick516@gmail.com)\n\n```\npip install easydollar\n```\n\nFloating-Point values should **not** be used in money calculations.\nPython's **Decimal** or *BigDecimal* in Java are a bit clunky to use for quick\nprototyping.\n\nThis module is useful for **str**-parsed US-Dollar amounts (from user input, or a .*txt*/.*csv*/.*xls*)\n\n\nThis is the **wrong** module for cent calcuations that need three or more decimal-point places (like gas prices or some APR calculations)\n\n\n\n**Note**\n\"Instantiating a **USD** with a **float**\" is a feature intentionally left out. Input like 50.20 actually becomes *50.2* which then becomes *$50.02*\n..which is obviously incorrect.\n\n\n\n## How to use the USD type\n\n**Note**\nYou can see the output of all the below examples by writing\n```python\nimport easydollar.examples\n```\n\n#### How to import\nIt is recommended you use the **lower-case** *usd()*\nto instantiate USD instances.\n\n*usd()* casts a **str** to a **USD** instance.\n\n```python\nfrom easydollar.USD import usd\n```\n\n#### Add cash amounts\n\n*Example 1*\n```python\nhusband_income = usd('55000.00')\n\n# if it's a whole dollar amount, the decimal-point is optional.\nwife_income = usd('62000')\n\nhousehold_income = husband_income + wife_income\n\nprint(f'Total household income: {household_income}\\n')\n```\n\n*Example 2*\n```python\n# USD instances will implicitly roll over cents into dollars when cast to a string.\nmoney1 = usd('1.50')\nmoney2 = usd('0.50')\ntotal = money1 + money2\nprint (f'Dollar addition: {money1} + {money2} = {total}')\n\nprint (f\"Output of usd('0.5255') = {usd('0.5255')}\") # Outputs \"$52.55\"\nprint(f\"Output of usd('1000575.100') = {usd('1000575.100')}\") # Outputs \"$1,000,576.00\"\n```\n\n\n#### Making change from a transaction\n\n```python\nprice = usd('56.60')\n\npaid = usd('60.00')\n\nchange = paid - price\n\nprint(f'Price: {price}')\nprint(f'Paid: {paid}')\nprint (f'Change due: {change}')\n```\n\n\n## IMPORTANT!\nThe multiply operator on the USD object is a \"scale\" operation (only accepts a whole number)\n*You can't multiply two USD's together.*\n\n```python\npayrate = usd('15.00')\nhours_worked = 40\n\npaycheck = payrate * hours_worked\n\nprint(f'This weeks earnings: {paycheck}')\n```\n\n\n#### Division, and Interest Multiplication \n\nThe divide operator in **USD** is a *distribution* function.\n\nSimilar to the *multiply* operator, a USD instance can only be \"divided\" by a whole number.\n\n## IMPORTANT!\nThe division operator is not a *true division* (this would involve using floating-point values in some cases.) Instead, it invokes USD's 'distribute' method.\n\n*USD.distribute(n)* distributes the *USD*-instance's value among *n* and returns a **list** of **USD**\n\nIf you were to sum the elements of the list, you would have\nthe pre-*distribute()* value **exactly**\n\nThe divide \"/\" operator is **only** a shorthand for *my_usd.distribute(n)[0]*\n\n## IMPORTANT!\nIf you add the result of the \"/\" operator *n* times, you **might not**\nget the original value.\n\n```python\nloan_amount = usd('10653.26')\n\ninterest = 21 # 21 percent (21%)\n\ntotal_loan_interest = loan_amount.interest(interest)\n\nterm = 60\n\nmonthly_principle = loan_amount / term\nmonthly_interest = total_loan_interest / term\n\nfirst_payment = monthly_interest + monthly_principle\n\nprint('~~ Loan Issued. ~~')\nprint(f'Loan Amount: {loan_amount}')\nprint(f'Interest: {interest}%')\nprint(f'Term: {term} months')\nprint(f'Total interest to be paid over term: {total_loan_interest}\\n')\n\nprint(f'Principle monthly: {monthly_principle}')\nprint(f'Interest monthly: {monthly_interest}\\n')\nprint(f'First payment due: {first_payment}')\n```\n\nUsing the division operator here is okay, because this is a calculation of the first payment.\nIt is equivilent to \n```python\nmonthly_principle = loan_amount.distribute(term)[0]\n```\n\nTo find the current payment, you could do:\n```python\ncurrent_payment = my_usd.distribute(total_term)[payments_already_made]\n```\nor\n```python\ncurrent_payment = my_usd.distribute(remaining_term)[0]\n```\n\n*A feature to streamline this is being worked on.*\n\n\n## Other features of note:\n\n\n#### with_interest(percent)\n```python\nappreciated_value = my_usd.with_interest(50) # 50% appreciation\n```\n\n#### apply_interest(percent)\n```python\nmy_usd.apply_interest(0.6) # Applies 0.6% interest to my_usd\n```\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SeanCPP/easydollar", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "easydollar", "package_url": "https://pypi.org/project/easydollar/", "platform": "", "project_url": "https://pypi.org/project/easydollar/", "project_urls": { "Homepage": "https://github.com/SeanCPP/easydollar" }, "release_url": "https://pypi.org/project/easydollar/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "A simple, light-weight data type for handling cash (in USD)", "version": "1.0.2" }, "last_serial": 4202029, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "78f24fc5d06b862a484b281e4aad31e3", "sha256": "6968a295df810883a55e57bba14c3bba055623c5facebe8c96028b5a187d2c1c" }, "downloads": -1, "filename": "easydollar-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "78f24fc5d06b862a484b281e4aad31e3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5671, "upload_time": "2018-08-18T15:00:44", "url": "https://files.pythonhosted.org/packages/20/95/0bee72db6e72b5183c153ba73d00c6fa9dee16f5a52c8ac4153b5f493ba8/easydollar-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "199d9f962f16fdfebf23be53e406c0dd", "sha256": "8927b2321bccf655b70d1623eb1a2375e0b2ddfb9c5b70048cba9dfad7460d59" }, "downloads": -1, "filename": "easydollar-1.0.0.tar.gz", "has_sig": false, "md5_digest": "199d9f962f16fdfebf23be53e406c0dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4793, "upload_time": "2018-08-18T15:00:46", "url": "https://files.pythonhosted.org/packages/31/85/dd552e74a49fe05a897840a91437fdbfa4a5c07ab63fd1d34102f11c6b1e/easydollar-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "d8d8fbc37d6b20d2af66b6835624f808", "sha256": "30f4741c02d5e7343412fe8cb0c35693029cf2d588316769b4e26ff1e68a2fab" }, "downloads": -1, "filename": "easydollar-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d8d8fbc37d6b20d2af66b6835624f808", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5805, "upload_time": "2018-08-20T18:20:43", "url": "https://files.pythonhosted.org/packages/09/5a/2008b2a43cabea0547a2d7a4f1e459f3dcd297b4694e58a1ccb81fc9b535/easydollar-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dda51149468fac460f8d2892d834464f", "sha256": "f5e57837a53d08ae0f6fdf8284306b24470c3e64b17735dfe5cc8d2d95c7e24b" }, "downloads": -1, "filename": "easydollar-1.0.1.tar.gz", "has_sig": false, "md5_digest": "dda51149468fac460f8d2892d834464f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4968, "upload_time": "2018-08-20T18:20:45", "url": "https://files.pythonhosted.org/packages/ba/6b/6ab07704a854fb5da9b2c754d9cf2e584d852a8ab9301fdab29de5d442a1/easydollar-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "b667fb848c21e67f5248f3e701b5dddc", "sha256": "05f50fd0466a26d4ddbf2b95c0dbb0158e14abcf83bf00a1ab6ebc235c09daf9" }, "downloads": -1, "filename": "easydollar-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b667fb848c21e67f5248f3e701b5dddc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5862, "upload_time": "2018-08-24T02:07:33", "url": "https://files.pythonhosted.org/packages/5b/13/34b4206023728547f266a09290b06e27f97a0efa26ba2130506394affc0e/easydollar-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d728da279145cf8937455b4a010dfc08", "sha256": "42a3f2353219d39d2ac150b8a1aa0cc53c690c9158bb21652403ac4ee354f7d4" }, "downloads": -1, "filename": "easydollar-1.0.2.tar.gz", "has_sig": false, "md5_digest": "d728da279145cf8937455b4a010dfc08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5017, "upload_time": "2018-08-24T02:07:35", "url": "https://files.pythonhosted.org/packages/c2/a3/6a9c5e1b5e757ef092aaf3f690bf202ed77408f88ec6f37fc04d8509bed0/easydollar-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b667fb848c21e67f5248f3e701b5dddc", "sha256": "05f50fd0466a26d4ddbf2b95c0dbb0158e14abcf83bf00a1ab6ebc235c09daf9" }, "downloads": -1, "filename": "easydollar-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b667fb848c21e67f5248f3e701b5dddc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5862, "upload_time": "2018-08-24T02:07:33", "url": "https://files.pythonhosted.org/packages/5b/13/34b4206023728547f266a09290b06e27f97a0efa26ba2130506394affc0e/easydollar-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d728da279145cf8937455b4a010dfc08", "sha256": "42a3f2353219d39d2ac150b8a1aa0cc53c690c9158bb21652403ac4ee354f7d4" }, "downloads": -1, "filename": "easydollar-1.0.2.tar.gz", "has_sig": false, "md5_digest": "d728da279145cf8937455b4a010dfc08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5017, "upload_time": "2018-08-24T02:07:35", "url": "https://files.pythonhosted.org/packages/c2/a3/6a9c5e1b5e757ef092aaf3f690bf202ed77408f88ec6f37fc04d8509bed0/easydollar-1.0.2.tar.gz" } ] }