<?xml version="1.0" encoding="UTF-8"?>
<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="account" package="com.axelor.apps.account.db"/>
  
  <entity sequential="true" name="Move" lang="java">
  
    <many-to-one name="journal" ref="Journal" title="Journal" required="true"/>
    <many-to-one name="period" ref="com.axelor.apps.base.db.Period" title="Period" readonly="true" required="true"/>
    <date name="date" column="date_val" title="Date"/> <!--  Only used for Manual Misc. Operations -->
    <string name="reference" title="Reference" namecolumn="true" readonly="true"/>
    <one-to-many name="moveLineList" ref="MoveLine" title="Move lines" mappedBy="move"/>
    <many-to-one name="partner" ref="com.axelor.apps.base.db.Partner" title="Partner"/>
    <many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company" required="true"/>
    <many-to-one name="paymentMode" ref="com.axelor.apps.account.db.PaymentMode" title="Payment Mode"/>
    <many-to-one name="invoice" ref="com.axelor.apps.account.db.Invoice" title="Invoice"/>
    <integer name="statusSelect" title="Status" default="1" readonly="true" selection="iaccount.move.status.select"/>
    <boolean name="rejectOk" title="Rejection" default="false"/>
    <boolean name="getInfoFromFirstMoveLineOk" title="Get information from 1st Move line" default="true"/>
    <string name="exportNumber" title="Accounting Export N°"/>
    <date name="exportDate" title="Export Date"/>
    <boolean name="accountingOk" title="Exported" default="false"/>
    <many-to-one name="accountingReport" ref="com.axelor.apps.account.db.AccountingReport" title="Accounting Export"/>
    <many-to-one name="paymentVoucher" ref="com.axelor.apps.account.db.PaymentVoucher" title="Payment voucher"/>
   	<many-to-one name="companyCurrency" ref="com.axelor.apps.base.db.Currency" title="Company currency"/>
   	<string name="companyCurrencyCode" title="Company currency code"/>
   	<many-to-one name="currency" ref="com.axelor.apps.base.db.Currency" title="Currency"/>
   	<string name="currencyCode" title="Currency code"/>
    <boolean name="ignoreInAccountingOk" title="Ignore in accounting" default="false"/>
    <boolean name="ignoreInDebtRecoveryOk" title="Ignore in debt recovery process" default="false"/>
    <date name="validationDate" title="Validation date"/>
    <integer name="technicalOriginSelect" title="Technical origin" required="true" readonly="true" selection="iaccount.move.technical.origin.select"/>
    <boolean name="adjustingMove" title="Adjusting Move" default="false"/>
    <boolean name="autoYearClosureMove" title="Year closure move"/>
   	<many-to-many name="batchSet" ref="com.axelor.apps.base.db.Batch" title="Batchs"/>
    <integer name="functionalOriginSelect" title="Functional origin" readonly="true" selection="iaccount.move.functional.origin.select"/>

    <unique-constraint columns="reference,company"/>
    
    <extra-code><![CDATA[
	
	   	// STATUS SELECT
		public static final int STATUS_NEW = 1;
		public static final int STATUS_DAYBOOK = 2;
		public static final int STATUS_VALIDATED = 3;
		public static final int STATUS_CANCELED = 4;
		
		// TECHNICAL ORIGIN SELECT
		public static final int TECHNICAL_ORIGIN_ENTRY = 1;
		public static final int TECHNICAL_ORIGIN_AUTOMATIC = 2;
		public static final int TECHNICAL_ORIGIN_TEMPLATE = 3;
		public static final int TECHNICAL_ORIGIN_IMPORT = 4;

		// REVERSE DATE OF REVERSION
		public static final int DATE_OF_REVERSION_TODAY = 1;
		public static final int DATE_OF_REVERSION_ORIGINAL_MOVE_DATE = 2;
		public static final int DATE_OF_REVERSION_CHOOSE_DATE = 3;

		// FUNCTIONAL ORIGIN SELECT
		public static final int FUNCTIONAL_ORIGIN_OPENING = 1;
		public static final int FUNCTIONAL_ORIGIN_CLOSURE = 2;
	]]></extra-code>
    
    <track>
    	<field name="statusSelect"/>
    	<field name="journal"/>
    	<field name="reference"/>
    	<field name="period"/>
    	<field name="partner"/>
    	<field name="currency"/>
    	<field name="companyCurrency"/>
    	<field name="ignoreInAccountingOk"/>
    	<field name="ignoreInDebtRecoveryOk"/>
    	<message if="true" on="CREATE">Move created</message>
    	<message if="statusSelect == 1" tag="important">New move</message>
	    <message if="statusSelect == 2" tag="info">Daybook move</message>
	    <message if="statusSelect == 3" tag="success">Move validated</message>
	    <message if="statusSelect == 4" tag="warning">Move canceled</message>
    </track>
    
  </entity>
</domain-models>
