P_AR_DailyVATTaxBaseAmount

DDL: P_AR_DAILYVATTAXBASEAMOUNT SQL: PARDVTAXBASEAMT Type: view CONSUMPTION

P_AR_DailyVATTaxBaseAmount is a Consumption CDS View in SAP S/4HANA. It reads from 2 data sources (I_JournalEntry, P_AR_TaxItem) and exposes 7 fields with key fields CompanyCode, AccountingDocument, FiscalYear.

Data Sources (2)

SourceAliasJoin Type
I_JournalEntry JournalEntry inner
P_AR_TaxItem P_AR_TaxItem from

Annotations (10)

NameValueLevelField
AbapCatalog.sqlViewName PARDVTAXBASEAMT view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
ClientHandling.algorithm #SESSION_VARIABLE view
VDM.private true view
VDM.viewType #CONSUMPTION view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.dataClass #MIXED view

Fields (7)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode P_AR_TaxItem CompanyCode
KEY AccountingDocument P_AR_TaxItem AccountingDocument
KEY FiscalYear P_AR_TaxItem FiscalYear
TaxType P_AR_TaxItem TaxType
TaxCode P_AR_TaxItem TaxCode
CompanyCodeCurrency P_AR_TaxItem CompanyCodeCurrency
_TaxType P_AR_TaxItem _TaxType
@AbapCatalog.sqlViewName: 'PARDVTAXBASEAMT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM.private:true
@VDM.viewType: #CONSUMPTION
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED

define view P_AR_DailyVATTaxBaseAmount
  as select from P_AR_TaxItem
  
  inner join I_JournalEntry as JournalEntry on JournalEntry.CompanyCode        = P_AR_TaxItem.CompanyCode
                                           and JournalEntry.FiscalYear         = P_AR_TaxItem.FiscalYear
                                           and JournalEntry.AccountingDocument = P_AR_TaxItem.AccountingDocument
                                           
    //When the document is posted trough SD and the tax rate is zero, the VAT reason should always be read from billing item (not from FI cust. table FIARC_TAXID) 

  left outer to many join P_AR_BillingDocumentZeroVATRsn as BillingDocumentZeroVatReason on BillingDocumentZeroVatReason.BillingDocument = JournalEntry.OriginalReferenceDocument
  
{
  key P_AR_TaxItem.CompanyCode,
  key P_AR_TaxItem.AccountingDocument,
  key P_AR_TaxItem.FiscalYear,
      P_AR_TaxItem.TaxType,
      P_AR_TaxItem.TaxCode,
      P_AR_TaxItem.CompanyCodeCurrency,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      sum(
        distinct
        case
          when P_AR_TaxItem.TaxRate <> 0 and ( P_AR_TaxItem.StRpTaxClassification = 'VL' or P_AR_TaxItem.StRpTaxClassification = 'TX' )
            then P_AR_TaxItem.TaxBaseAmountInCoCodeCrcy
          else 0
        end
      ) as TaxedAmountInCoCoCrcy,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      sum(
        distinct
        case
          when P_AR_TaxItem.StRpTaxClassification = 'VN' or 
              ( P_AR_TaxItem.StRpTaxClassification = 'TX' and P_AR_TaxItem.TaxRate = 0 and 
                ( ( JournalEntry.ReferenceDocumentType  = 'VBRK' and BillingDocumentZeroVatReason.ZeroVATRsn = 'N' ) or
                  ( JournalEntry.ReferenceDocumentType <> 'VBRK' and P_AR_TaxItem.ZeroVATRsn = 'N' ) )
              )
            then P_AR_TaxItem.TaxBaseAmountInCoCodeCrcy
          else 0
        end
      ) as NotTaxedAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      sum(
        distinct
          case
            when P_AR_TaxItem.TaxRate = 0 and 
                ( ( JournalEntry.ReferenceDocumentType  = 'VBRK' and BillingDocumentZeroVatReason.ZeroVATRsn = 'E' ) or 
                  ( JournalEntry.ReferenceDocumentType <> 'VBRK' and P_AR_TaxItem.ZeroVATRsn = 'E' ) )
              then P_AR_TaxItem.TaxBaseAmountInCoCodeCrcy
            else 0
          end
      ) as TaxExemptionAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      sum(
        distinct
          case
            when P_AR_TaxItem.TaxRate = 0 and 
                ( ( JournalEntry.ReferenceDocumentType  = 'VBRK' and ( BillingDocumentZeroVatReason.ZeroVATRsn = 'X' or BillingDocumentZeroVatReason.ZeroVATRsn = 'Z' ) ) or 
                  ( JournalEntry.ReferenceDocumentType <> 'VBRK' and ( P_AR_TaxItem.ZeroVATRsn = 'X' or P_AR_TaxItem.ZeroVATRsn = 'Z' )  ) )
              then P_AR_TaxItem.TaxBaseAmountInCoCodeCrcy
            else 0
          end
      ) as ExportOperationTaxAmount,
      
      P_AR_TaxItem._TaxType
}
group by
  P_AR_TaxItem.CompanyCode,
  P_AR_TaxItem.AccountingDocument,
  P_AR_TaxItem.FiscalYear,
  P_AR_TaxItem.TaxType,
  P_AR_TaxItem.TaxCode,
  P_AR_TaxItem.CompanyCodeCurrency
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_JOURNALENTRY",
"P_AR_BILLINGDOCUMENTZEROVATRSN",
"P_AR_TAXITEM"
],
"ASSOCIATED":
[
"I_TAXTYPE"
],
"BASE":
[
"P_AR_TAXITEM"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/