@AbapCatalog.sqlViewName: 'CSRROEUTAXCLFNC'
@AbapCatalog.compiler.compareFilter: true
@ClientHandling.algorithm: #SESSION_VARIABLE
@EndUserText.label: 'EU Sales Tax Item View for RO'
@VDM.viewType: #CONSUMPTION
//@Search.searchable: true
@Analytics: { dataCategory: #CUBE }
@AccessControl.authorizationCheck: #CHECK
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@Metadata.allowExtensions:true
define view C_RO_StRpTaxItemWithEUTaxClfnC as
select from I_StRpTaxItmWithEUTaxClass as TaxItems
// Join with customer's master record to retrieve fiskn
left outer join I_Customer as Customer on Debtor = Customer.Customer
// Join with supplier's master record to retrieve fiskn
left outer join I_Supplier as Supplier on Creditor = Supplier.Supplier
{
key TaxItems.CompanyCode,
key TaxItems.AccountingDocument,
key TaxItems.FiscalYear,
key TaxItems.TaxCode,
key TaxItems.TaxItem,
key TaxItems.TransactionTypeDetermination,
key StatryRptCategory,
key StatryRptRunID,
key StatryRptgEntity,
// Customer
Debtor,
// Supplier
Creditor,
// VAT number of the business partner
TaxItems.VATRegistration,
// VAT number under which this partner will be reported
cast (
case
// Customer's VAT number is not on the line item => take it from the master record
when Debtor <> '' and TaxItems.VATRegistration = '' then Customer.VATRegistration
// Supplier's VAT number is not on the line item => take it from the master record
when Creditor <> '' and TaxItems.VATRegistration = '' then Supplier.VATRegistration
else TaxItems.VATRegistration
end as fies_ecsl_reporting_vat
) as ReportingVATRegistration,
cast (
case
// Customer's VAT number is not on the line item => take it from the master record
when Debtor <> '' and TaxItems.VATRegistration = '' then substring(Customer.VATRegistration, 1, 2)
// Supplier's VAT number is not on the line item => take it from the master record
when Creditor <> '' and TaxItems.VATRegistration = '' then substring(Supplier.VATRegistration, 1, 2)
else substring(TaxItems.VATRegistration, 1, 2)
end as stceg_l
) as VATRegistrationCountry,
cast (
case
// Customer's VAT number is not on the line item => take the Country from the master record
when Debtor <> '' and TaxItems.VATRegistration = '' then Customer.Country
// Supplier's VAT number is not on the line item => take the Country from the master record
when Creditor <> '' and TaxItems.VATRegistration = '' then Supplier.Country
when TaxItems.VATRegistration <> '' and TaxItems.DelivOfGoodsDestCountry <> '' then TaxItems.DelivOfGoodsDestCountry
else substring(TaxItems.VATRegistration, 1, 2)
// else TaxItems.DelivOfGoodsDestCountry
end as egbld
) as DelivOfGoodsDestCountry,
// Name of the busniness partner
cast(
case
when TaxItems.IsOneTimeAccount = '' and Debtor <> '' then TaxItems.CustomerName
when TaxItems.IsOneTimeAccount = '' and Creditor <> '' then TaxItems.SupplierName
else _OneTimeAccount.BusinessPartnerName1
end as md_customer_name)
as Name,
// Operation code is determined by EU code
cast(
case
when TaxItems.IsEUTriangularDeal = '' and TaxItems.EUTaxClassification = '1' then 'L'
when TaxItems.IsEUTriangularDeal = 'X' and TaxItems.EUTaxClassification = '1' then 'T'
when TaxItems.EUTaxClassification = '9' then 'A'
when TaxItems.EUTaxClassification = '4' then 'P'
when TaxItems.EUTaxClassification = '5' then 'S'
when TaxItems.EUTaxClassification = 'R' then 'R'
when TaxItems.EUTaxClassification = 'C' and AmountInReportingCurrency >= 0 then 'B'
when TaxItems.EUTaxClassification = 'C' and AmountInReportingCurrency < 0 then 'A'
else '?'
end as ecslxx_operation)
as Operation,
TaxItemGroup,
TaxItems.TaxJurisdiction,
TaxItems.Country,
TaxItems.ReportingCountry,
@Semantics.currencyCode:true
ReportingCurrency,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'ReportingCurrency'
cast(
(case
when TaxType = 'A' then (AmountInReportingCurrency * -1)
else AmountInReportingCurrency
end)
as glo_amount_rptg_crcy) as AmountInReportingCurrency,
TaxItems.IsReversal,
TaxItems.IsReversed,
TaxableEntity,
ReportingDate,
TaxItems.PostingDate,
TaxItems.DocumentDate,
TaxReportingDate,
IsEUTriangularDeal,
DelivOfGoodsOriginCountry,
EUTaxClassification,
TaxType,
TaxItems.BusinessPartner,
BusinessPartnerName
}
where
ReportingCountry = 'RO'
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CUSTOMER",
"I_ONETIMEACCOUNTBP",
"I_STRPTAXITMWITHEUTAXCLASS",
"I_SUPPLIER"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/