public function getBalanceAccountsClosingPeriods(array $input)
  {
    $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');

    $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId);

    if($fiscalYearId == $input['id'])
    {
      return json_encode(array('info' => $this->Lang->get('decima-accounting::period-management.invalidFiscalYear')));
    }

    $period = json_decode($this->getLastPeriodOfFiscalYear($input), true);

    $FiscalYear = $this->FiscalYear->byId($input['id']);

    $FiscalYear = $this->FiscalYear->byYearAndByOrganization($FiscalYear->year + 1, $organizationId);

    $period2 = $this->Period->firstPeriodbyOrganizationAndByFiscalYear($this->AuthenticationManager->getCurrentUserOrganizationId(), $FiscalYear->id)->toArray();

    $period2['endDate'] = $this->Carbon->createFromFormat('Y-m-d', $period2['end_date'])->format($this->Lang->get('form.phpShortDateFormat'));
    unset($period2['end_date']);
    $period2['month'] = $period2['month'] . ' - ' . $this->Lang->get('decima-accounting::period-management.' . $period2['month']);

    return json_encode(array('id0' => $period['id'], 'month0' => $period['month'], 'endDate0' => $period['endDate'], 'id1' => $period2['id'], 'month1' => $period2['month'], 'endDate1' => $period2['endDate'], 'fiscalYearId' => $FiscalYear->id));
  }
public function getBalanceAccountsClosingPeriods(array $input)
  {
    $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');

    $fiscalYearId = $this->FiscalYear->lastFiscalYearByOrganization($organizationId);

    if($fiscalYearId == $input['id'])
    {
      return json_encode(array('info' => $this->Lang->get('decima-accounting::period-management.invalidFiscalYear')));
    }

    $period = json_decode($this->getLastPeriodOfFiscalYear($input), true);

    $FiscalYear = $this->FiscalYear->byId($input['id']);

    $FiscalYear = $this->FiscalYear->byYearAndByOrganization($FiscalYear->year + 1, $organizationId);

    $period2 = $this->Period->firstPeriodbyOrganizationAndByFiscalYear($this->AuthenticationManager->getCurrentUserOrganizationId(), $FiscalYear->id)->toArray();

    $period2['endDate'] = $this->Carbon->createFromFormat('Y-m-d', $period2['end_date'])->format($this->Lang->get('form.phpShortDateFormat'));
    unset($period2['end_date']);
    $period2['month'] = $period2['month'] . ' - ' . $this->Lang->get('decima-accounting::period-management.' . $period2['month']);

    return json_encode(array('id0' => $period['id'], 'month0' => $period['month'], 'endDate0' => $period['endDate'], 'id1' => $period2['id'], 'month1' => $period2['month'], 'endDate1' => $period2['endDate'], 'fiscalYearId' => $FiscalYear->id));
  }
public function getBalanceAccountsClosingPeriods ( array $ input ) { $ organizationId = $ this -> AuthenticationManager -> getCurrentUserOrganization ( 'id' ) ; $ fiscalYearId = $ this -> FiscalYear -> lastFiscalYearByOrganization ( $ organizationId ) ; if ( $ fiscalYearId == $ input [ 'id' ] ) { return json_encode ( array ( 'info' => $ this -> Lang -> get ( 'decima-accounting::period-management.invalidFiscalYear' ) ) ) ; } $ period = json_decode ( $ this -> getLastPeriodOfFiscalYear ( $ input ) , true ) ; $ FiscalYear = $ this -> FiscalYear -> byId ( $ input [ 'id' ] ) ; $ FiscalYear = $ this -> FiscalYear -> byYearAndByOrganization ( $ FiscalYear -> year + 1 , $ organizationId ) ; $ period2 = $ this -> Period -> firstPeriodbyOrganizationAndByFiscalYear ( $ this -> AuthenticationManager -> getCurrentUserOrganizationId ( ) , $ FiscalYear -> id ) -> toArray ( ) ; $ period2 [ 'endDate' ] = $ this -> Carbon -> createFromFormat ( 'Y-m-d' , $ period2 [ 'end_date' ] ) -> format ( $ this -> Lang -> get ( 'form.phpShortDateFormat' ) ) ; unset ( $ period2 [ 'end_date' ] ) ; $ period2 [ 'month' ] = $ period2 [ 'month' ] . ' - ' . $ this -> Lang -> get ( 'decima-accounting::period-management.' . $ period2 [ 'month' ] ) ; return json_encode ( array ( 'id0' => $ period [ 'id' ] , 'month0' => $ period [ 'month' ] , 'endDate0' => $ period [ 'endDate' ] , 'id1' => $ period2 [ 'id' ] , 'month1' => $ period2 [ 'month' ] , 'endDate1' => $ period2 [ 'endDate' ] , 'fiscalYearId' => $ FiscalYear -> id ) ) ; }
Get last period of fiscal year and first period of the next fiscal year

@param array $input
An array as follows: array(id => $id);

@return array
An array as follows: array( 'id' = $id, 'month' => $month, 'end_date' => $endDate)
Get last period of fiscal year and first period of the next fiscal year