Merge pull request #16725 from deepeshgarg007/item_dashboard
fix: Item name display issue fix in item dashboard
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 465c283..049a8a0 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@
from erpnext.hooks import regional_overrides
from frappe.utils import getdate
-__version__ = '11.1.6'
+__version__ = '11.1.9'
def get_default_company(user=None):
'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/cashier_closing/cashier_closing.json b/erpnext/accounts/doctype/cashier_closing/cashier_closing.json
index 57a9c7a..14e9070 100644
--- a/erpnext/accounts/doctype/cashier_closing/cashier_closing.json
+++ b/erpnext/accounts/doctype/cashier_closing/cashier_closing.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -15,6 +16,7 @@
"fields": [
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -32,7 +34,7 @@
"label": "Series",
"length": 0,
"no_copy": 0,
- "options": "Cashier-closing-\n",
+ "options": "Cashier-closing-",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -43,10 +45,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -74,10 +78,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -105,10 +111,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -135,10 +143,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -166,10 +176,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -188,7 +200,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -197,10 +209,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -219,7 +233,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -228,10 +242,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -250,7 +266,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -259,10 +275,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -291,10 +309,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -321,10 +341,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -351,6 +373,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -364,7 +387,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-09-03 10:59:54.500567",
+ "modified": "2019-02-19 08:35:23.157327",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Cashier Closing",
@@ -373,7 +396,6 @@
"permissions": [
{
"amend": 0,
- "apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
@@ -399,5 +421,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
- "track_seen": 0
+ "track_seen": 0,
+ "track_views": 0
}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/cashier_closing_payments/cashier_closing_payments.json b/erpnext/accounts/doctype/cashier_closing_payments/cashier_closing_payments.json
index bdfc70f..7f16bea 100644
--- a/erpnext/accounts/doctype/cashier_closing_payments/cashier_closing_payments.json
+++ b/erpnext/accounts/doctype/cashier_closing_payments/cashier_closing_payments.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -14,6 +15,7 @@
"fields": [
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -41,10 +43,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -63,7 +67,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -72,6 +76,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -85,7 +90,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2018-09-02 14:45:36.303520",
+ "modified": "2019-02-19 08:34:20.268037",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Cashier Closing Payments",
@@ -99,5 +104,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
- "track_seen": 0
+ "track_seen": 0,
+ "track_views": 0
}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
index 5a827be..32e49db 100644
--- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
+++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -398,7 +399,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "6",
+ "precision": "9",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -911,7 +912,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2018-08-19 04:08:44.742510",
+ "modified": "2019-02-18 19:00:53.662788",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Journal Entry Account",
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json
index 76fe884..bff995e 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.json
+++ b/erpnext/accounts/doctype/payment_request/payment_request.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -425,7 +426,7 @@
"no_copy": 0,
"options": "currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -1501,7 +1502,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-09-06 14:44:43.563367",
+ "modified": "2019-02-18 18:52:34.203239",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Request",
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index fe99763..ac0cd7e 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -196,8 +196,9 @@
pricing_rule_rate = 0.0
if pricing_rule.currency == args.currency:
pricing_rule_rate = pricing_rule.rate
+
item_details.update({
- "price_list_rate": pricing_rule_rate,
+ "price_list_rate": pricing_rule_rate * args.get("conversion_factor"),
"discount_percentage": 0.0
})
else:
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 263b5bb..b4fd91f 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -9,9 +9,12 @@
this.setup_posting_date_time_check();
this._super(doc);
- // formatter for material request item
- this.frm.set_indicator_formatter('item_code',
- function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" })
+ // formatter for purchase invoice item
+ if(this.frm.doc.update_stock) {
+ this.frm.set_indicator_formatter('item_code', function(doc) {
+ return (doc.qty<=doc.received_qty) ? "green" : "orange";
+ });
+ }
},
onload: function() {
this._super();
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
index c2309b2..6da171f 100644
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json
@@ -293,7 +293,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -321,7 +321,7 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
- "label": "Qty",
+ "label": "Accepted Qty",
"length": 0,
"no_copy": 0,
"oldfieldname": "qty",
@@ -358,7 +358,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -2626,7 +2626,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2019-01-07 16:52:00.749414",
+ "modified": "2019-02-18 19:03:19.250280",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 13ba053..077d995 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -1966,7 +1966,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -5644,7 +5644,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2019-01-07 16:51:53.914523",
+ "modified": "2019-02-18 18:56:51.265257",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
index d6ce115..a95f314 100644
--- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
+++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json
@@ -779,7 +779,7 @@
"no_copy": 0,
"options": "currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -913,7 +913,7 @@
"no_copy": 0,
"options": "Company:company:default_currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -2766,7 +2766,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2019-01-07 16:51:55.018091",
+ "modified": "2019-02-18 18:59:52.223628",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Item",
diff --git a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json
index 438328d..ccdabfe 100644
--- a/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json
+++ b/erpnext/accounts/doctype/sales_invoice_payment/sales_invoice_payment.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -13,6 +14,7 @@
"fields": [
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -40,11 +42,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -72,16 +75,17 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "default": "0.0",
+ "default": "",
"depends_on": "eval:parent.doctype == 'Sales Invoice'",
"fieldname": "amount",
"fieldtype": "Currency",
@@ -97,7 +101,7 @@
"no_copy": 0,
"options": "currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -106,11 +110,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -136,11 +141,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -168,16 +174,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fetch_from": "mode_of_payment.type",
+ "fetch_from": "mode_of_payment.type",
"fieldname": "type",
"fieldtype": "Read Only",
"hidden": 0,
@@ -201,11 +208,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -233,11 +241,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -264,7 +273,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
- "translatable": 0,
+ "translatable": 0,
"unique": 0
}
],
@@ -278,7 +287,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2018-05-16 22:42:52.033991",
+ "modified": "2019-02-18 15:03:59.720469",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Payment",
@@ -292,5 +301,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
- "track_seen": 0
+ "track_seen": 0,
+ "track_views": 0
}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
index 50eed24..f7b9aef 100644
--- a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
+++ b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
@@ -1,5 +1,7 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
@@ -12,6 +14,8 @@
"engine": "InnoDB",
"fields": [
{
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -39,9 +43,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -68,9 +75,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -88,7 +98,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -97,9 +107,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -126,20 +139,21 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
-
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2017-02-17 16:47:04.413420",
+ "modified": "2019-02-18 18:50:44.770361",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Timesheet",
@@ -153,5 +167,6 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
- "track_seen": 0
+ "track_seen": 0,
+ "track_views": 0
}
\ No newline at end of file
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 95cb351..b8c9854 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -495,6 +495,7 @@
values.append(self.filters.get(party_type_field))
if party_type_field=="customer":
+ account_type = "Receivable"
if self.filters.get("customer_group"):
lft, rgt = frappe.db.get_value("Customer Group",
self.filters.get("customer_group"), ["lft", "rgt"])
@@ -529,12 +530,18 @@
or (steam.parent = against_voucher and steam.parenttype = against_voucher_type)
or (steam.parent = party and steam.parenttype = 'Customer')))""".format(lft, rgt))
- if party_type_field=="supplier":
+ elif party_type_field=="supplier":
+ account_type = "Payable"
if self.filters.get("supplier_group"):
conditions.append("""party in (select name from tabSupplier
where supplier_group=%s)""")
values.append(self.filters.get("supplier_group"))
+ accounts = [d.name for d in frappe.get_all("Account",
+ filters={"account_type": account_type, "company": self.filters.company})]
+ conditions.append("account in (%s)" % ','.join(['%s'] *len(accounts)))
+ values += accounts
+
return " and ".join(conditions), values
def get_gl_entries_for(self, party, party_type, against_voucher_type, against_voucher):
diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
index 94d93f6..3c775cd 100644
--- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
+++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.json
@@ -848,7 +848,7 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"print_width": "100px",
@@ -1786,7 +1786,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2019-01-07 16:52:02.125715",
+ "modified": "2019-02-18 18:58:10.351451",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier Quotation Item",
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 0ba47ed..34bbe7b 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -94,6 +94,8 @@
if self.is_return:
self.validate_qty()
+ validate_regional(self)
+
def validate_invoice_documents_schedule(self):
self.validate_payment_schedule_dates()
self.set_due_date()
@@ -1132,3 +1134,7 @@
p_doctype.update_blanket_order()
p_doctype.update_billing_percentage()
p_doctype.set_status()
+
+@erpnext.allow_regional
+def validate_regional(doc):
+ pass
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 7d77f90..ccdd412 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -202,7 +202,8 @@
"validate": "erpnext.portal.doctype.products_settings.products_settings.home_page_is_products"
},
"Sales Invoice": {
- "on_submit": "erpnext.regional.france.utils.create_transaction_log",
+ "on_submit": ["erpnext.regional.france.utils.create_transaction_log", "erpnext.regional.italy.utils.sales_invoice_on_submit"],
+ "on_cancel": "erpnext.regional.italy.utils.sales_invoice_on_cancel",
"on_trash": "erpnext.regional.check_deletion_permission"
},
"Payment Entry": {
@@ -210,7 +211,7 @@
"on_trash": "erpnext.regional.check_deletion_permission"
},
'Address': {
- 'validate': 'erpnext.regional.india.utils.validate_gstin_for_india'
+ 'validate': ['erpnext.regional.india.utils.validate_gstin_for_india', 'erpnext.regional.italy.utils.set_state_code']
},
('Sales Invoice', 'Purchase Invoice', 'Delivery Note'): {
'validate': 'erpnext.regional.india.utils.set_place_of_supply'
@@ -301,5 +302,9 @@
},
'Saudi Arabia': {
'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.united_arab_emirates.utils.update_itemised_tax_data'
+ },
+ 'Italy': {
+ 'erpnext.controllers.taxes_and_totals.update_itemised_tax_data': 'erpnext.regional.italy.utils.update_itemised_tax_data',
+ 'erpnext.controllers.accounts_controller.validate_regional': 'erpnext.regional.italy.utils.sales_invoice_validate',
}
}
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.json b/erpnext/hr/doctype/salary_slip/salary_slip.json
index 76e43d6..c9a5d87 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.json
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.json
@@ -195,7 +195,7 @@
"columns": 0,
"fetch_from": "employee.branch",
"fieldname": "branch",
- "fieldtype": "Link",
+ "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -208,11 +208,11 @@
"no_copy": 0,
"oldfieldname": "branch",
"oldfieldtype": "Link",
- "options": "Branch",
+ "options": "Branch",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
- "read_only": 1,
+ "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
@@ -901,7 +901,7 @@
"no_copy": 0,
"options": "Company:company:default_currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 1,
"read_only": 0,
@@ -1906,7 +1906,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2019-02-12 11:24:20.848207",
+ "modified": "2019-02-18 18:54:36.161027",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Slip",
diff --git a/erpnext/hr/doctype/salary_slip_timesheet/salary_slip_timesheet.json b/erpnext/hr/doctype/salary_slip_timesheet/salary_slip_timesheet.json
index 7a9393c..797f8f7 100644
--- a/erpnext/hr/doctype/salary_slip_timesheet/salary_slip_timesheet.json
+++ b/erpnext/hr/doctype/salary_slip_timesheet/salary_slip_timesheet.json
@@ -1,5 +1,7 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
@@ -11,16 +13,21 @@
"editable_grid": 1,
"fields": [
{
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "time_sheet",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Time Sheet",
"length": 0,
"no_copy": 0,
@@ -30,49 +37,58 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
},
{
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "working_hours",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Working Hours",
"length": 0,
"no_copy": 1,
"permlevel": 0,
- "precision": "3",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
+ "translatable": 0,
"unique": 0
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
-
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2016-07-11 03:28:07.152366",
+ "modified": "2019-02-19 08:33:41.762144",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Slip Timesheet",
@@ -82,7 +98,10 @@
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
+ "show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
- "track_seen": 0
+ "track_changes": 0,
+ "track_seen": 0,
+ "track_views": 0
}
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.json b/erpnext/hr/doctype/salary_structure/salary_structure.json
index ce8b64e..0e47278 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.json
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 1,
@@ -365,7 +366,7 @@
"no_copy": 0,
"options": "Company:company:default_currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -950,7 +951,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-07-24 18:36:25.169098",
+ "modified": "2019-02-18 18:51:53.932518",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Structure",
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 2199491..b1a393b 100755
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -585,4 +585,6 @@
erpnext.patches.v11_0.add_permissions_in_gst_settings
erpnext.patches.v11_1.setup_guardian_role
execute:frappe.delete_doc('DocType', 'Notification Control')
-erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019
\ No newline at end of file
+erpnext.patches.v11_0.remove_barcodes_field_from_copy_fields_to_variants
+erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019
+erpnext.patches.v11_0.make_italian_localization_fields
diff --git a/erpnext/patches/v11_0/make_italian_localization_fields.py b/erpnext/patches/v11_0/make_italian_localization_fields.py
new file mode 100644
index 0000000..fa77149
--- /dev/null
+++ b/erpnext/patches/v11_0/make_italian_localization_fields.py
@@ -0,0 +1,28 @@
+# Copyright (c) 2017, Frappe and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+from erpnext.regional.italy.setup import make_custom_fields, setup_report
+from erpnext.regional.italy import state_codes
+import frappe
+
+
+def execute():
+ company = frappe.get_all('Company', filters = {'country': 'Italy'})
+ if not company:
+ return
+
+ frappe.reload_doc('regional', 'report', 'electronic_invoice_register')
+ make_custom_fields()
+ setup_report()
+
+ # Set state codes
+ condition = ""
+ for state, code in state_codes.items():
+ condition += " when '{0}' then '{1}'".format(frappe.db.escape(state), frappe.db.escape(code))
+
+ if condition:
+ frappe.db.sql("""
+ UPDATE tabAddress set state_code = (case state {condition} end)
+ WHERE country in ('Italy', 'Italia', 'Italian Republic', 'Repubblica Italiana')
+ """.format(condition=condition))
diff --git a/erpnext/patches/v11_0/remove_barcodes_field_from_copy_fields_to_variants.py b/erpnext/patches/v11_0/remove_barcodes_field_from_copy_fields_to_variants.py
new file mode 100644
index 0000000..97ddd41
--- /dev/null
+++ b/erpnext/patches/v11_0/remove_barcodes_field_from_copy_fields_to_variants.py
@@ -0,0 +1,7 @@
+import frappe
+
+def execute():
+ '''Remove barcodes field from "Copy Fields to Variants" table because barcodes must be unique'''
+
+ settings = frappe.get_doc('Item Variant Settings')
+ settings.remove_invalid_fields_for_copy_fields_in_variants()
diff --git a/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json b/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
index b1f7372..a9b3bfb 100644
--- a/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
+++ b/erpnext/projects/doctype/timesheet_detail/timesheet_detail.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@@ -13,6 +14,7 @@
"fields": [
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -44,6 +46,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -75,6 +78,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -105,6 +109,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -136,6 +141,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -166,6 +172,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -197,6 +204,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -230,6 +238,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -260,6 +269,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -278,7 +288,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -292,6 +302,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -325,6 +336,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -355,6 +367,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -388,6 +401,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -420,6 +434,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -450,6 +465,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -482,6 +498,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -512,6 +529,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -545,6 +563,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -575,6 +594,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -607,6 +627,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -637,6 +658,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -669,6 +691,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -700,6 +723,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -718,7 +742,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 1,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -732,6 +756,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -752,7 +777,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 1,
- "precision": "2",
+ "precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -766,6 +791,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -796,6 +822,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -827,6 +854,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -860,6 +888,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -891,6 +920,7 @@
},
{
"allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
@@ -932,7 +962,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2018-05-07 15:12:31.510813",
+ "modified": "2019-02-18 18:55:53.190526",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet Detail",
@@ -944,5 +974,6 @@
"show_name_in_global_search": 0,
"sort_order": "ASC",
"track_changes": 0,
- "track_seen": 0
+ "track_seen": 0,
+ "track_views": 0
}
\ No newline at end of file
diff --git a/erpnext/regional/italy/__init__.py b/erpnext/regional/italy/__init__.py
new file mode 100644
index 0000000..ef1d582
--- /dev/null
+++ b/erpnext/regional/italy/__init__.py
@@ -0,0 +1,79 @@
+# coding=utf-8
+
+fiscal_regimes = [
+ "RF01-Ordinario",
+ "RF02-Contribuenti minimi (art.1, c.96-117, L. 244/07)",
+ "RF04-Agricoltura e attività connesse e pesca (artt.34 e 34-bis, DPR 633/72)",
+ "RF05-Vendita sali e tabacchi (art.74, c.1, DPR. 633/72)",
+ "RF06-Commercio fiammiferi (art.74, c.1, DPR 633/72)",
+ "RF07-Editoria (art.74, c.1, DPR 633/72)",
+ "RF08-Gestione servizi telefonia pubblica (art.74, c.1, DPR 633/72)",
+ "RF09-Rivendita documenti di trasporto pubblico e di sosta (art.74, c.1, DPR 633/72)",
+ "RF10-Intrattenimenti, giochi e altre attività di cui alla tariffa allegata al DPR 640/72 (art.74, c.6, DPR 633/72)",
+ "RF11-Agenzie viaggi e turismo (art.74-ter, DPR 633/72)",
+ "RF12-Agriturismo (art.5, c.2, L. 413/91)",
+ "RF13-Vendite a domicilio (art.25-bis, c.6, DPR 600/73)",
+ "RF14-Rivendita beni usati, oggetti d’arte, d’antiquariato o da collezione (art.36, DL 41/95)",
+ "RF15-Agenzie di vendite all’asta di oggetti d’arte, antiquariato o da collezione (art.40-bis, DL 41/95)",
+ "RF16-IVA per cassa P.A. (art.6, c.5, DPR 633/72)",
+ "RF17-IVA per cassa (art. 32-bis, DL 83/2012)",
+ "RF18-Altro",
+ "RF19-Regime forfettario (art.1, c.54-89, L. 190/2014)"
+]
+
+tax_exemption_reasons = [
+ "N1-Escluse ex art. 15",
+ "N2-Non Soggette",
+ "N3-Non Imponibili",
+ "N4-Esenti",
+ "N5-Regime del margine / IVA non esposta in fattura",
+ "N6-Inversione Contabile",
+ "N7-IVA assolta in altro stato UE"
+]
+
+mode_of_payment_codes = [
+ "MP01-Contanti",
+ "MP02-Assegno",
+ "MP03-Assegno circolare",
+ "MP04-Contanti presso Tesoreria",
+ "MP05-Bonifico",
+ "MP06-Vaglia cambiario",
+ "MP07-Bollettino bancario",
+ "MP08-Carta di pagamento",
+ "MP09-RID",
+ "MP10-RID utenze",
+ "MP11-RID veloce",
+ "MP12-RIBA",
+ "MP13-MAV",
+ "MP14-Quietanza erario",
+ "MP15-Giroconto su conti di contabilità speciale",
+ "MP16-Domiciliazione bancaria",
+ "MP17-Domiciliazione postale",
+ "MP18-Bollettino di c/c postale",
+ "MP19-SEPA Direct Debit",
+ "MP20-SEPA Direct Debit CORE",
+ "MP21-SEPA Direct Debit B2B",
+ "MP22-Trattenuta su somme già riscosse"
+]
+
+vat_collectability_options = [
+ "I-Immediata",
+ "D-Differita",
+ "S-Scissione dei Pagamenti"
+]
+
+state_codes = {'Siracusa': 'SR', 'Bologna': 'BO', 'Grosseto': 'GR', 'Caserta': 'CE', 'Alessandria': 'AL', 'Ancona': 'AN', 'Pavia': 'PV',
+ 'Benevento or Beneventum': 'BN', 'Modena': 'MO', 'Lodi': 'LO', 'Novara': 'NO', 'Avellino': 'AV', 'Verona': 'VR', 'Forli-Cesena': 'FC',
+ 'Caltanissetta': 'CL', 'Brescia': 'BS', 'Rieti': 'RI', 'Treviso': 'TV', 'Ogliastra': 'OG', 'Olbia-Tempio': 'OT', 'Bergamo': 'BG',
+ 'Napoli': 'NA', 'Campobasso': 'CB', 'Fermo': 'FM', 'Roma': 'RM', 'Lucca': 'LU', 'Rovigo': 'RO', 'Piacenza': 'PC', 'Monza and Brianza': 'MB',
+ 'La Spezia': 'SP', 'Pescara': 'PE', 'Vercelli': 'VC', 'Enna': 'EN', 'Nuoro': 'NU', 'Medio Campidano': 'MD', 'Trieste': 'TS', 'Aosta': 'AO',
+ 'Firenze': 'FI', 'Trapani': 'TP', 'Messina': 'ME', 'Teramo': 'TE', 'Udine': 'UD', 'Verbano-Cusio-Ossola': 'VB', 'Padua': 'PD',
+ 'Reggio Emilia': 'RE', 'Frosinone': 'FR', 'Taranto': 'TA', 'Catanzaro': 'CZ', 'Belluno': 'BL', 'Pordenone': 'PN', 'Viterbo': 'VT',
+ 'Gorizia': 'GO', 'Vatican City': 'SCV', 'Ferrara': 'FE', 'Chieti': 'CH', 'Crotone': 'KR', 'Foggia': 'FG', 'Perugia': 'PG', 'Bari': 'BA',
+ 'Massa-Carrara': 'MS', 'Pisa': 'PI', 'Latina': 'LT', 'Salerno': 'SA', 'Turin': 'TO', 'Lecco': 'LC', 'Lecce': 'LE', 'Pistoia': 'PT', 'Como': 'CO',
+ 'Barletta-Andria-Trani': 'BT', 'Mantua': 'MN', 'Ragusa': 'RG', 'Macerata': 'MC', 'Imperia': 'IM', 'Palermo': 'PA', 'Matera': 'MT', "L'Aquila": 'AQ',
+ 'Milano': 'MI', 'Catania': 'CT', 'Pesaro e Urbino': 'PU', 'Potenza': 'PZ', 'Republic of San Marino': 'RSM', 'Genoa': 'GE', 'Brindisi': 'BR',
+ 'Cagliari': 'CA', 'Siena': 'SI', 'Vibo Valentia': 'VV', 'Reggio Calabria': 'RC', 'Ascoli Piceno': 'AP', 'Carbonia-Iglesias': 'CI', 'Oristano': 'OR',
+ 'Asti': 'AT', 'Ravenna': 'RA', 'Vicenza': 'VI', 'Savona': 'SV', 'Biella': 'BI', 'Rimini': 'RN', 'Agrigento': 'AG', 'Prato': 'PO', 'Cuneo': 'CN',
+ 'Cosenza': 'CS', 'Livorno or Leghorn': 'LI', 'Sondrio': 'SO', 'Cremona': 'CR', 'Isernia': 'IS', 'Trento': 'TN', 'Terni': 'TR', 'Bolzano/Bozen': 'BZ',
+ 'Parma': 'PR', 'Varese': 'VA', 'Venezia': 'VE', 'Sassari': 'SS', 'Arezzo': 'AR'}
\ No newline at end of file
diff --git a/erpnext/regional/italy/e-invoice.xml b/erpnext/regional/italy/e-invoice.xml
new file mode 100644
index 0000000..34053bd
--- /dev/null
+++ b/erpnext/regional/italy/e-invoice.xml
@@ -0,0 +1,208 @@
+{%- macro format_float(value) -%}
+{{ "%.2f" % value|abs }}
+{%- endmacro -%}
+
+{%- macro render_address(address) %}
+<Indirizzo>{{ address.address_line1 }}</Indirizzo>
+<CAP>{{ address.pincode }}</CAP>
+<Comune>{{ address.city }}</Comune>
+{%- if address.state_code %}
+<Provincia>{{ address.state_code }}</Provincia>
+{%- endif %}
+<Nazione>{{ address.country_code|upper }}</Nazione>
+{%- endmacro %}
+
+{%- macro render_discount_or_margin(item) -%}
+{%- if item.discount_percentage > 0.0 or item.margin_type %}
+<ScontoMaggiorazione>
+ {%- if item.discount_percentage > 0.0 %}
+ <Tipo>SC</Tipo>
+ <Percentuale>{{ format_float(item.discount_percentage) }}</Percentuale>
+ {%- endif %}
+ {%- if item.margin_rate_or_amount > 0.0 -%}
+ <Tipo>MG</Tipo>
+ {%- if item.margin_type == "Percentage" -%}
+ <Percentuale>{{ format_float(item.margin_rate_or_amount) }}</Percentuale>
+ {%- elif item.margin_type == "Amount" -%}
+ <Importo>{{ format_float(item.margin_rate_or_amount) }}</Importo>
+ {%- endif -%}
+ {%- endif %}
+</ScontoMaggiorazione>
+{%- endif -%}
+{%- endmacro -%}
+
+<?xml version='1.0' encoding='UTF-8'?>
+<p:FatturaElettronica xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+ xmlns:p="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ versione="{{ doc.transmission_format_code }}"
+ xsi:schemaLocation="http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2 http://www.fatturapa.gov.it/export/fatturazione/sdi/fatturapa/v1.2/Schema_del_file_xml_FatturaPA_versione_1.2.xsd">
+ <FatturaElettronicaHeader>
+ <DatiTrasmissione>
+ <IdTrasmittente>
+ <IdPaese>{{ doc.company_address_data.country_code|upper or "IT" }}</IdPaese>
+ <IdCodice>{{ doc.company_fiscal_code or doc.company_tax_id | replace("IT","") }}</IdCodice>
+ </IdTrasmittente>
+ <ProgressivoInvio>{{ doc.progressive_number }}</ProgressivoInvio>
+ <FormatoTrasmissione>{{ doc.transmission_format_code }}</FormatoTrasmissione>
+ <CodiceDestinatario>{{ doc.customer_data.recipient_code }}</CodiceDestinatario>
+ {% if doc.company_data.phone or doc.company_data.email -%}
+ <ContattiTrasmittente>
+ {% if doc.company_data.phone -%}<Telefono>{{ doc.company_data.phone }}</Telefono>{%- endif %}
+ {% if doc.company_data.email -%}<Email>{{ doc.company_data.email }}</Email>{%- endif %}
+ </ContattiTrasmittente>
+ {% endif -%}
+ </DatiTrasmissione>
+ <CedentePrestatore>
+ <DatiAnagrafici>
+ <IdFiscaleIVA>
+ <IdPaese>{{ doc.company_address_data.country_code|upper or "IT"}}</IdPaese>
+ <IdCodice>{{ doc.company_tax_id | replace("IT","") }}</IdCodice>
+ </IdFiscaleIVA>
+ {%- if doc.company_fiscal_code %}
+ <CodiceFiscale>{{ doc.company_fiscal_code }}</CodiceFiscale>
+ {%- endif %}
+ <Anagrafica>
+ <Denominazione>{{ doc.company }}</Denominazione>
+ </Anagrafica>
+ <RegimeFiscale>{{ doc.company_fiscal_regime.split("-")[0] }}</RegimeFiscale>
+ </DatiAnagrafici>
+ <Sede>
+ {{ render_address(doc.company_address_data) }}
+ </Sede>
+ {%- if doc.company_data.registration_number %}
+ <IscrizioneREA>
+ <Ufficio>{{ doc.company_data.registrar_office_province }}</Ufficio>
+ <NumeroREA>{{ doc.company_data.registration_number }}</NumeroREA>
+ {%- if doc.company_data.share_capital_amount %}
+ <CapitaleSociale>{{ format_float(doc.company_data.share_capital_amount) }}</CapitaleSociale>
+ {%- endif %}
+ {%- if doc.company_data.no_of_members %}
+ <SocioUnico>{{ doc.company_data.no_of_members.split("-")[0] }}</SocioUnico>
+ {%- endif %}
+ {%- if doc.company_data.liquidation_state %}
+ <StatoLiquidazione>{{ doc.company_data.liquidation_state.split("-")[0] }}</StatoLiquidazione>
+ {%- endif %}
+ </IscrizioneREA>
+ {%- endif %}
+ </CedentePrestatore>
+ <CessionarioCommittente>
+ <DatiAnagrafici>
+ {%- if doc.customer_data.customer_type == "Individual" %}
+ <CodiceFiscale>{{ doc.customer_data.fiscal_code }}</CodiceFiscale>
+ <Anagrafica>
+ <Nome>{{ doc.customer_data.first_name }}</Nome>
+ <Cognome>{{ doc.customer_data.last_name }}</Cognome>
+ </Anagrafica>
+ {%- else %}
+ {%- if doc.customer_data.is_public_administration %}
+ <CodiceFiscale>{{ doc.customer_data.fiscal_code }}</CodiceFiscale>
+ {%- else %}
+ <IdFiscaleIVA>
+ <IdPaese>{{ doc.customer_address_data.country_code|upper or "IT" }}</IdPaese>
+ <IdCodice>{{ doc.tax_id | replace("IT","") }}</IdCodice>
+ </IdFiscaleIVA>
+ {%- endif %}
+ <Anagrafica>
+ <Denominazione>{{ doc.customer_name }}</Denominazione>
+ </Anagrafica>
+ {%- endif %}
+ </DatiAnagrafici>
+ {%- if doc.customer_address_data %}
+ <Sede>
+ {{ render_address(doc.customer_address_data) }}
+ </Sede>
+ {%- endif %}
+ </CessionarioCommittente>
+ </FatturaElettronicaHeader>
+ <FatturaElettronicaBody>
+ <DatiGenerali>
+ <DatiGeneraliDocumento>
+ <TipoDocumento>{{ doc.type_of_document }}</TipoDocumento>
+ <Divisa>EUR</Divisa>
+ <Data>{{ doc.posting_date }}</Data>
+ <Numero>{{ doc.unamended_name }}</Numero>
+ {%- if doc.stamp_duty %}
+ <DatiBollo>
+ <BolloVirtuale>SI</BolloVirtuale>
+ <ImportoBollo>{{ format_float(doc.stamp_duty) }}</ImportoBollo>
+ </DatiBollo>
+ {%- endif %}
+ <ImportoTotaleDocumento>{{ format_float(doc.grand_total) }}</ImportoTotaleDocumento>
+ <Causale>VENDITA</Causale>
+ </DatiGeneraliDocumento>
+ {%- if doc.po_no %}
+ <DatiOrdineAcquisto>
+ <IdDocumento>{{ doc.po_no }}</IdDocumento>
+ {%- if doc.po_date %}
+ <Data>{{ doc.po_date }}</Data>
+ {%- endif %}
+ </DatiOrdineAcquisto>
+ {%- endif %}
+ {%- if doc.is_return and doc.return_against_unamended %}
+ <DatiFattureCollegate>
+ <IdDocumento>{{ doc.return_against_unamended }}</IdDocumento>
+ </DatiFattureCollegate>
+ {%- endif %}
+ {%- if doc.shipping_address_data %}
+ <DatiTrasporto>
+ <IndirizzoResa>
+ {{ render_address(doc.shipping_address_data) }}
+ </IndirizzoResa>
+ </DatiTrasporto>
+ {%- endif %}
+ </DatiGenerali>
+ <DatiBeniServizi>
+ {%- for item in doc.e_invoice_items %}
+ <DettaglioLinee>
+ <NumeroLinea>{{ item.idx }}</NumeroLinea>
+ <CodiceArticolo>
+ <CodiceTipo>CODICE</CodiceTipo>
+ <CodiceValore>{{ item.item_code }}</CodiceValore>
+ </CodiceArticolo>
+ <Descrizione>{{ item.description or item.item_name }}</Descrizione>
+ <Quantita>{{ format_float(item.qty) }}</Quantita>
+ <UnitaMisura>{{ item.stock_uom }}</UnitaMisura>
+ <PrezzoUnitario>{{ format_float(item.price_list_rate or item.rate) }}</PrezzoUnitario>
+ {{ render_discount_or_margin(item) }}
+ <PrezzoTotale>{{ format_float(item.amount) }}</PrezzoTotale>
+ <AliquotaIVA>{{ format_float(item.tax_rate) }}</AliquotaIVA>
+ {%- if item.tax_exemption_reason %}
+ <Natura>{{ item.tax_exemption_reason.split("-")[0] }}</Natura>
+ {%- endif %}
+ </DettaglioLinee>
+ {%- endfor %}
+ {%- for tax, data in doc.tax_data.items() %}
+ <DatiRiepilogo>
+ <AliquotaIVA>{{ format_float(tax|flt) }}</AliquotaIVA>
+ {%- if data.tax_exemption_reason %}
+ <Natura>{{ data.tax_exemption_reason.split("-")[0] }}</Natura>
+ {%- endif %}
+ <ImponibileImporto>{{ format_float(data.taxable_amount) }}</ImponibileImporto>
+ <Imposta>{{ format_float(data.tax_amount) }}</Imposta>
+ <EsigibilitaIVA>{{ doc.vat_collectability.split("-")[0] }}</EsigibilitaIVA>
+ {%- if data.tax_exemption_law %}
+ <RiferimentoNormativo>{{ data.tax_exemption_law }}</RiferimentoNormativo>
+ {%- endif %}
+ </DatiRiepilogo>
+ {%- endfor %}
+ </DatiBeniServizi>
+ {%- if doc.payment_schedule %}
+ <DatiPagamento>
+ {%- if payment_schedule|length > 1 %}
+ <CondizioniPagamento>TP01</CondizioniPagamento>
+ {%- else %}
+ <CondizioniPagamento>TP02</CondizioniPagamento>
+ {%- endif %}
+ {%- for payment_term in doc.payment_schedule %}
+ <DettaglioPagamento>
+ <ModalitaPagamento>{{ payment_term.mode_of_payment_code.split("-")[0] }}</ModalitaPagamento>
+ <DataScadenzaPagamento>{{ payment_term.due_date }}</DataScadenzaPagamento>
+ <ImportoPagamento>{{ format_float(payment_term.payment_amount) }}</ImportoPagamento>
+ {%- if payment_term.bank_account_iban %}<IBAN>{{ payment_term.bank_account_iban }}</IBAN>{%- endif %}
+ </DettaglioPagamento>
+ {%- endfor %}
+ </DatiPagamento>
+ {%- endif %}
+ </FatturaElettronicaBody>
+</p:FatturaElettronica>
diff --git a/erpnext/regional/italy/setup.py b/erpnext/regional/italy/setup.py
new file mode 100644
index 0000000..a9de2d1
--- /dev/null
+++ b/erpnext/regional/italy/setup.py
@@ -0,0 +1,158 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+# coding=utf-8
+
+from __future__ import unicode_literals
+
+import frappe
+from frappe import _
+from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
+from erpnext.regional.italy import fiscal_regimes, tax_exemption_reasons, mode_of_payment_codes, vat_collectability_options
+
+def setup(company=None, patch=True):
+ make_custom_fields()
+ setup_report()
+
+def make_custom_fields(update=True):
+ invoice_item_fields = [
+ dict(fieldname='tax_rate', label='Tax Rate',
+ fieldtype='Float', insert_after='description',
+ print_hide=1, hidden=1, read_only=1),
+ dict(fieldname='tax_amount', label='Tax Amount',
+ fieldtype='Currency', insert_after='tax_rate',
+ print_hide=1, hidden=1, read_only=1, options="currency"),
+ dict(fieldname='total_amount', label='Total Amount',
+ fieldtype='Currency', insert_after='tax_amount',
+ print_hide=1, hidden=1, read_only=1, options="currency")
+ ]
+
+ custom_fields = {
+ 'Company': [
+ dict(fieldname='sb_e_invoicing', label='E-Invoicing',
+ fieldtype='Section Break', insert_after='date_of_establishment', print_hide=1),
+ dict(fieldname='fiscal_regime', label='Fiscal Regime',
+ fieldtype='Select', insert_after='sb_e_invoicing', print_hide=1,
+ options="\n".join(map(lambda x: x.decode('utf-8'), fiscal_regimes))),
+ dict(fieldname='fiscal_code', label='Fiscal Code', fieldtype='Data', insert_after='fiscal_regime', print_hide=1,
+ description=_("Applicable if the company is an Individual or a Proprietorship")),
+ dict(fieldname='vat_collectability', label='VAT Collectability',
+ fieldtype='Select', insert_after='fiscal_code', print_hide=1,
+ options="\n".join(map(lambda x: x.decode('utf-8'), vat_collectability_options))),
+ dict(fieldname='cb_e_invoicing1', fieldtype='Column Break', insert_after='vat_collectability', print_hide=1),
+ dict(fieldname='registrar_office_province', label='Province of the Registrar Office',
+ fieldtype='Data', insert_after='cb_e_invoicing1', print_hide=1, length=2),
+ dict(fieldname='registration_number', label='Registration Number',
+ fieldtype='Data', insert_after='registrar_office_province', print_hide=1, length=20),
+ dict(fieldname='share_capital_amount', label='Share Capital',
+ fieldtype='Currency', insert_after='registration_number', print_hide=1,
+ description=_('Applicable if the company is SpA, SApA or SRL')),
+ dict(fieldname='no_of_members', label='No of Members',
+ fieldtype='Select', insert_after='share_capital_amount', print_hide=1,
+ options="\nSU-Socio Unico\nSM-Piu Soci", description=_("Applicable if the company is a limited liability company")),
+ dict(fieldname='liquidation_state', label='Liquidation State',
+ fieldtype='Select', insert_after='no_of_members', print_hide=1,
+ options="\nLS-In Liquidazione\nLN-Non in Liquidazione")
+ ],
+ 'Sales Taxes and Charges': [
+ dict(fieldname='tax_exemption_reason', label='Tax Exemption Reason',
+ fieldtype='Select', insert_after='included_in_print_rate', print_hide=1,
+ depends_on='eval:doc.charge_type!="Actual" && doc.rate==0.0',
+ options="\n" + "\n".join(map(lambda x: x.decode('utf-8'), tax_exemption_reasons))),
+ dict(fieldname='tax_exemption_law', label='Tax Exempt Under',
+ fieldtype='Text', insert_after='tax_exemption_reason', print_hide=1,
+ depends_on='eval:doc.charge_type!="Actual" && doc.rate==0.0')
+ ],
+ 'Customer': [
+ dict(fieldname='fiscal_code', label='Fiscal Code', fieldtype='Data', insert_after='tax_id', print_hide=1),
+ dict(fieldname='recipient_code', label='Recipient Code',
+ fieldtype='Data', insert_after='fiscal_code', print_hide=1, default="0000000"),
+ dict(fieldname='pec', label='Recipient PEC',
+ fieldtype='Data', insert_after='fiscal_code', print_hide=1),
+ dict(fieldname='is_public_administration', label='Is Public Administration',
+ fieldtype='Check', insert_after='is_internal_customer', print_hide=1,
+ description=_("Set this if the customer is a Public Administration company."),
+ depends_on='eval:doc.customer_type=="Company"'),
+ dict(fieldname='first_name', label='First Name', fieldtype='Data',
+ insert_after='salutation', print_hide=1, depends_on='eval:doc.customer_type!="Company"'),
+ dict(fieldname='last_name', label='Last Name', fieldtype='Data',
+ insert_after='first_name', print_hide=1, depends_on='eval:doc.customer_type!="Company"')
+ ],
+ 'Mode of Payment': [
+ dict(fieldname='mode_of_payment_code', label='Code',
+ fieldtype='Select', insert_after='included_in_print_rate', print_hide=1,
+ options="\n".join(map(lambda x: x.decode('utf-8'), mode_of_payment_codes)))
+ ],
+ 'Payment Schedule': [
+ dict(fieldname='mode_of_payment_code', label='Code',
+ fieldtype='Select', insert_after='mode_of_payment', print_hide=1,
+ options="\n".join(map(lambda x: x.decode('utf-8'), mode_of_payment_codes)),
+ fetch_from="mode_of_payment.mode_of_payment_code", read_only=1),
+ dict(fieldname='bank_account', label='Bank Account',
+ fieldtype='Link', insert_after='mode_of_payment_code', print_hide=1,
+ options="Bank Account"),
+ dict(fieldname='bank_account_name', label='Bank Account Name',
+ fieldtype='Data', insert_after='bank_account', print_hide=1,
+ fetch_from="bank_account.account_name", read_only=1),
+ dict(fieldname='bank_account_no', label='Bank Account No',
+ fieldtype='Data', insert_after='bank_account_name', print_hide=1,
+ fetch_from="bank_account.bank_account_no", read_only=1),
+ dict(fieldname='bank_account_iban', label='IBAN',
+ fieldtype='Data', insert_after='bank_account_name', print_hide=1,
+ fetch_from="bank_account.iban", read_only=1),
+ ],
+ "Sales Invoice": [
+ dict(fieldname='vat_collectability', label='VAT Collectability',
+ fieldtype='Select', insert_after='taxes_and_charges', print_hide=1,
+ options="\n".join(map(lambda x: x.decode('utf-8'), vat_collectability_options)),
+ fetch_from="company.vat_collectability"),
+ dict(fieldname='sb_e_invoicing_reference', label='E-Invoicing',
+ fieldtype='Section Break', insert_after='pos_total_qty', print_hide=1),
+ dict(fieldname='company_tax_id', label='Company Tax ID',
+ fieldtype='Data', insert_after='sb_e_invoicing_reference', print_hide=1, read_only=1,
+ fetch_from="company.tax_id"),
+ dict(fieldname='company_fiscal_code', label='Company Fiscal Code',
+ fieldtype='Data', insert_after='company_tax_id', print_hide=1, read_only=1,
+ fetch_from="company.fiscal_code"),
+ dict(fieldname='company_fiscal_regime', label='Company Fiscal Regime',
+ fieldtype='Data', insert_after='company_fiscal_code', print_hide=1, read_only=1,
+ fetch_from="company.fiscal_regime"),
+ dict(fieldname='cb_e_invoicing_reference', fieldtype='Column Break',
+ insert_after='company_fiscal_regime', print_hide=1),
+ dict(fieldname='customer_fiscal_code', label='Customer Fiscal Code',
+ fieldtype='Data', insert_after='cb_e_invoicing_reference', read_only=1,
+ fetch_from="customer.fiscal_code"),
+ ],
+ 'Purchase Invoice Item': invoice_item_fields,
+ 'Sales Order Item': invoice_item_fields,
+ 'Delivery Note Item': invoice_item_fields,
+ 'Sales Invoice Item': invoice_item_fields,
+ 'Quotation Item': invoice_item_fields,
+ 'Purchase Order Item': invoice_item_fields,
+ 'Purchase Receipt Item': invoice_item_fields,
+ 'Supplier Quotation Item': invoice_item_fields,
+ 'Address': [
+ dict(fieldname='country_code', label='Country Code',
+ fieldtype='Data', insert_after='country', print_hide=1, read_only=1,
+ fetch_from="country.code"),
+ dict(fieldname='state_code', label='State Code',
+ fieldtype='Data', insert_after='state', print_hide=1)
+ ]
+ }
+
+ create_custom_fields(custom_fields, ignore_validate = frappe.flags.in_patch, update=update)
+
+def setup_report():
+ report_name = 'Electronic Invoice Register'
+
+ frappe.db.sql(""" update `tabReport` set disabled = 0 where
+ name = %s """, report_name)
+
+ if not frappe.db.get_value('Custom Role', dict(report=report_name)):
+ frappe.get_doc(dict(
+ doctype='Custom Role',
+ report=report_name,
+ roles= [
+ dict(role='Accounts User'),
+ dict(role='Accounts Manager')
+ ]
+ )).insert()
diff --git a/erpnext/regional/italy/utils.py b/erpnext/regional/italy/utils.py
new file mode 100644
index 0000000..c86ad78
--- /dev/null
+++ b/erpnext/regional/italy/utils.py
@@ -0,0 +1,307 @@
+from __future__ import unicode_literals
+
+import frappe, json, os
+from frappe.utils import flt, cstr
+from erpnext.controllers.taxes_and_totals import get_itemised_tax
+from frappe import _
+from frappe.utils.file_manager import save_file, remove_file
+from frappe.desk.form.load import get_attachments
+from erpnext.regional.italy import state_codes
+
+
+def update_itemised_tax_data(doc):
+ if not doc.taxes: return
+
+ itemised_tax = get_itemised_tax(doc.taxes)
+
+ for row in doc.items:
+ tax_rate = 0.0
+ if itemised_tax.get(row.item_code):
+ tax_rate = sum([tax.get('tax_rate', 0) for d, tax in itemised_tax.get(row.item_code).items()])
+
+ row.tax_rate = flt(tax_rate, row.precision("tax_rate"))
+ row.tax_amount = flt((row.net_amount * tax_rate) / 100, row.precision("net_amount"))
+ row.total_amount = flt((row.net_amount + row.tax_amount), row.precision("total_amount"))
+
+@frappe.whitelist()
+def export_invoices(filters=None):
+ saved_xmls = []
+
+ invoices = frappe.get_all("Sales Invoice", filters=get_conditions(filters), fields=["*"])
+
+ for invoice in invoices:
+ attachments = get_e_invoice_attachments(invoice)
+ saved_xmls += [attachment.file_name for attachment in attachments]
+
+ zip_filename = "{0}-einvoices.zip".format(frappe.utils.get_datetime().strftime("%Y%m%d_%H%M%S"))
+
+ download_zip(saved_xmls, zip_filename)
+
+
+@frappe.whitelist()
+def prepare_invoice(invoice, progressive_number):
+ #set company information
+ company = frappe.get_doc("Company", invoice.company)
+
+ invoice.progressive_number = progressive_number
+ invoice.unamended_name = get_unamended_name(invoice)
+ invoice.company_data = company
+ company_address = frappe.get_doc("Address", invoice.company_address)
+ invoice.company_address_data = company_address
+
+ #Set invoice type
+ if invoice.is_return and invoice.return_against:
+ invoice.type_of_document = "TD04" #Credit Note (Nota di Credito)
+ invoice.return_against_unamended = get_unamended_name(frappe.get_doc("Sales Invoice", invoice.return_against))
+ else:
+ invoice.type_of_document = "TD01" #Sales Invoice (Fattura)
+
+ #set customer information
+ invoice.customer_data = frappe.get_doc("Customer", invoice.customer)
+ customer_address = frappe.get_doc("Address", invoice.customer_address)
+ invoice.customer_address_data = customer_address
+
+ if invoice.shipping_address_name:
+ invoice.shipping_address_data = frappe.get_doc("Address", invoice.shipping_address_name)
+
+ if invoice.customer_data.is_public_administration:
+ invoice.transmission_format_code = "FPA12"
+ else:
+ invoice.transmission_format_code = "FPR12"
+
+ invoice.e_invoice_items = [item for item in invoice.items]
+ tax_data = get_invoice_summary(invoice.e_invoice_items, invoice.taxes)
+ invoice.tax_data = tax_data
+
+ #Check if stamp duty (Bollo) of 2 EUR exists.
+ stamp_duty_charge_row = next((tax for tax in invoice.taxes if tax.charge_type == _("Actual") and tax.tax_amount == 2.0 ), None)
+ if stamp_duty_charge_row:
+ invoice.stamp_duty = stamp_duty_charge_row.tax_amount
+
+ for item in invoice.e_invoice_items:
+ if item.tax_rate == 0.0 and item.tax_amount == 0.0:
+ item.tax_exemption_reason = tax_data["0.0"]["tax_exemption_reason"]
+
+ return invoice
+
+def get_conditions(filters):
+ filters = json.loads(filters)
+
+ conditions = {"docstatus": 1}
+
+ if filters.get("company"): conditions["company"] = filters["company"]
+ if filters.get("customer"): conditions["customer"] = filters["customer"]
+
+ if filters.get("from_date"): conditions["posting_date"] = (">=", filters["from_date"])
+ if filters.get("to_date"): conditions["posting_date"] = ("<=", filters["to_date"])
+
+ if filters.get("from_date") and filters.get("to_date"):
+ conditions["posting_date"] = ("between", [filters.get("from_date"), filters.get("to_date")])
+
+ return conditions
+
+#TODO: Use function from frappe once PR #6853 is merged.
+def download_zip(files, output_filename):
+ from zipfile import ZipFile
+
+ input_files = [frappe.get_site_path('private', 'files', filename) for filename in files]
+ output_path = frappe.get_site_path('private', 'files', output_filename)
+
+ with ZipFile(output_path, 'w') as output_zip:
+ for input_file in input_files:
+ output_zip.write(input_file, arcname=os.path.basename(input_file))
+
+ with open(output_path, 'rb') as fileobj:
+ filedata = fileobj.read()
+
+ frappe.local.response.filename = output_filename
+ frappe.local.response.filecontent = filedata
+ frappe.local.response.type = "download"
+
+def get_invoice_summary(items, taxes):
+ summary_data = frappe._dict()
+ for tax in taxes:
+ #Include only VAT charges.
+ if tax.charge_type == "Actual":
+ continue
+
+ #Charges to appear as items in the e-invoice.
+ if tax.charge_type in ["On Previous Row Total", "On Previous Row Amount"]:
+ reference_row = next((row for row in taxes if row.idx == int(tax.row_id or 0)), None)
+ if reference_row:
+ items.append(
+ frappe._dict(
+ idx=len(items)+1,
+ item_code=reference_row.description,
+ item_name=reference_row.description,
+ rate=reference_row.tax_amount,
+ qty=1.0,
+ amount=reference_row.tax_amount,
+ stock_uom=frappe.db.get_single_value("Stock Settings", "stock_uom") or _("Nos"),
+ tax_rate=tax.rate,
+ tax_amount=(reference_row.tax_amount * tax.rate) / 100,
+ net_amount=reference_row.tax_amount,
+ taxable_amount=reference_row.tax_amount,
+ item_tax_rate="{}",
+ charges=True
+ )
+ )
+
+ #Check item tax rates if tax rate is zero.
+ if tax.rate == 0:
+ for item in items:
+ item_tax_rate = json.loads(item.item_tax_rate)
+ if tax.account_head in item_tax_rate:
+ key = cstr(item_tax_rate[tax.account_head])
+ summary_data.setdefault(key, {"tax_amount": 0.0, "taxable_amount": 0.0, "tax_exemption_reason": "", "tax_exemption_law": ""})
+ summary_data[key]["tax_amount"] += item.tax_amount
+ summary_data[key]["taxable_amount"] += item.net_amount
+ if key == "0.0":
+ summary_data[key]["tax_exemption_reason"] = tax.tax_exemption_reason
+ summary_data[key]["tax_exemption_law"] = tax.tax_exemption_law
+
+ if summary_data == {}: #Implies that Zero VAT has not been set on any item.
+ summary_data.setdefault("0.0", {"tax_amount": 0.0, "taxable_amount": tax.total,
+ "tax_exemption_reason": tax.tax_exemption_reason, "tax_exemption_law": tax.tax_exemption_law})
+
+ else:
+ item_wise_tax_detail = json.loads(tax.item_wise_tax_detail)
+ for rate_item in [tax_item for tax_item in item_wise_tax_detail.items() if tax_item[1][0] == tax.rate]:
+ key = cstr(tax.rate)
+ if not summary_data.get(key): summary_data.setdefault(key, {"tax_amount": 0.0, "taxable_amount": 0.0})
+ summary_data[key]["tax_amount"] += rate_item[1][1]
+ summary_data[key]["taxable_amount"] += sum([item.net_amount for item in items if item.item_code == rate_item[0]])
+
+ for item in items:
+ key = cstr(tax.rate)
+ if item.get("charges"):
+ if not summary_data.get(key): summary_data.setdefault(key, {"taxable_amount": 0.0})
+ summary_data[key]["taxable_amount"] += item.taxable_amount
+
+ return summary_data
+
+#Preflight for successful e-invoice export.
+def sales_invoice_validate(doc):
+ #Validate company
+ if doc.doctype != 'Sales Invoice':
+ return
+
+ if not doc.company_address:
+ frappe.throw(_("Please set an Address on the Company '%s'" % doc.company), title=_("E-Invoicing Information Missing"))
+ else:
+ validate_address(doc.company_address, "Company")
+
+ if not doc.company_tax_id and not doc.company_fiscal_code:
+ frappe.throw(_("Please set either the Tax ID or Fiscal Code on Company '%s'" % doc.company), title=_("E-Invoicing Information Missing"))
+
+ #Validate customer details
+ customer_type, is_public_administration = frappe.db.get_value("Customer", doc.customer, ["customer_type", "is_public_administration"])
+ if customer_type == _("Individual"):
+ if not doc.customer_fiscal_code:
+ frappe.throw(_("Please set Fiscal Code for the customer '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
+ else:
+ if is_public_administration:
+ if not doc.customer_fiscal_code:
+ frappe.throw(_("Please set Fiscal Code for the public administration '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
+ else:
+ if not doc.tax_id:
+ frappe.throw(_("Please set Tax ID for the customer '%s'" % doc.customer), title=_("E-Invoicing Information Missing"))
+
+ if not doc.customer_address:
+ frappe.throw(_("Please set the Customer Address"), title=_("E-Invoicing Information Missing"))
+ else:
+ validate_address(doc.customer_address, "Customer")
+
+ if not len(doc.taxes):
+ frappe.throw(_("Please set at least one row in the Taxes and Charges Table"), title=_("E-Invoicing Information Missing"))
+ else:
+ for row in doc.taxes:
+ if row.rate == 0 and row.tax_amount == 0 and not row.tax_exemption_reason:
+ frappe.throw(_("Row {0}: Please set at Tax Exemption Reason in Sales Taxes and Charges".format(row.idx)),
+ title=_("E-Invoicing Information Missing"))
+
+
+#Ensure payment details are valid for e-invoice.
+def sales_invoice_on_submit(doc, method):
+ #Validate payment details
+ if get_company_country(doc.company) not in ['Italy',
+ 'Italia', 'Italian Republic', 'Repubblica Italiana']:
+ return
+
+ if not len(doc.payment_schedule):
+ frappe.throw(_("Please set the Payment Schedule"), title=_("E-Invoicing Information Missing"))
+ else:
+ for schedule in doc.payment_schedule:
+ if not schedule.mode_of_payment:
+ frappe.throw(_("Row {0}: Please set the Mode of Payment in Payment Schedule".format(schedule.idx)),
+ title=_("E-Invoicing Information Missing"))
+ elif not frappe.db.get_value("Mode of Payment", schedule.mode_of_payment, "mode_of_payment_code"):
+ frappe.throw(_("Row {0}: Please set the correct code on Mode of Payment {1}".format(schedule.idx, schedule.mode_of_payment)),
+ title=_("E-Invoicing Information Missing"))
+
+ prepare_and_attach_invoice(doc)
+
+def prepare_and_attach_invoice(doc):
+ progressive_name, progressive_number = get_progressive_name_and_number(doc)
+
+ invoice = prepare_invoice(doc, progressive_number)
+ invoice_xml = frappe.render_template('erpnext/regional/italy/e-invoice.xml', context={"doc": invoice}, is_path=True)
+
+ xml_filename = progressive_name + ".xml"
+ save_file(xml_filename, invoice_xml, dt=doc.doctype, dn=doc.name, is_private=True)
+
+#Delete e-invoice attachment on cancel.
+def sales_invoice_on_cancel(doc, method):
+ if get_company_country(doc.company) not in ['Italy',
+ 'Italia', 'Italian Republic', 'Repubblica Italiana']:
+ return
+
+ for attachment in get_e_invoice_attachments(doc):
+ remove_file(attachment.name, attached_to_doctype=doc.doctype, attached_to_name=doc.name)
+
+def get_company_country(company):
+ return frappe.get_cached_value('Company', company, 'country')
+
+def get_e_invoice_attachments(invoice):
+ out = []
+ attachments = get_attachments(invoice.doctype, invoice.name)
+ company_tax_id = invoice.company_tax_id if invoice.company_tax_id.startswith("IT") else "IT" + invoice.company_tax_id
+
+ for attachment in attachments:
+ if attachment.file_name.startswith(company_tax_id) and attachment.file_name.endswith(".xml"):
+ out.append(attachment)
+
+ return out
+
+def validate_address(address_name, address_context):
+ pincode, city = frappe.db.get_value("Address", address_name, ["pincode", "city"])
+ if not pincode:
+ frappe.throw(_("Please set pin code on %s Address" % address_context), title=_("E-Invoicing Information Missing"))
+ if not city:
+ frappe.throw(_("Please set city on %s Address" % address_context), title=_("E-Invoicing Information Missing"))
+
+
+def get_unamended_name(doc):
+ attributes = ["naming_series", "amended_from"]
+ for attribute in attributes:
+ if not hasattr(doc, attribute):
+ return doc.name
+
+ if doc.amended_from:
+ return "-".join(doc.name.split("-")[:-1])
+ else:
+ return doc.name
+
+def get_progressive_name_and_number(doc):
+ company_tax_id = doc.company_tax_id if doc.company_tax_id.startswith("IT") else "IT" + doc.company_tax_id
+ progressive_name = frappe.model.naming.make_autoname(company_tax_id + "_.#####")
+ progressive_number = progressive_name.split("_")[1]
+
+ return progressive_name, progressive_number
+
+def set_state_code(doc, method):
+ if not (hasattr(doc, "state_code") and doc.country in ["Italy", "Italia", "Italian Republic", "Repubblica Italiana"]):
+ return
+
+ state_codes_lower = {key.lower():value for key,value in state_codes.items()}
+ doc.state_code = state_codes_lower.get(doc.get('state','').lower())
diff --git a/erpnext/regional/report/electronic_invoice_register/__init__.py b/erpnext/regional/report/electronic_invoice_register/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/regional/report/electronic_invoice_register/__init__.py
diff --git a/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.js b/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.js
new file mode 100644
index 0000000..67297f7
--- /dev/null
+++ b/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.js
@@ -0,0 +1,53 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Electronic Invoice Register"] = {
+ "filters": [
+ {
+ "fieldname":"from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
+ "width": "80"
+ },
+ {
+ "fieldname":"to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "default": frappe.datetime.get_today()
+ },
+ {
+ "fieldname":"customer",
+ "label": __("Customer"),
+ "fieldtype": "Link",
+ "options": "Customer"
+ },
+ {
+ "fieldname":"company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": frappe.defaults.get_user_default("Company")
+ },
+ ],
+ "onload": function(reportview) {
+ reportview.page.add_inner_button(__("Export E-Invoices"), function() {
+ //TODO: refactor condition to disallow export if report has no data.
+ if (!reportview.data.length) {
+ frappe.msgprint(__("No data to export"));
+ return
+ }
+
+ var w = window.open(
+ frappe.urllib.get_full_url(
+ "/api/method/erpnext.regional.italy.utils.export_invoices?"
+ + "filters=" + JSON.stringify(reportview.get_filter_values())
+ )
+ );
+ if (!w) {
+ frappe.msgprint(__("Please enable pop-ups")); return;
+ }
+ })
+ }
+}
diff --git a/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.json b/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.json
new file mode 100644
index 0000000..5470c49
--- /dev/null
+++ b/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.json
@@ -0,0 +1,21 @@
+{
+ "add_total_row": 0,
+ "color": "green",
+ "creation": "2019-01-13 17:43:21.903589",
+ "disabled": 1,
+ "docstatus": 0,
+ "doctype": "Report",
+ "icon": "fa fa-file-code-o",
+ "idx": 0,
+ "is_standard": "Yes",
+ "modified": "2019-01-13 19:03:56.187748",
+ "modified_by": "Administrator",
+ "module": "Regional",
+ "name": "Electronic Invoice Register",
+ "owner": "Administrator",
+ "prepared_report": 0,
+ "ref_doctype": "Sales Invoice",
+ "report_name": "Electronic Invoice Register",
+ "report_type": "Script Report",
+ "roles": []
+}
\ No newline at end of file
diff --git a/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.py b/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.py
new file mode 100644
index 0000000..376ba3e
--- /dev/null
+++ b/erpnext/regional/report/electronic_invoice_register/electronic_invoice_register.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+from erpnext.accounts.report.sales_register.sales_register import _execute
+
+def execute(filters=None):
+ return _execute(filters)
diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.json b/erpnext/selling/doctype/quotation_item/quotation_item.json
index 3a8b0df..24cb405 100644
--- a/erpnext/selling/doctype/quotation_item/quotation_item.json
+++ b/erpnext/selling/doctype/quotation_item/quotation_item.json
@@ -762,7 +762,7 @@
"no_copy": 0,
"options": "currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -1914,7 +1914,7 @@
"istable": 1,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2019-01-07 16:51:56.248107",
+ "modified": "2019-02-18 18:57:25.277633",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation Item",
diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
index 19065df..5ca2f81 100644
--- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json
+++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json
@@ -961,7 +961,7 @@
"no_copy": 0,
"options": "Company:company:default_currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -2477,7 +2477,7 @@
"istable": 1,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2019-01-07 16:51:51.852343",
+ "modified": "2019-02-18 18:53:23.425126",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order Item",
diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py
index c3260ab..1b08a22 100644
--- a/erpnext/setup/doctype/company/test_company.py
+++ b/erpnext/setup/doctype/company/test_company.py
@@ -46,7 +46,7 @@
def test_coa_based_on_country_template(self):
countries = ["India", "Brazil", "United Arab Emirates", "Canada", "Germany", "France",
- "Guatemala", "Indonesia", "Mexico", "Nicaragua", "Netherlands", "Singapore",
+ "Guatemala", "Indonesia", "Italy", "Mexico", "Nicaragua", "Netherlands", "Singapore",
"Brazil", "Argentina", "Hungary", "Taiwan"]
for country in countries:
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
index 9fe741a..1e73d68 100644
--- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
+++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json
@@ -793,7 +793,7 @@
"no_copy": 0,
"options": "currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -928,7 +928,7 @@
"no_copy": 0,
"options": "Company:company:default_currency",
"permlevel": 0,
- "precision": "2",
+ "precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
@@ -2310,7 +2310,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2019-01-07 16:51:53.322875",
+ "modified": "2019-02-18 18:58:51.342901",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note Item",
diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py
index 678de1a..0422442 100644
--- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py
+++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.py
@@ -5,14 +5,17 @@
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
+from frappe import _
class ItemVariantSettings(Document):
+ invalid_fields_for_copy_fields_in_variants = ['barcodes']
+
def set_default_fields(self):
self.fields = []
fields = frappe.get_meta('Item').fields
exclude_fields = ["naming_series", "item_code", "item_name", "show_in_website",
"show_variant_in_website", "standard_rate", "opening_stock", "image", "description",
- "variant_of", "valuation_rate", "description",
+ "variant_of", "valuation_rate", "description", "barcodes",
"website_image", "thumbnail", "website_specifiations", "web_long_description"]
for d in fields:
@@ -20,4 +23,14 @@
d.fieldtype not in ['HTML', 'Section Break', 'Column Break', 'Button', 'Read Only']:
self.append('fields', {
'field_name': d.fieldname
- })
\ No newline at end of file
+ })
+
+ def remove_invalid_fields_for_copy_fields_in_variants(self):
+ fields = [row for row in self.fields if row.field_name not in self.invalid_fields_for_copy_fields_in_variants]
+ self.fields = fields
+ self.save()
+
+ def validate(self):
+ for d in self.fields:
+ if d.field_name in self.invalid_fields_for_copy_fields_in_variants:
+ frappe.throw(_('Cannot set the field <b>{0}</b> for copying in variants').format(d.field_name))
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 2b0ed38..cb4afef 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -85,7 +85,7 @@
// stop
frm.add_custom_button(__('Stop'),
- () => frm.events.update_status(frm, 'Stop'));
+ () => frm.events.update_status(frm, 'Stopped'));
}
}
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index 3746dfb..528f799 100644
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -417,7 +417,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Recd Quantity",
+ "label": "Received Quantity",
"length": 0,
"no_copy": 0,
"oldfieldname": "received_qty",
@@ -2608,7 +2608,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2019-01-07 16:51:59.002215",
+ "modified": "2019-02-18 16:04:36.138776",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt Item",