import re

SETTINGS_DOCTYPE = "Unicommerce Settings"
MODULE_NAME = "unicommerce"

DEFAULT_WEIGHT_UOM = "Gram"
UNICOMMERCE_SKU_PATTERN = re.compile(r"[A-Za-z0-9._\-/]{3,45}")


# Custom fields
ITEM_SYNC_CHECKBOX = "sync_with_unicommerce"
ORDER_CODE_FIELD = "unicommerce_order_code"
CHANNEL_ID_FIELD = "unicommerce_channel_id"
ORDER_STATUS_FIELD = "unicommerce_order_status"
ORDER_INVOICE_STATUS_FIELD = "unicommerce_invoicing_status"
ORDER_ITEM_CODE_FIELD = "unicommerce_order_item_code"
ORDER_ITEM_BATCH_NO = "unicommerce_batch_code"
PRODUCT_CATEGORY_FIELD = "unicommerce_product_category"
FACILITY_CODE_FIELD = "unicommerce_facility_code"
INVOICE_CODE_FIELD = "unicommerce_invoice_code"
SHIPPING_PACKAGE_CODE_FIELD = "unicommerce_shipping_package_code"
RETURN_CODE_FIELD = "unicommerce_return_code"
TRACKING_CODE_FIELD = "unicommerce_tracking_code"
SHIPPING_PROVIDER_CODE = "unicommerce_shipping_provider"
MANIFEST_GENERATED_CHECK = "unicommerce_manifest_generated"
ADDRESS_JSON_FIELD = "unicommerce_raw_billing_address"
CUSTOMER_CODE_FIELD = "unicommerce_customer_code"
PACKAGE_TYPE_FIELD = "unicommerce_package_type"
ITEM_LENGTH_FIELD = "unicommerce_item_length"
ITEM_WIDTH_FIELD = "unicommerce_item_width"
ITEM_HEIGHT_FIELD = "unicommerce_item_height"
ITEM_BATCH_GROUP_FIELD = "unicommerce_batch_group_code"
SHIPPING_PACKAGE_STATUS_FIELD = "unicommerce_shipping_package_status"
IS_COD_CHECKBOX = "unicommerce_is_cod"
SHIPPING_METHOD_FIELD = "unicommerce_shipping_method"
UNICOMMERCE_SHIPPING_ID = "unicommerce_shipment_id"
PICKLIST_ORDER_DETAILS_FIELD = "order_details"

GRN_STOCK_ENTRY_TYPE = "GRN on Unicommerce"


# Tax -> Unicommerce tax amount field mapping
TAX_FIELDS_MAPPING = {
	"igst": "integratedGst",
	"cgst": "centralGst",
	"sgst": "stateGst",
	"ugst": "unionTerritoryGst",
	"tcs": "tcsAmount",
	"cash_on_delivery_charges": "cashOnDeliveryCharges",
	"gift_wrap_charges": "giftWrapCharges",
	"shipping_charges": "shippingCharges",
	"shipping_method_charges": "shippingMethodCharges",
}

# Tax -> Unicommerce tax "rate" field mapping
TAX_RATE_FIELDS_MAPPING = {
	"igst": "integratedGstPercentage",
	"cgst": "centralGstPercentage",
	"sgst": "stateGstPercentage",
	"ugst": "unionTerritoryGstPercentage",
}

# field name for accounts in Unicommerce channels
CHANNEL_TAX_ACCOUNT_FIELD_MAP = {
	"igst": "igst_account",
	"cgst": "cgst_account",
	"sgst": "sgst_account",
	"ugst": "ugst_account",
	"tcs": "tcs_account",
	"cash_on_delivery_charges": "cod_account",
	"gift_wrap_charges": "gift_wrap_account",
	"shipping_charges": "fnf_account",
	"shipping_method_charges": "fnf_account",
}


