@AbapCatalog.sqlViewName: 'CSRPLEUTXCLFNCC'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED
@Analytics.dataCategory: #CUBE
@ClientHandling.algorithm: #SESSION_VARIABLE
@EndUserText.label: 'EU Sales Tax Item View - Correction Run'
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality: #X
@ObjectModel.usageType.sizeCategory: #XL
@VDM.viewType: #CONSUMPTION
@Metadata.allowExtensions:true
define view C_PL_StRpTxItmWithEUTxClCrrtnC
as select from I_StRpTaxItmWithEUTaxClass
inner join P_T007B_GLO
on P_T007B_GLO.ktosl = I_StRpTaxItmWithEUTaxClass.TransactionTypeDetermination
left outer join I_StRpRepRun as CurrRun on I_StRpTaxItmWithEUTaxClass.StatryRptgEntity = CurrRun.StatryRptgEntity
and I_StRpTaxItmWithEUTaxClass.StatryRptCategory = CurrRun.StatryRptCategory
and I_StRpTaxItmWithEUTaxClass.StatryRptRunID = CurrRun.StatryRptRunID
left outer join I_StRpRepRun as LastAccRun on I_StRpTaxItmWithEUTaxClass.StatryRptgEntity = LastAccRun.StatryRptgEntity
and I_StRpTaxItmWithEUTaxClass.StatryRptCategory = LastAccRun.StatryRptCategory
and LastAccRun.StatryRptTaskUUID = CurrRun.StatryRptTaskUUID
and LastAccRun.StatryRptRunType = 'STAND'
and LastAccRun.StatryRptRunStatus = 'SOK'
left outer join I_StRpJournalEntryLog on LastAccRun.StatryRptgEntity = I_StRpJournalEntryLog.StatryRptgEntity
and LastAccRun.StatryRptCategory = I_StRpJournalEntryLog.StatryRptCategory
and LastAccRun.StatryRptRunID = I_StRpJournalEntryLog.StatryRptRunID
and I_StRpJournalEntryLog.CompanyCode = I_StRpTaxItmWithEUTaxClass.CompanyCode
and I_StRpJournalEntryLog.AccountingDocument = I_StRpTaxItmWithEUTaxClass.AccountingDocument
and I_StRpJournalEntryLog.FiscalYear = I_StRpTaxItmWithEUTaxClass.FiscalYear
inner join P_PL_StRpReportingGroupsCr on I_StRpTaxItmWithEUTaxClass.StatryRptgEntity = P_PL_StRpReportingGroupsCr.StatryRptgEntity
and I_StRpTaxItmWithEUTaxClass.StatryRptCategory = P_PL_StRpReportingGroupsCr.StatryRptCategory
and I_StRpTaxItmWithEUTaxClass.StatryRptRunID = P_PL_StRpReportingGroupsCr.StatryRptRunID
and I_StRpTaxItmWithEUTaxClass.CompanyCode = P_PL_StRpReportingGroupsCr.CompanyCode
and (I_StRpTaxItmWithEUTaxClass.VATRegistration = P_PL_StRpReportingGroupsCr.VATRegistration
or (I_StRpTaxItmWithEUTaxClass.VATRegistration is null and P_PL_StRpReportingGroupsCr.VATRegistration is null))
and
((P_PL_StRpReportingGroupsCr.OfficialTaxOperationKey = 'G' and
(I_StRpTaxItmWithEUTaxClass.EUTaxClassification = '1' or I_StRpTaxItmWithEUTaxClass.EUTaxClassification = '3' or I_StRpTaxItmWithEUTaxClass.EUTaxClassification = '9'))
or
(P_PL_StRpReportingGroupsCr.OfficialTaxOperationKey = 'S' and
(I_StRpTaxItmWithEUTaxClass.EUTaxClassification = '4'))
)
and I_StRpTaxItmWithEUTaxClass.TaxType = P_PL_StRpReportingGroupsCr.TaxType
and (I_StRpTaxItmWithEUTaxClass.IsEUTriangularDeal = P_PL_StRpReportingGroupsCr.IsEUTriangularDeal
or (I_StRpTaxItmWithEUTaxClass.IsEUTriangularDeal is null and P_PL_StRpReportingGroupsCr.IsEUTriangularDeal is null))
association [0..1] to I_JournalEntry as _JournalEntry on $projection.AccountingDocument = _JournalEntry.AccountingDocument
and $projection.CompanyCode = _JournalEntry.CompanyCode
and $projection.FiscalYear = _JournalEntry.FiscalYear
{
key I_StRpTaxItmWithEUTaxClass.CompanyCode,
key I_StRpTaxItmWithEUTaxClass.AccountingDocument,
key I_StRpTaxItmWithEUTaxClass.FiscalYear,
key I_StRpTaxItmWithEUTaxClass.TaxCode,
key I_StRpTaxItmWithEUTaxClass.TransactionTypeDetermination,
key I_StRpTaxItmWithEUTaxClass.TaxItem,
key I_StRpTaxItmWithEUTaxClass.StatryRptCategory,
key I_StRpTaxItmWithEUTaxClass.StatryRptRunID,
key I_StRpTaxItmWithEUTaxClass.StatryRptgEntity,
Debtor,
case IsOneTimeAccount
when 'X' then _OneTimeAccount.BusinessPartnerName1
else CustomerName
end as CustomerName,
I_StRpTaxItmWithEUTaxClass.VATRegistration,
cast(substring(I_StRpTaxItmWithEUTaxClass.VATRegistration, 1, 2) as stceg_l) as VATRegistrationCountry,
cast(substring(I_StRpTaxItmWithEUTaxClass.VATRegistration, 3, 18) as farp_stceg )as ReportingVATRegistration,
I_StRpTaxItmWithEUTaxClass.TaxItemGroup,
I_StRpTaxItmWithEUTaxClass.TaxJurisdiction,
I_StRpTaxItmWithEUTaxClass.Country,
@Semantics.currencyCode:true
ReportingCurrency,
@DefaultAggregation:#SUM
@Semantics.amount.currencyCode: 'ReportingCurrency'
cast(
(case
when I_StRpTaxItmWithEUTaxClass.TaxType = 'A' and stgrp = '2' then AmountInReportingCurrency
when I_StRpTaxItmWithEUTaxClass.TaxType = 'A' then (AmountInReportingCurrency * -1)
when I_StRpTaxItmWithEUTaxClass.TaxType = 'V' and stgrp = '1' then (AmountInReportingCurrency * -1)
else AmountInReportingCurrency
end)
as glo_amount_rptg_crcy) as AmountInReportingCurrency,
ReportingCountry,
IsReversal,
IsReversed,
TaxableEntity,
ReportingDate,
PostingDate,
DocumentDate,
I_StRpTaxItmWithEUTaxClass.TaxReportingDate,
I_StRpTaxItmWithEUTaxClass.IsEUTriangularDeal,
DelivOfGoodsDestCountry,
DelivOfGoodsOriginCountry,
EUTaxClassification,
I_StRpTaxItmWithEUTaxClass.TaxType,
cast((case
when EUTaxClassification = '1' or EUTaxClassification = '3' or EUTaxClassification = '9' then 'G'
when EUTaxClassification = '4' then 'S'
when EUTaxClassification = 'C' then 'C'
end) as fipl_ecsl_operation_key) as OfficialTaxOperationKey,
cast((case
when I_StRpJournalEntryLog.AccountingDocument is not null then '1'
else '0'
end) as fipl_ecsl_document_status) as InternalDocumentStatus,
cast(case
when EUTaxClassification = 'C' and TaxDebitCreditCode = 'H' then
'1'
when EUTaxClassification = 'C' and TaxDebitCreditCode = 'S' then
'2'
else
''
end as fipl_ecsl_cos preserving type) as EUTaxClassForCallOffStock,
BusinessPartner,
BusinessPartnerName,
_JournalEntry.DocumentReferenceID
}
where
(EUTaxClassification = '1' or EUTaxClassification = '3' or EUTaxClassification = '9' or EUTaxClassification = '4' or EUTaxClassification = 'C') and
ReportingCountry = 'PL'
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_JOURNALENTRY",
"I_ONETIMEACCOUNTBP",
"I_STRPJOURNALENTRYLOG",
"I_STRPREPRUN",
"I_STRPTAXITMWITHEUTAXCLASS",
"P_PL_STRPREPORTINGGROUPSCR",
"P_T007B_GLO"
],
"ASSOCIATED":
[
"I_JOURNALENTRY"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/