<?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">
    
<!--     ACCOUNTING REPORT -->
    
	<grid name="accounting-report-grid" title="Accounting reports" model="com.axelor.apps.account.db.AccountingReport">
		<field name="ref" width="120"/>
		<field name="date"/>
		<field name="company" form-view="company-form" grid-view="company-grid" if="__config__.app.getApp('base').getEnableMultiCompany()"/>
		<field name="currency"/>
		<field name="exportTypeSelect"/>
		<field name="typeSelect" selection="accounting.report.type.select"/>
	  <field name="dateFrom"/>
	  <field name="dateTo"/>
	  <field name="period" form-view="period-form" grid-view="period-grid" canEdit="false" canView="false"/>
	  <field name="journal" form-view="journal-form" grid-view="journal-grid"/>
	  <field name="totalDebit" aggregate="sum"/>
		<field name="totalCredit" aggregate="sum"/>
		<field name="balance"/>
		<field name="statusSelect"/>
		<field name="publicationDateTime"/>
	</grid>

	<form name="accounting-report-form" title="Accounting report" model="com.axelor.apps.account.db.AccountingReport"
		onNew="action-accounting-report-record-default">
		<panel name="mainPanel" >
			<field name="ref" readonly="true" />
			<field name="date" readonlyIf="statusSelect == 2"/>
			<field name="typeSelect" readonlyIf="company == null" onChange="action-group-account-accounting-report-typeselect-onchange" selection="accounting.report.type.select" />
			<field name="exportTypeSelect"/>
			<field name="company" canEdit="false" readonlyIf="ref != null" widget="SuggestBox" onChange="action-group-account-accounting-report-company-onchange" form-view="company-form" grid-view="company-grid"/>
			<field name="currency"/>
		</panel>
		
		<panel sidebar="true" name="infoPanel" title="Info">
			<button name="searchBtn" title="Search" hideIf="!typeSelect || [12,15,16,17,2000,2001,3000].indexOf(typeSelect) != -1" onClick="save,action-accounting-report-method-search-move-line,save" />
			<button name="exportBtn" title="Print" icon="fa-print"	onClick="action-group-account-accounting-report-export-click" />
			<field name="statusSelect" />
			<field name="publicationDateTime" />
		</panel>

		<panel-tabs name="mainPanelTab">
			<panel name="filterPanel" title="Filter">
				<field name="year" canEdit="false" hideIf="typeSelect != 12  &amp;&amp; typeSelect != 15 &amp;&amp; typeSelect != 16  &amp;&amp; typeSelect != 17" onChange="action-accounting-report-record-period-dates" onSelect="action-accounting-report-attrs-year-domain" requiredIf="typeSelect == 12 || typeSelect == 15 ||  typeSelect == 16  || typeSelect == 17" grid-view="year-account-grid" form-view="year-account-form" />
				<field name="period" canEdit="false" hideIf="typeSelect == 3000" onChange="action-group-account-accounting-report-period-onchange" onSelect="action-accounting-report-attrs-period-domain" form-view="period-form" grid-view="period-grid" canView="false" />
				<field name="dateFrom" hideIf="typeSelect == 3000" onChange="action-move-Live-report-record-set-date-to" requiredIf="typeSelect == 12 || typeSelect == 15" />
				<field name="dateTo" hideIf="typeSelect == 3000" requiredIf="typeSelect == 12 || typeSelect == 15" />
				<field name="journal" hideIf="!typeSelect || [0,1,2,3,4,5,10,12,13,14,15,16,17].indexOf(typeSelect) != -1" domain="self.statusSelect = 1 AND self.company = :company" form-view="journal-form" grid-view="journal-grid" canEdit="false"/>
				<field name="paymentMode" grid-view="payment-mode-grid" form-view="payment-mode-form" hideIf="!typeSelect || [1,2,3,4,5,10,12,13,14,15,16,17,3000].indexOf(typeSelect) != -1"/>
				<field name="accountSet" hideIf="typeSelect == 2000 || typeSelect == 2001 || typeSelect == 16 || typeSelect == 17 || typeSelect == 12" colSpan="12" form-view="account-form" grid-view="account-grid" widget="TagSelect" canNew="false" domain="self.company = :company AND ((:typeSelect = 3000 AND self.accountType.technicalTypeSelect = 'cash') OR (:typeSelect &lt;&gt; 3000  AND(:typeSelect &lt;&gt;  6 OR self.useForPartnerBalance = true)))"/>
				<field name="partnerSet" hideIf="typeSelect == 2000 || typeSelect == 2001 || typeSelect == 16 || typeSelect == 17 || typeSelect == 12 || typeSelect == 3000" colSpan="12" form-view="partner-form" grid-view="partner-grid" widget="TagSelect" canNew="false" domain=":company member of self.companySet AND self.isContact = false"/>
				<field name="analyticJournal" showIf="typeSelect == 2000 || typeSelect == 2001"  domain="self.company = :company" form-view="analytic-journal-form" grid-view="analytic-journal-grid"/>
				<field name="bankDetailsSet"  if-module="axelor-bank-payment" if="__config__.app.isApp('bank-payment')" showIf="typeSelect == 3000" colSpan="12" form-view="bank-details-form" grid-view="bank-details-grid" widget="TagSelect" canNew="false" onSelect="action-accounting-report-method-set-bank-details-domain"/>
			</panel>
			<panel name="printingInformationsPanel" title="Printing informations" hideIf="!typeSelect || [16,17,3000].indexOf(typeSelect) != -1">
				<field name="global" hideIf="!typeSelect || [0,3,4,10,12,13,15,16,17].indexOf(typeSelect) != -1"	onChange="action-accounting-report-record-global" />
				<field name="globalByDate" hideIf="!typeSelect || [3,4,5,10,11,12,13,14,15,16,17].indexOf(typeSelect) != -1" onChange="action-accounting-report-record-global-by-date" />
				<field name="globalByPartner" hideIf="typeSelect != 3 &amp;&amp; typeSelect != 7" onChange="action-accounting-report-record-global-by-partner" />
				<field name="detailed" hideIf="typeSelect != 4" onChange="action-accounting-report-record-detailed" />
				<field name="displayClosingAccountingMoves" showIf="typeSelect != 5 &amp;&amp; typeSelect != 16 &amp;&amp; typeSelect != 17"/>
				<field name="displayOpeningAccountingMoves" showIf="typeSelect != 5 &amp;&amp; typeSelect != 16 &amp;&amp; typeSelect != 17"/>
				<field name="displayOnlyNotCompletelyLetteredMoveLines" hideIf="typeSelect != 7"/>
				<field name="displayCodeAccountColumnOnPrinting" showIf="typeSelect == 1"/>
				<field name="displayNameAccountColumnOnPrinting" showIf="typeSelect == 1"/>
				<field name="displayMoveLineSequenceOnPrinting" showIf="typeSelect == 1"/>
				<field name="displayCumulativeBalance" showIf="typeSelect==7 || typeSelect==1"/>
			</panel>
		</panel-tabs>
		
		<panel sidebar="true" name="balancePanel" title="Balance" hideIf="typeSelect == 2000 || typeSelect == 2001 || typeSelect == 3000">
			<field name="totalDebit" />
			<field name="totalCredit" />
			<field name="balance" />
		</panel>

	</form>
    
    
