Merge branch 'v5.0' of https://github.com/frappe/erpnext into foreign_currency_calc
diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/ni_ni_chart_template.json b/erpnext/accounts/doctype/account/chart_of_accounts/ni_ni_chart_template.json
new file mode 100644
index 0000000..6db540a
--- /dev/null
+++ b/erpnext/accounts/doctype/account/chart_of_accounts/ni_ni_chart_template.json
@@ -0,0 +1,432 @@
+{
+	"country_code": "ni",
+	"name": "Catalogo de Cuentas",
+	"is_active": "Yes",
+	"tree": {
+		"Activo": {
+			"Activo Corriente": {
+				"Efectivo en Caja y Bancos": {
+					"Caja": {
+						"Caja General Moneda Nacional": {
+							"account_type": "Cash"
+						},
+						"Caja General Moneda Extrangera": {
+							"account_type": "Cash"
+						},
+						"Caja Chica Moneda Nacional": {
+							"account_type": "Cash"
+						},
+						"Caja Chica Moneda Extrangera": {
+							"account_type": "Cash"
+						},
+						"Fondos por Depositar": {
+							"account_type": "Cash"
+						}
+					},
+					"Cuentas Bancarias": {
+						"Cuenta Corriente Moneda Nacional": {
+							"account_type": "Bank"
+						},
+						"Cuenta Corriente Moneda Extrangera": {
+							"account_type": "Bank"
+						}
+					},
+					"Otros Equivalentes a Efectivo": {
+						"group_or_ledger": "Group",
+						"account_type": "Cash"
+					}
+				},
+				"Activos Financieros Realizables a Corto Plazo": {
+					"Inversiones a Corto Plazo": {},
+					"Bonos y Acciones Disponibles para la Venta": {},
+					"Certificados Bancarios": {},
+					"Otros Valores Negociables a Corto Plazo": {}
+				},
+				"Cuentas y Documentos por Cobrar a Clientes": {
+					"Cuentas por Cobrar Moneda Nacional": {
+						"account_type": "Receivable"
+					},
+					"Cuentas por Cobrar Moneda Extrangera": {
+						"account_type": "Receivable"
+					},
+					"Documentos por Cobrar Moneda Nacional": {
+						"account_type": "Receivable"
+					},
+					"Documentos por Cobrar Moneda Extrangera": {
+						"account_type": "Receivable"
+					},
+					"Cuentas por Cobrar por Exportaciones": {
+						"account_type": "Receivable"
+					},
+					"Estimacion para Cuentas Incobrables": {}
+				},
+				"Inventarios": {
+					"group_or_ledger": "Group",
+					"account_type": "Stock"
+				},
+				"Impuestos Acreditables": {
+					"Impuesto a Valor Agregado Acreditable": {
+						"IVA Acreditable por Compra de Bienes": {
+							"account_type": "Tax"
+						},
+						"IVA Acreditable por Importaciones": {
+							"account_type": "Tax"
+						},
+						"IVA Acreditable por Prestacion de Servicios": {
+							"account_type": "Tax"
+						},
+						"Acreditacion Proporcional": {}
+					},
+					"Anticipos de IR o Pago Minimo Definitivo": {},
+					"Retenciones a Cuenta de IR Acreditables": {
+						"Retencion por V/Bienes o P/Servicios 2%": {
+							"account_type": "Tax"
+						},
+						"Retencion Operaciones Targeta Debito/Credito 1.5%": {
+							"account_type": "Tax"
+						}
+					},
+					"Retenciones a Cuenta de IMI Acreditables": {},
+					"Retenciones Definitivas Sobre Rentas o Ganancias de Capital": {}
+				},
+				"Otras Cuentas por Cobrar": {
+					"group_or_ledger": "Group",
+					"account_type": "Receivable"
+				}
+			},
+			"Activo no Corriente": {
+				"Propiedad Planta y Equipo": {
+					"Terrenos": {},
+					"Edificios": {},
+					"Almacenes": {},
+					"Otros Activos Inmobiliarios": {},
+					"Parque Vehicular": {},
+					"Equipo de Computo": {},
+					"Mobiliario y Equipo de Oficinas": {},
+					"Maquinaria Industrial": {},
+					"Otra Bienes Mobiliarios": {},
+					"Depresiacion Acumulada": {},
+					"account_type": "Fixed Asset"
+				},
+				"Inversiones Permanentes": {
+					"Inversiones Permanentes": {
+						"group_or_ledger": "Group",
+						"account_type": "Fixed Asset"
+					},
+					"Negocios Conjuntos": {
+						"group_or_ledger": "Group",
+						"account_type": "Fixed Asset"
+					}
+				},
+				"Bienes en Arrendamiento Financiero": {
+					"Locales y Edificios en Arrendamiento": {},
+					"Equipos y Maquinaria en Arrendamiento": {}
+				},
+				"Activos Intangibles": {
+					"Patentes": {
+						"group_or_ledger": "Group"
+					},
+					"Marcas Registradas": {
+						"group_or_ledger": "Group"
+					},
+					"Derechos de Autor": {
+						"group_or_ledger": "Group"
+					},
+					"Concesiones": {
+						"group_or_ledger": "Group"
+					},
+					"Licencias": {
+						"group_or_ledger": "Group"
+					},
+					"Gastos de investigacion": {
+						"group_or_ledger": "Group"
+					},
+					"Amortizacion de Activos Intangibles": {
+						"group_or_ledger": "Group"
+					},
+					"Deterioro de Valor de Activos Intangibles": {}
+				},
+				"Amortizables": {
+					"Gastos de Consitucion": {},
+					"Gastos Pre Operativos": {},
+					"Mejoras en Bienes Arrendados": {
+						"group_or_ledger": "Group"
+					},
+					"Amortizacion de Activos Amortizables": {},
+					"Deterioro de Valaor de Activos Amortizables": {}
+				},
+				"Cuentas por Cobrar a Largo Plazo": {
+					"Creditos a Largo Plazo": {
+						"group_or_ledger": "Group"
+					}
+				},
+				"Inversiones a Largo Plazo": {
+					"Depositos Bancarios a Plazo": {
+						"group_or_ledger": "Group"
+					},
+					"Intereses percibidos por adelantado": {
+						"group_or_ledger": "Group"
+					},
+					"Titulos y Acciones": {
+						"group_or_ledger": "Group"
+					}
+				},
+				"Activo por Impuestos Diferidos": {
+					"group_or_ledger": "Group"
+				}
+			},
+			"root_type": "Asset"
+		},
+		"Pasivo": {
+			"Pasivo Corriente": {
+				"Cuentas por Pagar Proveedores": {
+					"Cuentas por Pagar Moneda Nacional": {
+						"account_type": "Payable"
+					},
+					"Cuentas por Pagar Moneda Extrangera": {
+						"account_type": "Payable"
+					},
+					"Documentos por Pagar Moneda Nacional": {
+						"account_type": "Payable"
+					},
+					"Documentos por Pagar Moneda Extrangera": {
+						"account_type": "Payable"
+					},
+					"Cuentas por Pagar por Importaciones": {
+						"account_type": "Payable"
+					}
+				},
+				"Anticipos de Clientes": {},
+				"Pasivos Financieros a Corto Plazo": {
+					"Prestamos por Pagar a Corto Plazo": {
+						"group_or_ledger": "Group"
+					},
+					"Sobregiros Bancarios": {
+						"group_or_ledger": "Group"
+					},
+					"Otras Deudas Bancarias": {
+						"group_or_ledger": "Group"
+					}
+				},
+				"Gastos por Pagar": {
+					"Servicios Basicos": {
+						"group_or_ledger": "Group"
+					},
+					"Prestaciones Sociales": {
+						"group_or_ledger": "Group"
+					},
+					"Salarios por Pagar": {}
+				},
+				"Provisiones por Pagar": {
+					"Pasivos Laborales": {
+						"Indemnizacion Laboral": {},
+						"Aguinaldo por Pagar": {}
+					},
+					"Reclamos por Pagar": {},
+					"Responsabilidad frente a terceros": {}
+				},
+				"Impuestos por Pagar": {
+					"Impuesto al Valor Agregado por Pagar": {
+						"account_type": "Tax"
+					},
+					"Impuesto sobre la Renta": {
+						"account_type": "Tax"
+					},
+					"Impuestos Municipales": {
+						"account_type": "Tax"
+					}
+				},
+				"Retenciones por Pagar": {
+					"Rentas del Trabajo": {
+						"Retencion Rentas del Trabajo Tarifa Progresiva": {
+							"account_type": "Tax"
+						},
+						"Retencion Definitiva por Rentas del Trabajo": {
+							"account_type": "Tax"
+						}
+					},
+					"Rentas de Actividades Economicas": {
+						"Retencion 2% por C/Bienes o P/Servicios": {
+							"account_type": "Tax"
+						},
+						"Retencion 10% Servicios Profesionales": {
+							"account_type": "Tax"
+						},
+						"Retencion 3% compra Bienes Agropecuarios": {
+							"account_type": "Tax"
+						},
+						"Retencion 5% compra Madera en Rollo": {
+							"account_type": "Tax"
+						},
+						"Otras Retenciones 10%": {
+							"account_type": "Tax"
+						}
+					},
+					"Rentas y Ganancias de Capital": {
+						"Retencion Defintiva 10% por Rentas de Capital": {
+							"account_type": "Tax"
+						},
+						"Retencion Definitiva 5% por Rentas de Capital": {
+							"account_type": "Tax"
+						},
+						"Retencion Definitiva 10% por Ganancia de Capital": {
+							"account_type": "Tax"
+						},
+						"Retencion Definitiva Actividades Economicas No Residentes": {
+							"account_type": "Tax"
+						},
+						"Retencion Definitiva Transacciones Bursatiles": {
+							"account_type": "Tax"
+						},
+						"Retenciones Defintiva 5% Fondos de Inversion": {
+							"account_type": "Tax"
+						}
+					},
+					"Retencion 17% Operaciones con Paraisos Fiscales": {
+						"account_type": "Tax"
+					}
+				},
+				"Otras Cuentas por Pagar": {
+					"group_or_ledger": "Group"
+				}
+			},
+			"Pasivo No Corriente": {
+				"Prestamos a Largo Plazo": {
+					"group_or_ledger": "Group"
+				},
+				"Cuentas por Pagar a Largo Plaso": {
+					"group_or_ledger": "Group"
+				},
+				"Otras Cuentas por Pagar a Largo Plazo": {
+					"group_or_ledger": "Group"
+				},
+				"Otros Pasivos Financieros a Largo Plaso": {
+					"group_or_ledger": "Group"
+				}
+			},
+			"Obligaciones por Arrendamiento Financiero a Largo Plazo": {
+				"group_or_ledger": "Group"
+			},
+			"Pasivo por Impuestos Diferidos": {
+				"group_or_ledger": "Group"
+			},
+			"root_type": "Liability"
+		},
+		"Patrimonio": {
+			"Aporte de Socios": {
+				"Capital": {
+					"Capital Social Pagado": {
+						"account_type": "Equity"
+					},
+					"Capital Social no Pagado": {
+						"account_type": "Equity"
+					}
+				}
+			},
+			"Donaciones": {
+				"group_or_ledger": "Group"
+			},
+			"Ganancias Acumuladas": {
+				"Reservas": {
+					"Reservas Legales": {
+						"account_type": "Equity"
+					},
+					"Reservas Voluntarias": {
+						"account_type": "Equity"
+					}
+				},
+				"Resultados": {
+					"Resultados Acumulados": {
+						"account_type": "Equity"
+					},
+					"Ajustes a Periodos Anteriores": {
+						"account_type": "Equity"
+					},
+					"Resultado del ejercicio": {
+						"account_type": "Equity"
+					}
+				}
+			},
+			"root_type": "Equity"
+		},
+		"Ingresos": {
+			"Ventas": {
+				"Venta de Bienes o Prestacion de Servicios Grabados": {},
+				"Venta de Bienes o Prestacion de Servicios Exentos": {},
+				"Venta de Bienes o Prestacion de Servicios Exonerados": {},
+				"Venta por Exportaciones": {}
+			},
+			"Otros Ingresos Grabables": {
+				"Ganacia Cambiaria": {},
+				"Sobrante en Arqueo de Caja": {},
+				"Otros Ingresos Grabables": {}
+			},
+			"Ingresos no Grabables": {
+				"Ingreso por Rentas y Ganacias de Capital sujetas a Retencion Definitiva": {},
+				"Interes Bancarios": {},
+				"Otros Ingresos no Grabables": {}
+			},
+			"root_type": "Income"
+		},
+		"Costos y Gastos": {
+			"Costo de Venta": {
+				"Costo de Bienes": {},
+				"Costo de Servicios": {},
+				"Costo de Produccion": {},
+				"account_type": "Cost of Goods Sold"
+			},
+			"Gastos de Ventas": {
+				"Publicidad": {},
+				"Mercadeo": {},
+				"Muestras Gratis": {},
+				"Regalosa Clientes": {},
+				"Fletes": {},
+				"Promociones": {}
+			},
+			"Gastos de Administracion": {
+				"Alquileres": {},
+				"Combustible": {},
+				"Servicios Basicos": {
+					"Energia Electrica": {},
+					"Agua Potable": {},
+					"Internet": {},
+					"Telefono Fijo": {},
+					"Celular": {},
+					"Costos por Servicios WEB": {}
+				},
+				"Vigilancia": {},
+				"Gastos Varios": {},
+				"Mantenimiento y Reparaciones": {},
+				"Papeleria": {},
+				"Representacion": {},
+				"Amortizaciones": {},
+				"Inatec": {},
+				"Indemnizacion": {},
+				"Fletes y Correos": {},
+				"Cuentas Incobrables": {},
+				"Capacitacion al Personal": {},
+				"Uniformes": {},
+				"Seguros": {},
+				"Donaciones": {},
+				"Impuesto Municipal": {},
+				"Matricula": {},
+				"Recoleccion de Basura": {},
+				"IVA Proporcional no Acreditado": {},
+				"Ayuda a Empleados": {}
+			},
+			"Gastos por Servicios Profesionales y Tecnicos": {},
+			"Gastos por Salarios y Otras Compensaciones": {},
+			"Gastopor Depreciacion": {},
+			"Otros Gastos": {
+				"Perdida Cambiario": {},
+				"Perdida e nVenta de Activo Fijo": {},
+				"Siniestros": {},
+				"Certificacion de Cheques y Chequeras": {}
+			},
+			"Costos y Gastos No Deducibles": {},
+			"Impuesto por Rentas y Ganancias de Capital": {},
+			"Impuesto sobre la Rentade Activividades Economicas": {},
+			"root_type": "Expense"
+		}
+	}
+}
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index a962248..67b53f6 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -35,6 +35,7 @@
 		self.validate_sales_order()
 		self.validate_warehouse()
 		self.calculate_operating_cost()
