From 7928a685c88554fff52a96e0d294fed172a1e012 Mon Sep 17 00:00:00 2001 From: Tyler Matteson Date: Sun, 20 Jan 2019 09:55:44 -0500 Subject: [PATCH] Feat: US Regional module, added test, changed address template reference to convention --- .../irs_1099_form/irs_1099_form.json | 40 ++++++++-------- .../united_states/address_template.html | 4 ++ .../united_states/test_united_states.py | 48 +++++++++++++++++++ 3 files changed, 72 insertions(+), 20 deletions(-) create mode 100644 erpnext/regional/united_states/address_template.html create mode 100644 erpnext/regional/united_states/test_united_states.py diff --git a/erpnext/regional/print_format/irs_1099_form/irs_1099_form.json b/erpnext/regional/print_format/irs_1099_form/irs_1099_form.json index 1270427ad1..ce8c44a9a1 100644 --- a/erpnext/regional/print_format/irs_1099_form/irs_1099_form.json +++ b/erpnext/regional/print_format/irs_1099_form/irs_1099_form.json @@ -1,23 +1,23 @@ [ { - "align_labels_right": 0, - "css": "", - "custom_format": 1, - "default_print_language": "en", - "disabled": 0, - "doc_type": "Supplier", - "docstatus": 0, - "doctype": "Print Format", - "font": "Default", - "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \"
\\t\\t\\t\\t

TAX Invoice
{{ doc.name }}\\t\\t\\t\\t

\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name\", \"label\": \"Customer Name\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name_in_arabic\", \"label\": \"Customer Name in Arabic\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"posting_date\", \"label\": \"Date\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"company_trn\", \"label\": \"Company TRN\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company_address_display\", \"label\": \"Company Address\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"item_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"200px\"}, {\"print_hide\": 0, \"fieldname\": \"uom\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_code\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"items\", \"label\": \"Items\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"label\": \"Total\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"charge_type\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"row_id\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"account_head\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"cost_center\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"300px\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_amount_after_discount_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_tax_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_total\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_tax_amount_after_discount_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"item_wise_tax_detail\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"taxes\", \"label\": \"Sales Taxes and Charges\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"grand_total\", \"label\": \"Grand Total\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"in_words\", \"align\": \"left\", \"label\": \"In Words\"}]", - "html": "
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n \n
PAYER'S name, street address, city or town, state or province, country, ZIP
or foreign postal code, and telephone no.
\n\t{{company if company else \"\"}}
\n\t{{payer_street_address if payer_street_address else \"\"}}\n
1 RentsOMB No. 1545-0115
2018
Form 1099-MISC
Miscellaneous Income
2 Royalties
3 Other Income
\n\t{{payments if payments else \"\"}}\n\t
4 Federal Income tax withheldCopy A
For
Internal Revenue
Service Center

File with Form 1096
PAYER'S TIN
\n\t{{company_tin if company_tin else \"\"}}\n\t
RECIPIENT'S TIN

\n {{tax_id if tax_id else \"None\"}}\n
Fishing boat proceeds6 Medical and health care payments
RECIPIENT'S name
\n {{supplier if supplier else \"\"}}\n
7 Nonemployee compensation
\n\t
Substitute payments in lieu of dividends or interestFor Privacy Act
and Paperwork
Reduction Act
Notice, see the
2018 General
Instructions for
Certain
Information
Returns.
Street address (including apt. no.)
\n\t{{recipient_street_address if recipient_street_address else \"\"}}\n\t
$___________$___________
9 Payer made direct sales of
$5,000 or more of consumer products
to a buyer
(recipient) for resale
10 Crop insurance proceeds
City or town, state or province, country, and ZIP or foreign postal code
\n\t{{recipient_city_state if recipient_city_state else \"\"}}\n
$___________
1112
Account number (see instructions)FACTA filing
requirement
2nd TIN not.13 Excess golden parachute payments
$___________
14 Gross proceeds paid to an
attorney
$___________
15a Section 409A deferrals15b Section 409 income16 State tax withheld17 State/Payer's state no.18 State income
$$$$
Form 1099-MISC Cat. No. 14425J www.irs.gov/Form1099MISC Department of the Treasury - Internal Revenue Service
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{supplier if supplier else \"\"}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n \n
PAYER'S name, street address, city or town, state or province, country, ZIP
or foreign postal code, and telephone no.
\n {{company if company else \"\"}}
\n \t{{payer_street_address if payer_street_address else \"\"}}
1 RentsOMB No. 1545-0115
2018
Form 1099-MISC
Miscellaneous Income
2 Royalties
3 Other Income
\n\t{{payments if payments else \"\"}}\n\t
4 Federal Income tax withheldCopy 1
For State Tax
Department
PAYER'S TIN
\n\t{{company_tin if company_tin else \"\"}}\n\t
RECIPIENT'S TIN
\n\t{{tax_id if tax_id else \"\"}}\n\t
Fishing boat proceeds6 Medical and health care payments
RECIPIENT'S name7 Nonemployee compensation
\n\t
Substitute payments in lieu of dividends or interest
Street address (including apt. no.)
\n\t{{recipient_street_address if recipient_street_address else \"\"}}\n\t
$___________$___________
9 Payer made direct sales of
$5,000 or more of consumer products
to a buyer
(recipient) for resale
10 Crop insurance proceeds
City or town, state or province, country, and ZIP or foreign postal code
\n\t{{recipient_city_state if recipient_city_state else \"\"}}\n\t
$___________
1112
Account number (see instructions)FACTA filing
requirement
2nd TIN not.13 Excess golden parachute payments
$___________
14 Gross proceeds paid to an
attorney
$___________
15a Section 409A deferrals15b Section 409 income16 State tax withheld17 State/Payer's state no.18 State income
$$$$
Form 1099-MISC Cat. No. 14425J www.irs.gov/Form1099MISC Department of the Treasury - Internal Revenue Service
\n
\n", - "line_breaks": 0, - "modified": "2018-10-08 14:56:56.912851", - "module": "Regional", - "name": "IRS 1099 Form", - "print_format_builder": 1, - "print_format_type": "Server", - "show_section_headings": 0, - "standard": "No" + "align_labels_right": 0, + "css": "", + "custom_format": 1, + "default_print_language": "en", + "disabled": 0, + "doc_type": "Supplier", + "docstatus": 0, + "doctype": "Print Format", + "font": "Default", + "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \"
\\t\\t\\t\\t

TAX Invoice
{{ doc.name }}\\t\\t\\t\\t

\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name\", \"label\": \"Customer Name\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name_in_arabic\", \"label\": \"Customer Name in Arabic\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"posting_date\", \"label\": \"Date\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"company_trn\", \"label\": \"Company TRN\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company_address_display\", \"label\": \"Company Address\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"item_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"200px\"}, {\"print_hide\": 0, \"fieldname\": \"uom\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_code\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"items\", \"label\": \"Items\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"label\": \"Total\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"charge_type\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"row_id\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"account_head\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"cost_center\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"300px\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"tax_amount_after_discount_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_tax_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_total\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"base_tax_amount_after_discount_amount\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"item_wise_tax_detail\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"taxes\", \"label\": \"Sales Taxes and Charges\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"grand_total\", \"label\": \"Grand Total\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"in_words\", \"align\": \"left\", \"label\": \"In Words\"}]", + "html": "
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n \n
PAYER'S name, street address, city or town, state or province, country, ZIP
or foreign postal code, and telephone no.
\n\t{{company if company else \"\"}}
\n\t{{payer_street_address if payer_street_address else \"\"}}\n
1 RentsOMB No. 1545-0115
2018
Form 1099-MISC
Miscellaneous Income
2 Royalties
3 Other Income
\n\t{{payments if payments else \"\"}}\n\t
4 Federal Income tax withheldCopy A
For
Internal Revenue
Service Center

File with Form 1096
PAYER'S TIN
\n\t{{company_tin if company_tin else \"\"}}\n\t
RECIPIENT'S TIN

\n {{tax_id if tax_id else \"None\"}}\n
Fishing boat proceeds6 Medical and health care payments
RECIPIENT'S name
\n {{supplier if supplier else \"\"}}\n
7 Nonemployee compensation
\n\t
Substitute payments in lieu of dividends or interestFor Privacy Act
and Paperwork
Reduction Act
Notice, see the
2018 General
Instructions for
Certain
Information
Returns.
Street address (including apt. no.)
\n\t{{recipient_street_address if recipient_street_address else \"\"}}\n\t
$___________$___________
9 Payer made direct sales of
$5,000 or more of consumer products
to a buyer
(recipient) for resale
10 Crop insurance proceeds
City or town, state or province, country, and ZIP or foreign postal code
\n\t{{recipient_city_state if recipient_city_state else \"\"}}\n
$___________
1112
Account number (see instructions)FACTA filing
requirement
2nd TIN not.13 Excess golden parachute payments
$___________
14 Gross proceeds paid to an
attorney
$___________
15a Section 409A deferrals15b Section 409 income16 State tax withheld17 State/Payer's state no.18 State income
$$$$
Form 1099-MISC Cat. No. 14425J www.irs.gov/Form1099MISC Department of the Treasury - Internal Revenue Service
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{supplier if supplier else \"\"}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n\n \n
PAYER'S name, street address, city or town, state or province, country, ZIP
or foreign postal code, and telephone no.
\n {{company if company else \"\"}}
\n \t{{payer_street_address if payer_street_address else \"\"}}
1 RentsOMB No. 1545-0115
2018
Form 1099-MISC
Miscellaneous Income
2 Royalties
3 Other Income
\n\t{{payments if payments else \"\"}}\n\t
4 Federal Income tax withheldCopy 1
For State Tax
Department
PAYER'S TIN
\n\t{{company_tin if company_tin else \"\"}}\n\t
RECIPIENT'S TIN
\n\t{{tax_id if tax_id else \"\"}}\n\t
Fishing boat proceeds6 Medical and health care payments
RECIPIENT'S name7 Nonemployee compensation
\n\t
Substitute payments in lieu of dividends or interest
Street address (including apt. no.)
\n\t{{recipient_street_address if recipient_street_address else \"\"}}\n\t
$___________$___________
9 Payer made direct sales of
$5,000 or more of consumer products
to a buyer
(recipient) for resale
10 Crop insurance proceeds
City or town, state or province, country, and ZIP or foreign postal code
\n\t{{recipient_city_state if recipient_city_state else \"\"}}\n\t
$___________
1112
Account number (see instructions)FACTA filing
requirement
2nd TIN not.13 Excess golden parachute payments
$___________
14 Gross proceeds paid to an
attorney
$___________
15a Section 409A deferrals15b Section 409 income16 State tax withheld17 State/Payer's state no.18 State income
$$$$
Form 1099-MISC Cat. No. 14425J www.irs.gov/Form1099MISC Department of the Treasury - Internal Revenue Service
\n
\n", + "line_breaks": 0, + "modified": "2018-10-08 14:56:56.912851", + "module": "Regional", + "name": "IRS 1099 Form", + "print_format_builder": 1, + "print_format_type": "Server", + "show_section_headings": 0, + "standard": "No" } -] \ No newline at end of file +] diff --git a/erpnext/regional/united_states/address_template.html b/erpnext/regional/united_states/address_template.html new file mode 100644 index 0000000000..089315e4e4 --- /dev/null +++ b/erpnext/regional/united_states/address_template.html @@ -0,0 +1,4 @@ +{{ address_line1 }}
+{% if address_line2 %}{{ address_line2 }}
{% endif -%} +{{ city }}, {% if state %}{{ state }}{% endif -%}{% if pincode %} {{ pincode }}
{% endif -%} +{% if country != "United States" %}{{ country|upper }}{% endif -%} diff --git a/erpnext/regional/united_states/test_united_states.py b/erpnext/regional/united_states/test_united_states.py new file mode 100644 index 0000000000..3c768b7b0b --- /dev/null +++ b/erpnext/regional/united_states/test_united_states.py @@ -0,0 +1,48 @@ +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt +from __future__ import unicode_literals +import frappe +import unittest +from erpnext.regional.report.irs_1099.irs_1099 import execute as execute_1099_report + + +class TestUnitedStates(unittest.TestCase): + def test_irs_1099_custom_field(self): + doc = frappe.new_doc("Supplier") + doc.supplier_name = "_US 1099 Test Supplier" + doc.supplier_group = "Services" + doc.supplier_type = "Company" + doc.country = "United States" + doc.tax_id = "04-1234567" + doc.irs_1099 = 1 + doc.save() + frappe.db.commit() + supplier = frappe.get_doc('Supplier', "_US 1099 Test Supplier") + self.assertEqual(supplier.irs_1099, 1) + + def test_irs_1099_report(self): + make_payment_entry_to_irs_1099_supplier() + filters = frappe._dict({"fiscal_year": "2016", "company": "_Test Company"}) + columns, data = execute_1099_report(filters) + print(columns, data) + expected_row = {'supplier': '_US 1099 Test Supplier', + 'supplier_group': 'Services', + 'payments': 100.0, + 'tax_id': '04-1234567'} + self.assertEqual(data, expected_row) + + +def make_payment_entry_to_irs_1099_supplier(): + pe = frappe.new_doc("Payment Entry") + pe.payment_type = "Pay" + pe.company = "_Test Company" + pe.posting_date = "2016-01-10" + pe.paid_from = "_Test Bank USD - _TC" + pe.paid_to = "_Test Bank - _TC" + pe.paid_amount = 100 + pe.received_amount = 100 + pe.reference_no = "For IRS 1099 testing" + pe.reference_date = "2016-01-10" + pe.party_type = "Supplier" + pe.party = "_US 1099 Test Supplier" + pe.save()