<!--     MOVE LINE EXPORT -->
    
    <grid name="accounting-report-export-grid" title="Accounting exports" model="com.axelor.apps.account.db.AccountingReport">
        <field name="ref" width="120"/>
        <field name="date"/>
		<field name="company" canEdit="false" form-view="company-form" grid-view="company-grid"/>
		<field name="typeSelect" selection="accounting.report.type.select.export"/>
        <field name="dateFrom"/>
        <field name="dateTo"/>
        <field name="period" form-view="period-form" grid-view="period-grid" canEdit="false" canView="false" />
        <field name="journal" form-view="journal-form" grid-view="journal-grid"/>
        <field name="totalDebit" aggregate="sum"/>
		<field name="totalCredit" aggregate="sum"/>
		<field name="balance"/>
		<field name="statusSelect"/>
    </grid>
    
	<form name="accounting-report-export-form" title="Accounting export" model="com.axelor.apps.account.db.AccountingReport"
	onNew="action-accounting-report-record-default">
		
		<panel name="searchPanel" title="Search">
			<field name="ref" readonly="true"/>
			<field name="date" title="Export Date fixed to" readonlyIf="statusSelect == 2"/>
			<field name="typeSelect" onChange="action-group-account-accounting-report-typeselect-onchange" selection="accounting.report.type.select.export"/>
			<field name="company" canEdit="false" readonlyIf="ref != null" widget="SuggestBox" onChange="action-group-account-accounting-report-company-onchange" form-view="company-form" grid-view="company-grid"/>
			<field name="year" hideIf="!$contains([1000, 1010], typeSelect)" onChange="action-accounting-report-record-period-dates" onSelect="action-accounting-report-attrs-year-domain" requiredIf="$contains([1000, 1010], typeSelect)" grid-view="year-account-grid" form-view="year-account-form" />
			<field name="period" canEdit="false" onChange="action-group-account-accounting-report-period-onchange" onSelect="action-accounting-report-attrs-period-domain" requiredIf="!$contains([1000, 1010], typeSelect)" form-view="period-form" grid-view="period-grid" canView="false"/>
			<field name="dateFrom" onChange="action-move-Live-report-record-set-date-to" readonlyIf="$contains([1000, 1010], typeSelect) &amp;&amp; period != null "/>
			<field name="dateTo" readonlyIf="$contains([1000, 1010], typeSelect) &amp;&amp; period != null "/>
			<field name="journal" form-view="journal-form" grid-view="journal-grid" hideIf="$contains([1000, 1010], typeSelect)"/>
		</panel>
		
		<panel sidebar="true" name="infoPanel" title="Info">
			<field name="statusSelect"/>
			<button name="searchBtn" title="Search" showIf="statusSelect != 2 || $contains([1000, 1010, 1001], typeSelect)" onClick="save,action-accounting-report-method-search-move-line,save"/>
			<button name="exportBtn" title="Export" showIf="statusSelect != 2 || $contains([1000, 1010, 1001], typeSelect)" onClick="action-group-account-accounting-report-export-click"/>
			<button name="showMoveExportedBtn" title="Exported moves" hideIf="statusSelect != 2 || $contains([1000, 1010], typeSelect)" onClick="save,action-accounting-report-method-show-move-exported"/>
			<button name="replayExportBtn" title="Run export again" hideIf="statusSelect != 2 || $contains([1000, 1010], typeSelect)" onClick="save,action-accounting-report-method-replay-export"/>
		</panel>
		
		<panel sidebar="true" name="balancePanel" title="Balance">
			<field name="totalDebit"/>
			<field name="totalCredit"/>
			<field name="balance"/>
		</panel>
		
	</form>
	
	
