<?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 name="PaymentVoucher" sequential="true" lang="java">

		<string name="ref" title="Reference" namecolumn="true" required="false"/>
		<many-to-one name="partner" title="Partner" ref="com.axelor.apps.base.db.Partner" required="false"/>
		<many-to-one name="account" ref="com.axelor.apps.account.db.Account" title="Partner account"/>
		<many-to-one name="accountOther" ref="com.axelor.apps.account.db.Account" title="Account other"/>
		<many-to-one name="paymentMode" ref="com.axelor.apps.account.db.PaymentMode" title="Payment mode" required="false"/>
	   	<many-to-one name="companyBankDetails" ref="com.axelor.apps.base.db.BankDetails" title="Company bank details"/>
	   	<many-to-one name="clientBanks" ref="com.axelor.apps.base.db.ClientBank" title="Client bank details"/>
	    <date name="paymentDate" title="Payment date"/>
		<decimal name="paidAmount" title="Amount paid" />
		<many-to-one name="user" column="user_id" ref="com.axelor.auth.db.User" title="User" readonly="true"/>
		<many-to-one name="moveLine" ref="com.axelor.apps.account.db.MoveLine" title="Overdue moveline" />
		<many-to-one name="moveLinePay" ref="com.axelor.apps.account.db.MoveLine" title="Pay moveline" />
		<decimal name="remainingAllocatedAmount" title="Amount Remaining to allocate" />
		<decimal name="allocatedAmount" title="Allocated amount" />
		<one-to-many name="payVoucherDueElementList" ref="com.axelor.apps.account.db.PayVoucherDueElement" title="List of invoices/schedule lines with remaining amount to pay" mappedBy="paymentVoucher" />
		<one-to-many name="payVoucherElementToPayList" ref="com.axelor.apps.account.db.PayVoucherElementToPay" title="List of invoices to pay" mappedBy="paymentVoucher" />
		<integer name="statusSelect" title="Status" default="1" readonly="true" selection="iaccount.payment.voucher.status.select"/>
		<integer name="cashStatusSelect" title="Cash status" default="1" readonly="true" selection="iaccount.cash.status.select"/>
		<integer name="statusTypeSelect" title="Status" default="1" readonly="true" selection="iaccount.payment.voucher.status.type.select"/>
		<many-to-one name="generatedMove" ref="com.axelor.apps.account.db.Move" title="Generated move" readonly="true"/>
		<one-to-many name="generatedMoveList" ref="com.axelor.apps.account.db.Move" title="Generated moves" readonly="true"/>
		<boolean name="hasAutoInput" title="Auto. input." default="false"/>
	 	<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company" required="true"/>
	 	<string name="bankCardTransactionNumber" title="CC Transaction N°" readonly="true"/>
	 	<string name="receiptNo" title="Receipt N°" readonly="true"/>
	 	<string name="email" title="Email to use"/>
	 	<boolean name="toSaveEmailOk" title="Save email sent to contact" default="true"/>
	 	<boolean name="defaultEmailOk" title="Default email address" default="false"/>
 	   	<many-to-many name="batchSet" ref="com.axelor.apps.base.db.Batch" title="Batchs"/>
	  	<many-to-one name="currency" ref="com.axelor.apps.base.db.Currency" required="true" title="Currency"/>
	  	<decimal name="paidAmountInCurrency"  title="Amount paid in currency"/>
	 	
