P_AR_EDPLDOCAGGREGATEDAMOUNT

CDS View

P_AR_EDPLDOCAGGREGATEDAMOUNT is a CDS View in S/4HANA. 2 CDS views read from this table.

CDS Views using this table (2)

ViewTypeJoinVDMDescription
P_AR_EDplDocumentDetail view from CONSUMPTION
P_AR_EDplDocumentTotal view from CONSUMPTION
@AbapCatalog.sqlViewName: 'PAREDPLDOCAGGAMT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@VDM.viewType: #CONSUMPTION
@VDM.private: true
@ClientHandling.algorithm: #SESSION_VARIABLE
define view P_AR_EDplDocAggregatedAmount
  with parameters
    P_RptgAmountIsInTransCrcy : fiar_use_transaction_currency

  as select from P_AR_SalesTaxItem2
                 ( P_RptgAmountIsInTransCrcy : $parameters.P_RptgAmountIsInTransCrcy) as TaxItem

{
  key TaxItem.CompanyCode,
  key TaxItem.FiscalYear,
  key TaxItem.AccountingDocument,
      TaxItem.PostingDate,
      TaxItem.DocumentDate,
      TaxItem.ReportingDate,
      TaxItem.FiscalPeriod,
      TaxItem.AccountingDocumentType,
      TaxItem.DocumentReferenceID,
      TaxItem.AR_Branch,
      TaxItem.AR_PrintCharacter,
      TaxItem.AR_OfficialDocumentNumber,
      TaxItem.NmbrOfPages,
      TaxItem.IsReversal,
      TaxItem.IsReversed,
      TaxItem.ReverseDocument,
      TaxItem.ReverseDocumentFiscalYear,
      TaxItem.ReversalReferenceDocument,
      TaxItem.LogicalSystem,
      TaxItem.OriginalReferenceDocument,
      TaxItem.ReferenceDocumentType,
      TaxItem.ReferenceDocumentLogicalSystem,
      TaxItem.ExchangeRateDate,
      TaxItem.ExchangeRate,

      cast(
        sum(
          case
            when TaxItem.TaxAmountInCoCodeCrcy <> 0 and ( TaxItem.StRpTaxClassification =  'TX' or TaxItem.StRpTaxClassification =  'VN' )
              then 1
            else 0
          end
        ) as fiar_nmbrvat preserving type
      )                                            as NmbrOfVATRates,

      min( TaxItem.AR_LowestPriorityOfZeroVATRsn ) as AR_LowestPriorityOfZeroVATRsn,

      TaxItem.CompanyCodeCountry,
      TaxItem.CompanyCodeCurrency,
      TaxItem.TransactionCurrency,
      TaxItem.ReportingCurrency,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when ( TaxItem.StRpTaxClassification = 'VN'
              or ( ( TaxItem.StRpTaxClassification = 'TX' or TaxItem.StRpTaxClassification = 'VL' ) and TaxItem.ZeroVATRsn = 'N' ) )
              and TaxItem.TaxAmountInCoCodeCrcy = 0
            then TaxItem.TaxBaseAmountInRptgCrcy
            else 0
          end
        ) as fi_ar_nottax_amnt preserving type
      )                                            as NotTaxedAmount,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when TaxItem.StRpTaxClassification = 'NC' or TaxItem.StRpTaxClassification = 'VS'
              then TaxItem.TaxAmountInRptgCrcy
            else 0
          end
        ) as fiar_notreg_bptaxamount preserving type
      )                                            as NotRegisteredBPTxAmtInRptgCrcy,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when ( TaxItem.StRpTaxClassification = 'TX' or TaxItem.StRpTaxClassification = 'VL' )
              and ( TaxItem.ZeroVATRsn = 'E' or TaxItem.ZeroVATRsn = 'Z' or TaxItem.ZeroVATRsn = 'X' )
              and TaxItem.TaxAmountInCoCodeCrcy = 0
            then TaxItem.TaxBaseAmountInRptgCrcy
            else 0
          end
        ) as fiar_exempted_amount preserving type
      )                                            as TaxExemptionAmount,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when TaxItem.StRpTaxClassification = 'VP' or TaxItem.StRpTaxClassification = 'EP' or TaxItem.StRpTaxClassification = 'PN'
              then TaxItem.TaxAmountInRptgCrcy
            else 0
          end
        ) as fi_ar_perpvat_amnt preserving type
      )                                            as PerceptionVATAmount,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when TaxItem.StRpTaxClassification = 'GP'
              then TaxItem.TaxAmountInRptgCrcy
            else 0
          end
        ) as fiar_provincial_tax_amount preserving type
      )                                            as GrossIncomeTaxAmount,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when TaxItem.StRpTaxClassification = 'MP'
              then TaxItem.TaxAmountInRptgCrcy
            else 0
          end
        ) as fi_ar_mptax_amnt preserving type
      )                                            as MunicipalTaxAmount,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when TaxItem.StRpTaxClassification = 'IT'
              then TaxItem.TaxAmountInRptgCrcy
            else 0
          end
        ) as fiar_internal_tax_amount preserving type
      )                                            as OpenTotalTaxAmount,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when TaxItem.StRpTaxClassification = 'OT'
              then TaxItem.TaxAmountInRptgCrcy
            else 0
          end
        ) as fiar_other_tax_amount preserving type
      )                                            as OtherTaxAmount,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when ( TaxItem.StRpTaxClassification = 'TX' or TaxItem.StRpTaxClassification = 'VL' )
              then TaxItem.TaxAmountInRptgCrcy
            else 0
          end
        ) as fiar_net_tax_amount preserving type
      )                                            as NetTaxAmount,

      @Semantics.amount.currencyCode: 'ReportingCurrency'
      cast(
        sum(
          case
            when ( TaxItem.StRpTaxClassification = 'TX' or TaxItem.StRpTaxClassification = 'VL' )
             and TaxItem.TaxAmountInCoCodeCrcy <> 0
              then TaxItem.TaxBaseAmountInRptgCrcy
            else 0
          end
        ) as fiar_taxed_base_amount preserving type
      )                                            as TaxedAmountInRptgCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      sum( TaxItem.TaxAmountInCoCodeCrcy )         as TaxAmountInCoCodeCrcy,
      @Semantics.amount.currencyCode: 'TransactionCurrency'
      sum( TaxItem.TaxAmountInTransCrcy )          as TaxAmountInTransCrcy,
      @Semantics.amount.currencyCode: 'ReportingCurrency'
      sum( TaxItem.TaxAmountInRptgCrcy )           as TaxAmountInRptgCrcy,

      TaxItem._OneTimeAccountBP

}
group by
  TaxItem.CompanyCode,
  TaxItem.FiscalYear,
  TaxItem.AccountingDocument,
  TaxItem.PostingDate,
  TaxItem.DocumentDate,
  TaxItem.ReportingDate,
  TaxItem.FiscalPeriod,
  TaxItem.AccountingDocumentType,
  TaxItem.DocumentReferenceID,
  TaxItem.AR_Branch,
  TaxItem.AR_PrintCharacter,
  TaxItem.AR_OfficialDocumentNumber,
  TaxItem.NmbrOfPages,
  TaxItem.IsReversal,
  TaxItem.IsReversed,
  TaxItem.ReverseDocument,
  TaxItem.ReverseDocumentFiscalYear,
  TaxItem.ReversalReferenceDocument,
  TaxItem.LogicalSystem,
  TaxItem.OriginalReferenceDocument,
  TaxItem.ReferenceDocumentType,
  TaxItem.ReferenceDocumentLogicalSystem,
  TaxItem.ExchangeRateDate,
  TaxItem.ExchangeRate,
  TaxItem.CompanyCodeCountry,
  TaxItem.CompanyCodeCurrency,
  TaxItem.TransactionCurrency,
  TaxItem.ReportingCurrency
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"P_AR_SALESTAXITEM2"
],
"ASSOCIATED":
[
"I_ONETIMEACCOUNTBP"
],
"BASE":
[
"P_AR_SALESTAXITEM2"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/