<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<object-views xmlns="http://axelor.com/xml/ns/object-views"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://axelor.com/xml/ns/object-views http://axelor.com/xml/ns/object-views/object-views_5.2.xsd">
    
    <grid name="reimbursement-grid" title="Reimbursements" model="com.axelor.apps.account.db.Reimbursement">
    	<field name="ref" width="120"/>
        <field name="statusSelect"/>
        <field name="amountToReimburse" aggregate="sum"/>
    </grid>
    
	<form name="reimbursement-form" title="Reimbursement" model="com.axelor.apps.account.db.Reimbursement"  onNew="action-reimbursement-set-default">
		<panel name="mainPanel" >
			<field name="ref" colSpan="12"/>
			<field name="company" canEdit="false" widget="SuggestBox" form-view="company-form" grid-view="company-grid"/>
			<field name="partner" form-view="partner-form" grid-view="partner-grid" domain="self.isContact = false AND :company member of self.companySet"/>
		</panel>
		
		<panel name="reimbursementDetailsPanel" title="Reimbursement details">
			<field name="amountToReimburse"/>
			<field name="amountReimbursed"/>
			<field name="bankDetails" domain="self.active = true" form-view="bank-details-form" grid-view="bank-details-grid"/>
		</panel>
		
		<panel name="reasonPanel" title="Reason">
			<field name="description" colSpan="12" showTitle="false"/>
		</panel>
		
		<panel  name="rejectInformationPanel" title="Reject Information" showIf="rejectedOk">
			<field name="rejectedOk"/>
			<field name="interbankCodeLine" grid-view="interbank-code-grid" form-view="interbank-code-form"/>
			<field name="rejectDate"/>
			<field name="rejectMoveLine" grid-view="move-line-grid" form-view="move-line-form"/>
		</panel> 
		
		<panel-related name="moveLineSetPanel" field="moveLineSet" hideIf="statusSelect == 1" colSpan="12" grid-view="move-line-grid" form-view="move-line-form"/>
		
		<panel sidebar="true" name="infoPanel" title="Info">
			<field name="statusSelect"/>
			<button name="validateReimbursementBtn" title="Validate" onClick="save,com.axelor.apps.account.web.ReimbursementController:validateReimbursement,save" showIf="statusSelect == 2"/>
		</panel>
	</form>
    
	<action-record name="action-reimbursement-set-default" model="com.axelor.apps.account.db.Reimbursement">
	    <field name="company"  expr="eval:__user__.activeCompany" if="__user__.activeCompany != null"/>
    	<field name="company"  expr="eval:__repo__(Company).all().fetchOne()" if="__user__.activeCompany == null &amp;&amp; __repo__(Company).all().fetch().size == 1"/>
	</action-record>
	
	<search-filters name="reimbursement-filters" model="com.axelor.apps.account.db.Reimbursement" title="Reimbursement filters">
		<filter title="Reimbursements to validate">
			<domain>self.statusSelect = 2</domain>
		</filter>
		<filter title="Rejected reimbursements">
			<domain>self.rejectedOk = true</domain>
		</filter>	
	</search-filters>   
	
</object-views>