UNICOMMERCE_COUNTRY_MAPPING = {
	"AD": "Andorra",
	"AE": "United Arab Emirates",
	"AF": "Afghanistan",
	"AG": "Antigua and Barbuda",
	"AI": "Anguilla",
	"AL": "Albania",
	"AM": "Armenia",
	"AO": "Angola",
	"AQ": "Antarctica",
	"AR": "Argentina",
	"AS": "American Samoa",
	"AT": "Austria",
	"AU": "Australia",
	"AW": "Aruba",
	"AZ": "Azerbaijan",
	"BA": "Bosnia and Herzegovina",
	"BB": "Barbados",
	"BD": "Bangladesh",
	"BE": "Belgium",
	"BF": "Burkina Faso",
	"BG": "Bulgaria",
	"BH": "Bahrain",
	"BI": "Burundi",
	"BJ": "Benin",
	"BM": "Bermuda",
	"BR": "Brazil",
	"BS": "Bahamas",
	"BT": "Bhutan",
	"BV": "Bouvet Island",
	"BW": "Botswana",
	"BY": "Belarus",
	"BZ": "Belize",
	"CA": "Canada",
	"CF": "Central African Republic",
	"CH": "Switzerland",
	"CI": "Ivory Coast",
	"CK": "Cook Islands",
	"CL": "Chile",
	"CM": "Cameroon",
	"CN": "China",
	"CO": "Colombia",
	"CR": "Costa Rica",
	"CU": "Cuba",
	"CV": "Cape Verde",
	"CX": "Christmas Island",
	"CY": "Cyprus",
	"CZ": "Czech Republic",
	"DE": "Germany",
	"DJ": "Djibouti",
	"DK": "Denmark",
	"DM": "Dominica",
	"DO": "Dominican Republic",
	"DZ": "Algeria",
	"EC": "Ecuador",
	"EE": "Estonia",
	"EG": "Egypt",
	"EH": "Western Sahara",
	"ER": "Eritrea",
	"ES": "Spain",
	"ET": "Ethiopia",
	"FI": "Finland",
	"FJ": "Fiji",
	"FK": "Falkland Islands",
	"FM": "Micronesia",
	"FO": "Faroe Islands",
	"FR": "France",
	"GA": "Gabon",
	"GB": "United Kingdom",
	"GD": "Grenada",
	"GE": "Georgia",
	"GF": "French Guiana",
	"GG": "Guernsey",
	"GH": "Ghana",
	"GI": "Gibraltar",
	"GL": "Greenland",
	"GM": "Gambia",
	"GN": "Guinea",
	"GP": "Guadeloupe",
	"GQ": "Equatorial Guinea",
	"GR": "Greece",
	"GS": "South Georgia and the South Sandwich Islands",
	"GT": "Guatemala",
	"GU": "Guam",
	"GW": "Guinea-Bissau",
	"GY": "Guyana",
	"HK": "Hong Kong",
	"HM": "Heard Island and McDonald Islands",
	"HN": "Honduras",
	"HR": "Croatia",
	"HT": "Haiti",
	"HU": "Hungary",
	"ID": "Indonesia",
	"IE": "Ireland",
	"IL": "Israel",
	"IM": "Isle of Man",
	"IN": "India",
	"IO": "British Indian Ocean Territory",
	"IQ": "Iraq",
	"IR": "Iran",
	"IS": "Iceland",
	"IT": "Italy",
	"JE": "Jersey",
	"JM": "Jamaica",
	"JO": "Jordan",
	"JP": "Japan",
	"KE": "Kenya",
	"KG": "Kyrgyzstan",
	"KH": "Cambodia",
	"KI": "Kiribati",
	"KM": "Comoros",
	"KN": "Saint Kitts and Nevis",
	"KR": "Korea, Republic of",
	"KW": "Kuwait",
	"KY": "Cayman Islands",
	"KZ": "Kazakhstan",
	"LB": "Lebanon",
	"LC": "Saint Lucia",
	"LI": "Liechtenstein",
	"LK": "Sri Lanka",
	"LR": "Liberia",
	"LS": "Lesotho",
	"LT": "Lithuania",
	"LU": "Luxembourg",
	"LV": "Latvia",
	"LY": "Libya",
	"MA": "Morocco",
	"MC": "Monaco",
	"MD": "Moldova, Republic of",
	"ME": "Montenegro",
	"MG": "Madagascar",
	"MH": "Marshall Islands",
	"MK": "Macedonia",
	"ML": "Mali",
	"MM": "Myanmar",
	"MN": "Mongolia",
	"MO": "Macao",
	"MP": "Northern Mariana Islands",
	"MQ": "Martinique",
	"MR": "Mauritania",
	"MS": "Montserrat",
	"MT": "Malta",
	"MU": "Mauritius",
	"MV": "Maldives",
	"MW": "Malawi",
	"MX": "Mexico",
	"MY": "Malaysia",
	"MZ": "Mozambique",
	"NA": "Namibia",
	"NC": "New Caledonia",
	"NE": "Niger",
	"NF": "Norfolk Island",
	"NG": "Nigeria",
	"NI": "Nicaragua",
	"NL": "Netherlands",
	"NO": "Norway",
	"NP": "Nepal",
	"NR": "Nauru",
	"NU": "Niue",
	"NZ": "New Zealand",
	"OM": "Oman",
	"PA": "Panama",
	"PE": "Peru",
	"PF": "French Polynesia",
	"PG": "Papua New Guinea",
	"PH": "Philippines",
	"PK": "Pakistan",
	"PL": "Poland",
	"PM": "Saint Pierre and Miquelon",
	"PN": "Pitcairn",
	"PR": "Puerto Rico",
	"PT": "Portugal",
	"PW": "Palau",
	"PY": "Paraguay",
	"QA": "Qatar",
	"RO": "Romania",
	"RS": "Serbia",
	"RU": "Russian Federation",
	"RW": "Rwanda",
	"SA": "Saudi Arabia",
	"SB": "Solomon Islands",
	"SC": "Seychelles",
	"SD": "Sudan",
	"SE": "Sweden",
	"SG": "Singapore",
	"SI": "Slovenia",
	"SJ": "Svalbard and Jan Mayen",
	"SK": "Slovakia",
	"SL": "Sierra Leone",
	"SM": "San Marino",
	"SN": "Senegal",
	"SO": "Somalia",
	"SR": "Suriname",
	"ST": "Sao Tome and Principe",
	"SV": "El Salvador",
	"SY": "Syria",
	"SZ": "Swaziland",
	"TC": "Turks and Caicos Islands",
	"TD": "Chad",
	"TF": "French Southern Territories",
	"TG": "Togo",
	"TH": "Thailand",
	"TJ": "Tajikistan",
	"TK": "Tokelau",
	"TM": "Turkmenistan",
	"TN": "Tunisia",
	"TO": "Tonga",
	"TR": "Turkey",
	"TT": "Trinidad and Tobago",
	"TV": "Tuvalu",
	"TW": "Taiwan",
	"TZ": "Tanzania",
	"UA": "Ukraine",
	"UG": "Uganda",
	"UM": "United States Minor Outlying Islands",
	"US": "United States",
	"UY": "Uruguay",
	"UZ": "Uzbekistan",
	"VC": "Saint Vincent and the Grenadines",
	"VE": "Venezuela, Bolivarian Republic of",
	"VN": "Vietnam",
	"VU": "Vanuatu",
	"WF": "Wallis and Futuna",
	"WS": "Samoa",
	"YE": "Yemen",
	"YT": "Mayotte",
	"ZA": "South Africa",
	"ZM": "Zambia",
	"ZW": "Zimbabwe",
}