+		self.validate_delivery_date()
 
 		from erpnext.utilities.transaction_base import validate_uom_is_integer
 		validate_uom_is_integer(self, "stock_uom", ["qty", "produced_qty"])
@@ -219,6 +220,13 @@
 		else:
 			self.actual_start_date = None
 			self.actual_end_date = None
+			
+	def validate_delivery_date(self):
+		if self.planned_start_date and self.expected_delivery_date and getdate(self.expected_delivery_date) < getdate(self.planned_start_date):
+			frappe.throw(_("Expected Delivery Date cannot be greater than Planned Start Date"))
+			
+		if self.planned_end_date and self.expected_delivery_date and getdate(self.expected_delivery_date) < getdate(self.planned_end_date):
+			frappe.msgprint(_("Production might not be able to finish by the Expected Delivery Date."))
 
 @frappe.whitelist()
 def get_item_details(item):
diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py
index d679b94..00f7ee6 100644
--- a/erpnext/manufacturing/doctype/workstation/workstation.py
+++ b/erpnext/manufacturing/doctype/workstation/workstation.py
@@ -32,7 +32,7 @@
 
 	def validate_overlap_for_operation_timings(self):
 		for d in self.get("working_hours"):
-			existing = frappe.db.sql_list("""select idx from `tabWorkstation Operation Hours`
+			existing = frappe.db.sql_list("""select idx from `tabWorkstation Working Hour`
 				where parent = %s and name != %s
 					and (
 						(start_time between %s and %s) or
diff --git a/erpnext/manufacturing/doctype/workstation_working_hour/workstation_working_hour.json b/erpnext/manufacturing/doctype/workstation_working_hour/workstation_working_hour.json
index 2afc2e7..a513cde 100644
--- a/erpnext/manufacturing/doctype/workstation_working_hour/workstation_working_hour.json
+++ b/erpnext/manufacturing/doctype/workstation_working_hour/workstation_working_hour.json
@@ -115,7 +115,7 @@
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 1, 
- "modified": "2014-12-24 14:46:40.678236", 
+ "modified": "2015-02-11 14:55:55.650726", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "Workstation Working Hour", 
diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
index 184c351..9575ce9 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
+++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.json
@@ -1,129 +1,129 @@
 {
- "allow_import": 0,
- "autoname": "LCV.####",
- "creation": "2014-07-11 11:33:42.547339",
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Transaction",
+ "allow_import": 0, 
+ "autoname": "LCV.####", 
+ "creation": "2014-07-11 11:33:42.547339", 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "Transaction", 
  "fields": [
   {
-   "fieldname": "company",
-   "fieldtype": "Link",
-   "in_list_view": 1,
-   "label": "Company",
-   "options": "Company",
-   "permlevel": 0,
+   "fieldname": "company", 
+   "fieldtype": "Link", 
+   "in_list_view": 1, 
+   "label": "Company", 
+   "options": "Company", 
+   "permlevel": 0, 
    "reqd": 1
-  },
+  }, 
   {
-   "fieldname": "purchase_receipts",
-   "fieldtype": "Table",
-   "label": "Purchase Receipts",
-   "options": "Landed Cost Purchase Receipt",
+   "fieldname": "purchase_receipts", 
+   "fieldtype": "Table", 
+   "label": "Purchase Receipts", 
+   "options": "Landed Cost Purchase Receipt", 
    "permlevel": 0
-  },
+  }, 
   {
-   "fieldname": "get_items_from_purchase_receipts",
-   "fieldtype": "Button",
-   "label": "Get Items From Purchase Receipts",
+   "fieldname": "get_items_from_purchase_receipts", 
+   "fieldtype": "Button", 
+   "label": "Get Items From Purchase Receipts", 
    "permlevel": 0
-  },
+  }, 
   {
-   "fieldname": "items",
-   "fieldtype": "Table",
-   "label": "Purchase Receipt Items",
-   "no_copy": 1,
-   "options": "Landed Cost Item",
-   "permlevel": 0,
+   "fieldname": "items", 
+   "fieldtype": "Table", 
+   "label": "Purchase Receipt Items", 
+   "no_copy": 1, 
+   "options": "Landed Cost Item", 
+   "permlevel": 0, 
    "read_only": 0
-  },
+  }, 
   {
-   "fieldname": "taxes",
-   "fieldtype": "Table",
-   "label": "Taxes and Charges",
-   "options": "Landed Cost Taxes and Charges",
+   "fieldname": "taxes", 
+   "fieldtype": "Table", 
+   "label": "Taxes and Charges", 
+   "options": "Landed Cost Taxes and Charges", 
    "permlevel": 0
-  },
+  }, 
   {
-   "fieldname": "sec_break1",
-   "fieldtype": "Section Break",
-   "options": "Simple",
-   "permlevel": 0,
+   "fieldname": "sec_break1", 
+   "fieldtype": "Section Break", 
+   "options": "Simple", 
+   "permlevel": 0, 
    "precision": ""
-  },
+  }, 
   {
-   "fieldname": "total_taxes_and_charges",
-   "fieldtype": "Currency",
-   "label": "Total Taxes and Charges",
-   "options": "Company:company:default_currency",
-   "permlevel": 0,
-   "read_only": 1,
+   "fieldname": "total_taxes_and_charges", 
+   "fieldtype": "Currency", 
+   "label": "Total Taxes and Charges", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "read_only": 1, 
    "reqd": 1
-  },
+  }, 
   {
-   "fieldname": "amended_from",
-   "fieldtype": "Link",
-   "label": "Amended From",
-   "no_copy": 1,
-   "options": "Landed Cost Voucher",
-   "permlevel": 0,
-   "print_hide": 1,
+   "fieldname": "amended_from", 
+   "fieldtype": "Link", 
+   "label": "Amended From", 
+   "no_copy": 1, 
+   "options": "Landed Cost Voucher", 
+   "permlevel": 0, 
+   "print_hide": 1, 
    "read_only": 1
-  },
+  }, 
   {
-   "fieldname": "col_break1",
-   "fieldtype": "Column Break",
-   "permlevel": 0,
+   "fieldname": "col_break1", 
+   "fieldtype": "Column Break", 
+   "permlevel": 0, 
    "precision": ""
-  },
+  }, 
   {
-   "default": "Amount",
-   "fieldname": "distribute_charges_based_on",
-   "fieldtype": "Select",
-   "label": "Distribute Charges Based On",
-   "options": "\nQty\nAmount",
-   "permlevel": 0,
-   "precision": "",
+   "default": "Amount", 
+   "fieldname": "distribute_charges_based_on", 
+   "fieldtype": "Select", 
+   "label": "Distribute Charges Based On", 
+   "options": "\nQty\nAmount", 
+   "permlevel": 0, 
+   "precision": "", 
    "reqd": 1
-  },
+  }, 
   {
-   "fieldname": "sec_break2",
-   "fieldtype": "Section Break",
-   "permlevel": 0,
+   "fieldname": "sec_break2", 
+   "fieldtype": "Section Break", 
+   "permlevel": 0, 
    "precision": ""
-  },
+  }, 
   {
-   "fieldname": "landed_cost_help",
-   "fieldtype": "HTML",
-   "label": "Landed Cost Help",
-   "options": "",
+   "fieldname": "landed_cost_help", 
+   "fieldtype": "HTML", 
+   "label": "Landed Cost Help", 
+   "options": "", 
    "permlevel": 0
   }