<!-- 	ACTION GROUPs -->    
    
    <action-group name="action-group-account-accounting-report-typeselect-onchange">
    	<action name="action-accounting-report-record-reset"/>
    	<action name="action-accounting-report-method-get-journal-type"/>
    	<action name="action-accounting-report-record-default-global"/>
    	<action name="action-accounting-report-method-get-account"/>
    </action-group>
    
    <action-group name="action-group-account-accounting-report-export-click">
    	<action name="save"/>
    	<action name="action-accounting-report-method-print-export-moveLine"/>
    	<action name="action-accounting-report-method-get-reload"/>
    </action-group>
    
    <action-group name="action-group-account-accounting-report-period-onchange">
    	<action name="action-accounting-report-record-year"/>
    	<action name="action-accounting-report-record-date-from-and-date-to"/>
    </action-group>

	<action-group name="action-group-account-accounting-report-company-onchange">
	    <action name="action-accounting-report-method-get-account"/>
	    <action name="action-accounting-report-record-reset"/>
	</action-group>

<!--     ACTION ATTRS -->
	    
	<action-attrs name="action-accounting-report-attrs-period-domain">
		<attribute if="eval: year != null" name="domain" expr="eval: &quot;self.year.id = ${year?.id}&quot;" for="period"/>
		<attribute name="domain" for="period" expr="eval: &quot; self.year.company = :company AND self.year.typeSelect = 1 &quot;" if="eval: year == null "/>
	</action-attrs>
	
	<action-attrs name="action-accounting-report-attrs-year-domain">
		<attribute name="domain" for="year" expr="eval: &quot;self.company.id = ${company?.id} AND self.typeSelect = 1 &quot;"/>
	</action-attrs>
	
