@AbapCatalog.sqlViewName: 'IARCALTAXITEM'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck:#CHECK
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@Analytics: { dataCategory: #CUBE }
@VDM.viewType: #COMPOSITE
@AccessControl.personalData.blocking:#BLOCKED_DATA_INCLUDED
@ClientHandling.algorithm: #SESSION_VARIABLE
//@ObjectModel.representativeKey: 'AccountingDocument'
@EndUserText.label: 'Argentina VAT Tax Line Item Calculation'
@Metadata.ignorePropagatedAnnotations: true
@Metadata.allowExtensions:true
define view I_AR_StRpTaxItem
as select from I_StRpTaxItem
left outer join I_AR_TaxClassIdentification on I_StRpTaxItem.TaxCalculationProcedure = I_AR_TaxClassIdentification.TaxCalculationProcedure
and I_StRpTaxItem.TaxCode = I_AR_TaxClassIdentification.TaxCode
and I_StRpTaxItem.TransactionTypeDetermination = I_AR_TaxClassIdentification.TransactionTypeDetermination
left outer join I_Altvcurrency on I_Altvcurrency.CurrencyAlternativeCodeGroup = 'DAILYVAT'
and I_StRpTaxItem.DocumentCurrency = I_Altvcurrency.Currency
left outer join I_AR_ImportServiceDocumentType on I_StRpTaxItem.CompanyCodeCountry = I_AR_ImportServiceDocumentType.Country
and I_StRpTaxItem.AccountingDocumentType = I_AR_ImportServiceDocumentType.AccountingDocumentType
left outer join I_CountrySpecificDocumentType on I_StRpTaxItem.CompanyCodeCountry = I_CountrySpecificDocumentType.Country
and I_StRpTaxItem.AccountingDocumentType = I_CountrySpecificDocumentType.AccountingDocumentType
left outer join I_AccountingDocument as _ReverseDoc on _ReverseDoc.CompanyCode = I_StRpTaxItem.CompanyCode
and _ReverseDoc.AccountingDocument = I_StRpTaxItem.ReverseDocument
and _ReverseDoc.FiscalYear = I_StRpTaxItem.FiscalYear
and _ReverseDoc.FiscalPeriod = I_StRpTaxItem.FiscalPeriod
and I_StRpTaxItem.ReverseDocument is not null
left outer join I_Customer on I_StRpTaxItem.BusinessPartner = I_Customer.Customer
left outer join I_Supplier on I_StRpTaxItem.BusinessPartner = I_Supplier.Supplier
association [0..1] to I_UnitOfMeasure as _QuantityUnitOfMeasure on $projection.QuantityUnit = _QuantityUnitOfMeasure.UnitOfMeasure
{
key I_StRpTaxItem.CompanyCode,
key I_StRpTaxItem.AccountingDocument,
key I_StRpTaxItem.FiscalYear,
key I_StRpTaxItem.TaxItem,
key I_StRpTaxItem.TaxCalculationProcedure,
key I_StRpTaxItem.TaxCode,
key I_StRpTaxItem.TransactionTypeDetermination,
I_StRpTaxItem.DebitCreditCode,
// cast (I_StRpTaxItem.TaxRate as char16) as TaxRate, //AFLE Changes
cast(cast(I_StRpTaxItem.TaxRate as abap.dec(11,2)) as char16) as TaxRate, //AFLE Changes
cast(cast(abs(I_StRpTaxItem.TaxRate) as abap.dec(11,2)) as char16) as AR_VATRateInPercent, //AFLE Changes
I_StRpTaxItem.GLAccount,
I_StRpTaxItem.AccountingDocumentHeaderText,
I_StRpTaxItem.AccountingDocumentType,
@Semantics.currencyCode:true
I_StRpTaxItem.AdditionalCurrency1,
@Semantics.currencyCode:true
I_StRpTaxItem.AdditionalCurrency2,
I_StRpTaxItem.BusinessPartner,
I_StRpTaxItem.BusinessPartnerName,
I_StRpTaxItem.BusinessPlace,
I_StRpTaxItem.CompanyCodeCountry,
@Semantics.currencyCode:true
I_StRpTaxItem.CompanyCodeCurrency,
@Semantics.currencyCode:true
I_StRpTaxItem.CountryCurrency,
I_StRpTaxItem.CustomerSupplierAddress,
@Semantics.currencyCode:true
I_StRpTaxItem.DocumentCurrency,
I_StRpTaxItem.DocumentDate,
I_StRpTaxItem.DocumentReferenceID,
I_StRpTaxItem.FiscalPeriod,
I_StRpTaxItem.IsReversal,
I_StRpTaxItem.IsReversed,
I_StRpTaxItem.Ledger,
I_StRpTaxItem.LedgerGroup,
I_StRpTaxItem.LowestLevelTaxJurisdiction,
I_StRpTaxItem.PostingDate,
I_StRpTaxItem.ReportingDate,
I_StRpTaxItem.ReferenceDocumentType,
I_StRpTaxItem.ReportingCountry,
@Semantics.currencyCode:true
I_StRpTaxItem.ReportingCurrency,
I_StRpTaxItem.ReverseDocument,
I_StRpTaxItem.ReverseDocumentFiscalYear,
I_StRpTaxItem.TargetTaxCode,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'DocumentCurrency'
I_StRpTaxItem.TaxAmount,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'AdditionalCurrency1'
I_StRpTaxItem.TaxAmountInAdditionalCurrency1,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'AdditionalCurrency2'
I_StRpTaxItem.TaxAmountInAdditionalCurrency2,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'CountryCurrency'
I_StRpTaxItem.TaxAmountInCountryCrcy,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'ReportingCurrency'
I_StRpTaxItem.TaxAmountInRptgCrcy,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'CountryCurrency'
I_StRpTaxItem.TaxBaseAmountInCountryCrcy,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'ReportingCurrency'
I_StRpTaxItem.TaxBaseAmountInRptgCrcy,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'DocumentCurrency'
I_StRpTaxItem.TaxBaseAmountInTransCrcy,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'AdditionalCurrency1'
I_StRpTaxItem.TaxBaseAmtInAdditionalCrcy1,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'AdditionalCurrency2'
I_StRpTaxItem.TaxBaseAmtInAdditionalCrcy2,
I_StRpTaxItem.TaxIsNotDeductible,
I_StRpTaxItem.TaxItemGroup,
I_StRpTaxItem.TaxJurisdiction,
I_StRpTaxItem.TaxNumber1,
I_StRpTaxItem.TaxNumber2,
I_StRpTaxItem.TaxNumber3,
I_StRpTaxItem.TaxReportingDate,
I_StRpTaxItem.TaxReturnCountry,
I_StRpTaxItem.TaxType,
I_AR_ImportServiceDocumentType.DocumentTypeCategory,
I_AR_ImportServiceDocumentType.IsRespForImportDeclaration,
I_CountrySpecificDocumentType.AR_OfficialDocumentClass,
I_CountrySpecificDocumentType.AR_IsSelfIssuedDocument,
I_Altvcurrency.AlternativeCurrencyKey,
@Semantics.unitOfMeasure: true
cast( 'X' as abap.unit( 3 ) ) as QuantityUnit, //dummy unit for length field
@Semantics.quantity.unitOfMeasure: 'QuantityUnit'
@DefaultAggregation: #SUM
length(I_StRpTaxItem.BusinessPartnerName) as LinearDataLength,
case
when I_StRpTaxItem.AccountingDocumentHeaderText is not null
then substring(I_StRpTaxItem.AccountingDocumentHeaderText, 1, 2)
else
I_StRpTaxItem.AccountingDocumentHeaderText
end as CountryFreeText,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'CompanyCodeCurrency'
case
when I_StRpTaxItem.TaxBaseAmountInCoCodeCrcy < 0
then I_StRpTaxItem.TaxBaseAmountInCoCodeCrcy
else I_StRpTaxItem.TaxBaseAmountInCoCodeCrcy
end as TaxBaseAmountInCoCodeCrcy,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'CompanyCodeCurrency'
case
when I_StRpTaxItem.TaxAmountInCoCodeCrcy < 0
then I_StRpTaxItem.TaxAmountInCoCodeCrcy
else I_StRpTaxItem.TaxAmountInCoCodeCrcy
end as TaxAmountInCoCodeCrcy,
case
when I_Supplier.Supplier <> '' then
I_Supplier.Country
end as BusinessPartnerCountry,
case
when I_Customer.Customer <> '' then
I_Customer.TaxNumberType
when I_Supplier.Supplier <> '' then
I_Supplier.TaxNumberType
end as TaxNumberType,
case length( I_StRpTaxItem.DocumentReferenceID )
when 13 then substring(I_StRpTaxItem.DocumentReferenceID,6,8)
when 14 then substring(I_StRpTaxItem.DocumentReferenceID,7,8)
end as AR_OfficialDocumentNumber,
case length( I_StRpTaxItem.DocumentReferenceID )
when 13 then substring(I_StRpTaxItem.DocumentReferenceID,1,4)
when 14 then substring(I_StRpTaxItem.DocumentReferenceID,1,5)
end as AR_Branch,
case length( I_StRpTaxItem.DocumentReferenceID )
when 13 then substring(I_StRpTaxItem.DocumentReferenceID,5,1)
when 14 then substring(I_StRpTaxItem.DocumentReferenceID,6,1)
end as AR_PrintCharacter,
'' as TaxClassification, //this GFN cannot be used since its default data element is type length 1
I_AR_TaxClassIdentification.StRpTaxClassification as TaxClassificationCategory,
substring(I_AR_TaxClassIdentification.StRpTaxClassification,1,2) as StRpTaxClassification,
@DefaultAggregation:#MAX
case I_StRpTaxItem.DocumentCurrency
when 'ARS' then 1
else I_StRpTaxItem.ExchangeRate
end as ExchangeRate,
case substring(I_AR_TaxClassIdentification.StRpTaxClassification,1,2)
when 'TX' then 1
when 'VL' then 1
when 'VN' then 1
end as NmbrOfVATRates,
case I_StRpTaxItem.TaxNumber1
when '30546676591' then I_StRpTaxItem.DocumentReferenceID
when '33693450239' then I_StRpTaxItem.DocumentReferenceID
else ' '
end as PurchaseImportForm,
ZeroVATRsn,
case
when _ReverseDoc.FiscalPeriod = I_StRpTaxItem.FiscalPeriod
then 'X'
end as ClearingIsReversible,
/* Associations */
I_StRpTaxItem._AccountingDocument,
I_StRpTaxItem._GLAccount,
I_StRpTaxItem._ReceivablesPayablesItem,
I_StRpTaxItem._ReportedItemsLog,
I_StRpTaxItem._ReportingCurrency,
I_StRpTaxItem._TaxJurisdiction,
I_StRpTaxItem._TaxTypeText,
I_AR_TaxClassIdentification.GLBusinessTransactionType,
I_Supplier.ResponsibleType as ResponsibleType,
_QuantityUnitOfMeasure
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_ACCOUNTINGDOCUMENT",
"I_ALTVCURRENCY",
"I_AR_IMPORTSERVICEDOCUMENTTYPE",
"I_AR_TAXCLASSIDENTIFICATION",
"I_COUNTRYSPECIFICDOCUMENTTYPE",
"I_CUSTOMER",
"I_STRPTAXITEM",
"I_SUPPLIER"
],
"ASSOCIATED":
[
"I_ACCOUNTINGDOCUMENT",
"I_CURRENCY",
"I_GLACCOUNT",
"I_OPERATIONALACCTGDOCITEM",
"I_STRPJOURNALENTRYLOG",
"I_TAXJURISDICTION",
"I_TAXTYPETEXT",
"I_UNITOFMEASURE"
],
"BASE":
[
"I_STRPTAXITEM"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/