<?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="human-resource" package="com.axelor.apps.hr.db"/>

	<entity name="ExpenseLine" cacheable="true">
	    <!-- Original part of expenseLine -->
	    <many-to-one name="user" ref="com.axelor.auth.db.User" title="User" column="user_id"/>
	    <many-to-one name="project" ref="com.axelor.apps.project.db.Project" title="Project" />
	    <many-to-one name="expenseProduct" ref="com.axelor.apps.base.db.Product" title="Expense Type" required="true" />
	    <date name="expenseDate" title="Expense date" required="true"/>
	    <decimal name="untaxedAmount" title="Untaxed amount" readonly="true"/>
	    <decimal name="totalTax" title="Total tax" />
	    <decimal name="totalAmount" title="Total amount with tax" required="true"/>
	    <string name="comments" title="Comments" large="true"/>
	    <boolean name="toInvoice"/>
		<boolean name="invoiced" readonly="true"/>
		<many-to-one name="expense" ref="com.axelor.apps.hr.db.Expense" title="Expense" />
		<many-to-one name="generalExpense" ref="com.axelor.apps.hr.db.Expense" title="General Expense"/>
		<many-to-one name="kilometricExpense" ref="com.axelor.apps.hr.db.Expense" title="Kilometric Allowance" />
		<one-to-many name="analyticMoveLineList" ref="com.axelor.apps.account.db.AnalyticMoveLine" title="Analytic distribution lines" mappedBy="expenseLine"/>
		<many-to-one name="analyticDistributionTemplate" title="Analytic distribution template" ref="com.axelor.apps.account.db.AnalyticDistributionTemplate"/>
        <many-to-one name="justificationMetaFile" ref="com.axelor.meta.db.MetaFile" title="Justification" />
	  
		<!-- integration of KilometricAllowance -->
  		<many-to-one name="kilometricAllowParam" ref="com.axelor.apps.hr.db.KilometricAllowParam" title="K.A.P."/>
        <integer name="kilometricTypeSelect" title="Type"  selection="hr.kilometric.allowance.type.select"/>
        <decimal name="distance" title="Distance travelled" min="0"/>
        <string name="fromCity" title="Starting city" />
        <string name="toCity" title="Arriving city" />
        
        <string name="fullName" namecolumn="true">
			<![CDATA[
	  		String fullName = "";
	  		
	  		if(expense != null && expense.getFullName() != null)  {
				fullName += expense.getFullName();
			}
			if (!fullName.isEmpty()) {
				fullName += "-" + id;
			}
			else {
				fullName = id.toString();
			}
			
	  		return fullName;
	  	]]>
	  	</string>

		<extra-code>
		<![CDATA[
			// KILOMETRIC TYPE SELECT
			public static final int KILOMETRIC_TYPE_ONE_WAY = 1;
			public static final int KILOMETRIC_TYPE_ROUND_TRIP = 2;
		]]>
		</extra-code>

  </entity>

</domain-models>