<!-- 	 	<integer name="operationTypeSelect" title="Type de saisie paiement" required="true" selection="ipayment.operation.type.select"/> -->
	 	<integer name="operationTypeSelect" title="Payment type" required="true" selection="iinvoice.operation.type.select"/>
	 	
		<decimal name="remainingAmount" title="Amount remaining to allocate" />	
		
        <string name="chequeNumber" />
        <string name="chequeBank" />
        <string name="chequeOwner" />
        <date name="chequeDate" title="Bank deposit date" />
        <many-to-one name="depositSlip" ref="com.axelor.apps.account.db.DepositSlip" />
		
		
		<string name="label" />
		
		<many-to-one name="confirmedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Confirmed by"/> 
		<date name="confirmationDate" title="Confirmation date" readonly="true"/>
		
		<many-to-one name="acceptedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Accepted by"/> 
		<date name="acceptanceDate" title="acceptance date" readonly="true"/>

		<many-to-one name="requestedByUser" ref="com.axelor.auth.db.User" readonly="true" title="requested by"/> 
		<date name="requestDate" title="request Date" />

		<many-to-one name="recipientUser" ref="com.axelor.auth.db.User" title="recipient"/> 

		<many-to-one name="recipientPartner" ref="com.axelor.apps.base.db.Partner" title="recipient partner"/> 

		<string name="recipientPartnerStr" title="recipient partner"/> 
		
		<date name="invoiceDate" title="invoice Date" />
		<date name="dueDate" title="Due Date" />
		<date name="puttingtDate" title="Credit Date" />
		<!-- creadit date -->
		<date name="creditDate" title="Credit Date" />
		<date name="cagexDeadline" title="Cagex deadline" />
		<!-- date d'enlevement -->
		<date name="deliveryDate" title="Delivery Date" />
		<date name="paymentEmissionDate" title="payment emission Date" />

		<boolean name="rejected" default="false" title="Rejected" />
		<date name="rejectedDate" title="Rejected Date" />
		<many-to-one name="rejectedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Rejected by"/> 
		<integer name="rejectedInstanceSelect" title="Status"  selection="iaccount.payment.voucher.rejection.status.select" />
		<decimal name="rejectAmountFee"  title="Reject Amount Fee"/>
		<decimal name="amountAfterRejection"  title="Amount after rejection"/>
		<string name="rejectionRaison" large="true"/>

		<integer name="sort" title="Sort" default="1"  selection="iaccount.payment.voucher.sort.select"/>

		<!-- <string name="clientBank" title="Client bank"  selection="iaccount.payment.voucher.client.bank"/> -->

	 	<string name="commercialTransactionNumber" title="Commercial Transaction N°" />

		<many-to-one name="originPaymentVoucher" ref="com.axelor.apps.account.db.PaymentVoucher" title="Payment voucher"/>

		<many-to-one name="paymentCondition" ref="com.axelor.apps.account.db.PaymentCondition" title="Payment condition" />

		<date name="approvalDate" title="Approval date" />
		<many-to-one name="approvedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Approved by"/> 

		<date name="refusalDate" title="Refusal date" />
		<many-to-one name="refusedByUser" ref="com.axelor.auth.db.User" readonly="true" title="Refused by"/> 
        
		<!-- date reception sur service finnance -->
		<date name="receptionDateInOffice" title="Reception date in office" />

  		<many-to-one name="purchaseOrder" ref="com.axelor.apps.purchase.db.PurchaseOrder" title="Purchase Order" />

		<string name="debitCreditSelect" title="Debit/Credit" selection="move.voucher.debit.credit.select"/>

		<boolean name="cashFunding" default="false" title="Cash funding"/>

		<many-to-one ref="CashAccountConfig" name="cashAccountConfig" title="Cash account config"/>

		<decimal name="initialTheoricalSolde" title="Intial theoretical solde"/>
		<decimal name="theoricalSolde" title="Theoretical solde"/>

        <unique-constraint columns="ref,company"/>
		<unique-constraint columns="receiptNo,company"/>

		<extra-code><![CDATA[
		
	   	// STATUS SELECT
		public static final int STATUS_DRAFT = 1;
        public static final int STATUS_WAITING_FOR_DEPOSIT_SLIP = 2;
		public static final int STATUS_CONFIRMED = 3;
		public static final int STATUS_REQUESTED = 0;
		public static final int STATUS_ACCEPTED = 4;
		public static final int STATUS_APPROUVED = 5;
		public static final int STATUS_REJECTED = 6;
		public static final int STATUS_REFUSED = 7;
		
	   	// OPERATION TYPE SELECT
		public static final int OPERATION_TYPE_SUPPLIER_PURCHASE = 1;
		public static final int OPERATION_TYPE_SUPPLIER_REFUND = 2;
		public static final int OPERATION_TYPE_CLIENT_SALE = 3;
		public static final int OPERATION_TYPE_CLIENT_REFUND = 4;
		public static final int OPERATION_TYPE_CLIENT_SALE_CLIENT_REFUND = 6;
		public static final int OPERATION_TYPE_SUPPLIER_PURCHASE_SUPPLIER_REFUND = 7;
		public static final int OTHER = 8;
		public static final int CASH = 9;

		]]></extra-code>

		 <track>
      		<field name="statusSelect"/>
			<field name="cashStatusSelect"/>
			<message if="true" on="CREATE">Voucher created</message>
      		<message if="statusSelect == 3" tag="important">Confirmed</message>
      	</track>

	
  	</entity>

</domain-models>