UNICOMMERCE_INDIAN_STATES_MAPPING = {
	"AN": "Andaman and Nicobar Islands",
	"AP": "Andhra Pradesh",
	"AR": "Arunachal Pradesh",
	"AS": "Assam",
	"BR": "Bihar",
	"CH": "Chandigarh",
	"CT": "Chhattisgarh",
	"DN": "Dadra and Nagar Haveli and Daman and Diu",
	"DD": "Dadra and Nagar Haveli and Daman and Diu",
	"DL": "Delhi",
	"GA": "Goa",
	"GJ": "Gujarat",
	"HR": "Haryana",
	"HP": "Himachal Pradesh",
	"JK": "Jammu and Kashmir",
	"KA": "Karnataka",
	"KL": "Kerala",
	"LD": "Lakshadweep Islands",
	"MP": "Madhya Pradesh",
	"MH": "Maharashtra",
	"MN": "Manipur",
	"ML": "Meghalaya",
	"MZ": "Mizoram",
	"NL": "Nagaland",
	"OR": "Odisha",
	"PY": "Pondicherry",
	"PB": "Punjab",
	"RJ": "Rajasthan",
	"SK": "Sikkim",
	"TN": "Tamil Nadu",
	"TR": "Tripura",
	"UP": "Uttar Pradesh",
	"WB": "West Bengal",
	"TL": "Telangana",
	"AD": "Andhra Pradesh",
	"UT": "Uttarakhand",
	"UL": "Uttarakhand",
	"JH": "Jharkhand",
	"JR": "Jharkhand",
}