- ],
- "icon": "icon-usd",
- "is_submittable": 1,
- "modified": "2015-02-05 05:11:40.305974",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Landed Cost Voucher",
- "name_case": "",
- "owner": "Administrator",
+ ], 
+ "icon": "icon-usd", 
+ "is_submittable": 1, 
+ "modified": "2015-02-11 16:21:49.528566", 
+ "modified_by": "Administrator", 
+ "module": "Stock", 
+ "name": "Landed Cost Voucher", 
+ "name_case": "", 
+ "owner": "Administrator", 
  "permissions": [
   {
-   "amend": 1,
-   "cancel": 1,
-   "create": 1,
-   "delete": 1,
-   "export": 1,
-   "permlevel": 0,
-   "read": 1,
-   "report": 1,
-   "role": "Material Manager",
-   "share": 1,
-   "submit": 1,
+   "amend": 1, 
+   "cancel": 1, 
+   "create": 1, 
+   "delete": 1, 
+   "export": 1, 
+   "permlevel": 0, 
+   "read": 1, 
+   "report": 1, 
+   "role": "Material Manager", 
+   "share": 1, 
+   "submit": 1, 
    "write": 1
   }
- ],
- "sort_field": "modified",
+ ], 
+ "sort_field": "modified", 
  "sort_order": "DESC"
-}
+}
\ No newline at end of file