<!-- 	ACTION RECORD -->

	<action-record name="action-accounting-report-record-global" model="com.axelor.apps.account.db.AccountingReport">
		<field name="globalByDate" expr="eval: false"/>
		<field name="globalByPartner" expr="eval: false"/>
		<field name="detailed" expr="eval: false"/>
	</action-record>
	
	<action-record name="action-accounting-report-record-global-by-date" model="com.axelor.apps.account.db.AccountingReport">
		<field name="global" expr="eval: false"/>
		<field name="globalByPartner" expr="eval: false"/>
		<field name="detailed" expr="eval: false"/>
	</action-record>
	
	<action-record name="action-accounting-report-record-global-by-partner" model="com.axelor.apps.account.db.AccountingReport">
		<field name="global" expr="eval: false"/>
		<field name="globalByDate" expr="eval: false"/>
		<field name="detailed" expr="eval: false"/>
	</action-record>
	
	<action-record name="action-accounting-report-record-detailed" model="com.axelor.apps.account.db.AccountingReport">
		<field name="global" expr="eval: false"/>
		<field name="globalByDate" expr="eval: false"/>
		<field name="globalByPartner" expr="eval: false"/>
	</action-record>
	
	<action-record name="action-accounting-report-record-year" model="com.axelor.apps.account.db.AccountingReport">
		<field name="year" expr="eval: period.year" if="eval : period != null"/>
	</action-record>
	
	<action-record name="action-accounting-report-record-period-dates" model="com.axelor.apps.account.db.AccountingReport">
		<field name="period" expr="eval: null"/>
		<field name="dateFrom" expr="eval: year.fromDate"/>
		<field name="dateTo" expr="eval: year.toDate"/>
	</action-record>

	<action-record name="action-accounting-report-record-date-from-and-date-to" model="com.axelor.apps.account.db.AccountingReport">
		<field name="dateFrom" expr="eval: period.fromDate" if="eval : period != null"/>
		<field name="dateTo" expr="eval: period.toDate" if="eval : period != null"/>
	</action-record>
	
	<action-record name="action-accounting-report-record-reset" model="com.axelor.apps.account.db.AccountingReport">
		<field name="accountSet" expr="eval: null"/>
		<field name="paymentMode" expr="eval: null"/>
		<field name="partnerSet" expr="eval: null"/>
		<field name="global" expr="eval: null"/>
		<field name="globalByDate" expr="eval: null"/>
		<field name="globalByPartner" expr="eval: null"/>
		<field name="detailed" expr="eval: null"/>
		<field name="year" expr="eval: null"/>
		<field name="exportTypeSelect" expr="eval: null"/>
		<field name="period" expr="eval: null"/>
  		<field name="dateFrom" expr="eval: null"/>
  		<field name="dateTo" expr="eval: null"/>
	</action-record>
	
	<action-record name="action-accounting-report-record-default-global" model="com.axelor.apps.account.db.AccountingReport">
		<field name="global" expr="eval: true" if="typeSelect in [1,2,5,11]"/>
		<field name="globalByPartner" expr="eval: true" if="typeSelect in [3]"/>
		<field name="detailed" expr="eval: true" if="typeSelect in [4]"/>
		<field name="exportTypeSelect" expr="eval: 'pdf'"/>
	</action-record>
	
	<action-record name="action-accounting-report-record-default" model="com.axelor.apps.account.db.AccountingReport">
		<field name="date" expr="eval:__config__.app.getTodayDate()"/>
		<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"/>
    	<field name="currency" expr="eval:__user__.activeCompany?.currency"/>
	</action-record>
	
	<action-record name="action-move-Live-report-record-set-date-to" model="com.axelor.apps.account.db.AccountingReport">
		<field name="dateTo" expr="eval: dateFrom" if="dateFrom &amp;&amp; !dateTo"/>
	</action-record>

<!-- 	ACTION METHOD -->
	
	<action-method name="action-accounting-report-method-get-account">
		<call class="com.axelor.apps.account.web.AccountingReportController" method="getAccount"/>
	</action-method>
	
	<action-method name="action-accounting-report-method-get-reload">
		<call class="com.axelor.apps.account.web.AccountingReportController" method="getReload"/>
	</action-method>
	
	<action-method name="action-accounting-report-method-print-export-moveLine">
		<call class="com.axelor.apps.account.web.AccountingReportController" method="printExportMoveLine"/>
	</action-method>
	
	<action-method name="action-accounting-report-method-show-move-exported">
		<call class="com.axelor.apps.account.web.AccountingReportController" method="showMoveExported"/>
	</action-method>
	
	<action-method name="action-accounting-report-method-replay-export">
		<call class="com.axelor.apps.account.web.AccountingReportController" method="replayExport"/>
	</action-method>
	
	<action-method name="action-accounting-report-method-search-move-line">
		<call class="com.axelor.apps.account.web.AccountingReportController" method="searchMoveLine"/>
	</action-method>
	
	<action-method name="action-accounting-report-method-get-journal-type">
		<call class="com.axelor.apps.account.web.AccountingReportController" method="getJournalType"/>
	</action-method>
	
   <action-method name="action-accounting-report-method-set-bank-details-domain">
     <call class="com.axelor.apps.bankpayment.web.AccountingReportController" method="setBankDetailsDomain"/>
   </action-method>
</object-views>