<?xml version="1.0" ?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">

  <module name="project" package="com.axelor.apps.project.db"/>

	<entity name="Project" cacheable="true">
        
  		<many-to-one name="currency" ref="com.axelor.apps.base.db.Currency" title="Currency" massUpdate="true"/>
		<integer name="invoicingSequenceSelect" title="Invoicing sequence" selection="business.project.invoicing.sequence.select"/>
		<string name="invoicingComment" title="Invoicing comment" large="true" />
		<decimal name="totalSaleOrdersFinalized" title="Finalized Orders Total" readonly="true"/>
		<decimal name="totalSaleOrdersConfirmed" title="Confirmed Orders Total" readonly="true"/>
		<decimal name="totalSaleOrdersInvoiced" title="Invoiced Orders Total" readonly="true"/>
		<many-to-one name="priceList" ref="com.axelor.apps.base.db.PriceList" title="Price list"/>

		<decimal name="totalPurchaseOrdersFinalized" title="Finalized Orders Total" readonly="true"/>
		<decimal name="totalPurchaseOrdersConfirmed" title="Confirmed Orders Total" readonly="true"/>
		<decimal name="totalPurchaseOrdersInvoiced" title="Invoiced Orders Total" readonly="true"/>
		
		<decimal name="totalTimesPlanned" title="Planned Times Total" readonly="true"/>
		<decimal name="totalTimesRealised" title="Realised Times Total" readonly="true"/>
		
		<decimal name="totalExpenses" title="ExpensesTotal" readonly="true"/>
		
		<decimal name="totalEstimatedCosts" title="Estimated Costs Total" readonly="true"/>
		<decimal name="totalRealCosts" title="Real Costs Total" readonly="true"/>
		
		<decimal name="totalProducedTurnOver" title="Produced Turnover" readonly="true"/>
		<decimal name="estimatedMargin" title="Estimated Margin" readonly="true"/>
		<decimal name="realTimesMargin" title="Real Margin (Time)" readonly="true"/>
		<decimal name="realInvoicingMargin" title="Real Margin (Invoicing)" readonly="true"/>
		
		<one-to-many name="manualElementList" ref="com.axelor.apps.businessproject.db.ManualElement" title="Manual elements" mappedBy="project"/>
		
	  	<boolean name="invoiced" readonly="true"/>
	  	<string name="unitOnPrinting" selection="hr.time.logging.preference.select" title="Invoicing unit"/>
	  	
	  	<one-to-many name="purchaseOrderLineList" ref="com.axelor.apps.purchase.db.PurchaseOrderLine" title="Purchase order lines" mappedBy="project" orphanRemoval="false"/>
	  	<one-to-many name="saleOrderLineList" ref="com.axelor.apps.sale.db.SaleOrderLine" title="Sale order lines" mappedBy="project" orphanRemoval="false"/>
	  	<one-to-many name="expensesLineList" ref="com.axelor.apps.hr.db.ExpenseLine" title="Expense lines" mappedBy="project" orphanRemoval="false"/>
		<one-to-many name="invoiceLineList" ref="com.axelor.apps.account.db.InvoiceLine" title="Invoice lines" mappedBy="project" orphanRemoval="false"/>
		
		<boolean name="isBusinessProject" title="Business project" />

		<boolean name="toInvoice" title="To invoice"/>
		<boolean name="isInvoicingTimesheet" title="Invoicing timesheet"/>
		<boolean name="isInvoicingExpenses" title="Invoicing Expenses"/>
		<boolean name="isInvoicingPurchases" title="Invoicing Purchases"/>

		<many-to-one name="customerAddress" title="Address" ref="com.axelor.apps.base.db.Address"/>
	 	<extra-code><![CDATA[
		
		   	// TYPE SELECT
		   	public static final int INVOICING_SEQ_EMPTY = 0;
			public static final int INVOICING_SEQ_INVOICE_PRE_TASK = 1;
			public static final int INVOICING_SEQ_INVOICE_POST_TASK = 2;
		
   			public static final int TASK_PER_LINE_ALONE = 1;
   			public static final int TASK_PER_LINE_PHASE = 2;
   			public static final int TASK_PER_LINE_TASK = 3;
		]]></extra-code>


	</entity>

	<enum name="ProjectGeneratorType">
		<item name="PROJECT_ALONE" title="Project alone"/>
		<item name="PHASE_BY_LINE" title="Phase by line"/>
		<item name="TASK_BY_LINE" title="Task by line"/>
		<item name="TASK_TEMPLATE" title="Tasks by product"/>
	</enum>

</domain-models>
