//@AbapCatalog.sqlViewName: 'PMYSRTXITMWPROD'
//@AccessControl.authorizationCheck: #NOT_REQUIRED
//@AccessControl.personalData.blocking: #NOT_REQUIRED
//@VDM.private: true
//@VDM.viewType: #COMPOSITE
//@ClientHandling.algorithm: #SESSION_VARIABLE
//@ObjectModel.usageType.sizeCategory: #XL
//@ObjectModel.usageType.serviceQuality: #D
//@ObjectModel.usageType.dataClass: #MIXED
@VDM.viewType: #COMPOSITE
@VDM.private: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED
@Metadata.ignorePropagatedAnnotations:true
define view entity P_MY_StRpTaxItemWithProduct
// extend statutory reporting tax item with product id and distribute tax base amount and tax amount by ratio
with parameters
P_StatryRptgEntity : srf_reporting_entity,
P_StatryRptCategory : srf_rep_cat_id,
P_StatryRptRunID : srf_report_run_id
as select from P_MY_StRpTxItmWithOriglDoc (
P_StatryRptgEntity : $parameters.P_StatryRptgEntity,
P_StatryRptCategory : $parameters.P_StatryRptCategory,
P_StatryRptRunID : $parameters.P_StatryRptRunID)
inner join I_OperationalAcctgDocItem on I_OperationalAcctgDocItem.CompanyCode = P_MY_StRpTxItmWithOriglDoc.CompanyCode
and (
( // normal tax case
I_OperationalAcctgDocItem.AccountingDocument = P_MY_StRpTxItmWithOriglDoc.AccountingDocument
and I_OperationalAcctgDocItem.FiscalYear = P_MY_StRpTxItmWithOriglDoc.FiscalYear
and I_OperationalAcctgDocItem.TaxCode = P_MY_StRpTxItmWithOriglDoc.TaxCode
)
or( // defer tax case
I_OperationalAcctgDocItem.AccountingDocument = P_MY_StRpTxItmWithOriglDoc.TaxTransferDocument
and I_OperationalAcctgDocItem.FiscalYear = P_MY_StRpTxItmWithOriglDoc.TaxTransferDocumentYear
and I_OperationalAcctgDocItem.TaxCode = P_MY_StRpTxItmWithOriglDoc.TargetTaxCode
// exclude defer tax partial transfer
and P_MY_StRpTxItmWithOriglDoc.PartialGrossAmtInLocalCrcy = P_MY_StRpTxItmWithOriglDoc.GrossAmtInLocalCrcy
)
)
and I_OperationalAcctgDocItem.Product <> '' // exclude non-mateiral line item
and I_OperationalAcctgDocItem.AccountingDocumentItemType = '' // exclude discount line item
and P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType <> '' // exclude tax item with tax code not mapped to tax box
{
key P_MY_StRpTxItmWithOriglDoc.CompanyCode,
key P_MY_StRpTxItmWithOriglDoc.AccountingDocument,
key P_MY_StRpTxItmWithOriglDoc.FiscalYear,
key I_OperationalAcctgDocItem.AccountingDocumentItem,
key P_MY_StRpTxItmWithOriglDoc.TaxItem,
key P_MY_StRpTxItmWithOriglDoc.TaxCode,
key P_MY_StRpTxItmWithOriglDoc.TransactionTypeDetermination,
key P_MY_StRpTxItmWithOriglDoc.TaxItemGroupingVersion,
key P_MY_StRpTxItmWithOriglDoc.ValidFrom,
key P_MY_StRpTxItmWithOriglDoc.TaxBoxStructureType,
key P_MY_StRpTxItmWithOriglDoc.TaxGroup,
key P_MY_StRpTxItmWithOriglDoc.TaxBox,
key P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType,
key P_MY_StRpTxItmWithOriglDoc.TaxBoxAggregationOperation,
key I_OperationalAcctgDocItem.Product as Product,
key $parameters.P_StatryRptgEntity as StatryRptgEntity, //P_MY_StRpTxItmWithOriglDoc._ReportedItemsLog.StatryRptgEntity,
key $parameters.P_StatryRptCategory as StatryRptCategory, //P_MY_StRpTxItmWithOriglDoc._ReportedItemsLog.StatryRptCategory,
key $parameters.P_StatryRptRunID as StatryRptRunID, //P_MY_StRpTxItmWithOriglDoc._ReportedItemsLog.StatryRptRunID,
P_MY_StRpTxItmWithOriglDoc.StatryRptRun,
P_MY_StRpTxItmWithOriglDoc.CAReconciliationKey,
P_MY_StRpTxItmWithOriglDoc.TaxRate,
P_MY_StRpTxItmWithOriglDoc.TaxRateValidityStartDate,
P_MY_StRpTxItmWithOriglDoc.TaxType,
P_MY_StRpTxItmWithOriglDoc.GLAccount,
P_MY_StRpTxItmWithOriglDoc.BusinessPlace,
P_MY_StRpTxItmWithOriglDoc.TaxJurisdiction,
P_MY_StRpTxItmWithOriglDoc.LowestLevelTaxJurisdiction,
P_MY_StRpTxItmWithOriglDoc.AccountingDocumentType,
P_MY_StRpTxItmWithOriglDoc.ReferenceDocumentType,
P_MY_StRpTxItmWithOriglDoc.ReverseDocument,
P_MY_StRpTxItmWithOriglDoc.ReverseDocumentFiscalYear,
P_MY_StRpTxItmWithOriglDoc.DocumentReferenceID,
P_MY_StRpTxItmWithOriglDoc.Ledger,
P_MY_StRpTxItmWithOriglDoc.LedgerGroup,
P_MY_StRpTxItmWithOriglDoc.ReportingDate,
P_MY_StRpTxItmWithOriglDoc.PostingDate,
P_MY_StRpTxItmWithOriglDoc.DocumentDate,
P_MY_StRpTxItmWithOriglDoc.TaxReportingDate,
P_MY_StRpTxItmWithOriglDoc.FiscalPeriod,
P_MY_StRpTxItmWithOriglDoc.ExchangeRate,
P_MY_StRpTxItmWithOriglDoc.IsReversal,
P_MY_StRpTxItmWithOriglDoc.IsReversed,
P_MY_StRpTxItmWithOriglDoc.AccountingDocumentHeaderText,
P_MY_StRpTxItmWithOriglDoc.ReportingCountry,
P_MY_StRpTxItmWithOriglDoc.CompanyCodeCurrency,
//@Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
-cast( I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency as abap.dec(23, 2) )
else
cast( I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency as abap.dec(23, 2) )
end as TaxBaseAmountInCoCodeCrcy,
//@Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
-cast(round(( get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxAmountInCoCodeCrcy ) *
get_numeric_value( I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) )/ get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
else
cast(round(( get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxAmountInCoCodeCrcy ) *
get_numeric_value( I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) )/ get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
end
end as TaxAmountInCoCodeCrcy,
P_MY_StRpTxItmWithOriglDoc.DocumentCurrency,
//@Semantics: { amount : {currencyCode: 'DocumentCurrency'} }
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
-cast(round(( get_numeric_value( P_MY_StRpTxItmWithOriglDoc.AmountInTransactionCurrency) *
get_numeric_value( I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) )/ get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
else
cast(round(( get_numeric_value( P_MY_StRpTxItmWithOriglDoc.AmountInTransactionCurrency) *
get_numeric_value( I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) )/ get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
end
end as AmountInTransactionCurrency,
//@Semantics: { amount : {currencyCode: 'DocumentCurrency'} }
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
-cast( I_OperationalAcctgDocItem.AmountInTransactionCurrency as abap.dec(23, 2) )
else
cast( I_OperationalAcctgDocItem.AmountInTransactionCurrency as abap.dec(23, 2) )
end as TaxBaseAmountInTransCrcy,
//@Semantics: { amount : {currencyCode: 'DocumentCurrency'} }
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
- cast(round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxAmount) *
get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) )/ get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
else
cast(round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxAmount) *
get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) )/ get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
end
end as TaxAmount, //Tax amount in transaction currency
// case P_MY_StRpTxItmWithOriglDoc.ReportingCountry
// when P_MY_StRpTxItmWithOriglDoc.CompanyCodeCountry then
// P_MY_StRpTxItmWithOriglDoc.CompanyCodeCurrency
// else
//
// P_MY_StRpTxItmWithOriglDoc.CountryCurrency
// end as ReportingCurrency,
P_MY_StRpTxItmWithOriglDoc.ReportingCurrency,
//@Semantics: { amount : {currencyCode: 'ReportingCurrency'} }
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
- cast(round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.AmountInReportingCurrency) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) ) /
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
else
cast(round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.AmountInReportingCurrency) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) ) /
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
end
end as AmountInReportingCurrency,
P_MY_StRpTxItmWithOriglDoc.AdditionalCurrency1,
//@Semantics: { amount : {currencyCode: 'AdditionalCurrency1'} }
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
-cast(round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.AmountInAdditionalCurrency1) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) ) /
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2)) // tax amount for a given material
else
cast(round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.AmountInAdditionalCurrency1) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) ) /
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2)) // tax amount for a given material
end
end
as AmountInAdditionalCurrency1,
//@Semantics: { amount : {currencyCode: 'AdditionalCurrency1'} }
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
-cast( I_OperationalAcctgDocItem.AmountInAdditionalCurrency1 as abap.dec(23, 2) )
else
cast( I_OperationalAcctgDocItem.AmountInAdditionalCurrency1 as abap.dec(23, 2) )
end as TaxBaseAmtInAdditionalCrcy1,
//@Semantics: { amount : {currencyCode: 'AdditionalCurrency1'} }
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
- cast( round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxAmountInAdditionalCurrency1) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) ) /
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
else
cast( round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxAmountInAdditionalCurrency1) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) ) /
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) , 2) as abap.dec(23, 2))
end
end as TaxAmountInAdditionalCurrency1,
P_MY_StRpTxItmWithOriglDoc.AdditionalCurrency2,
//@Semantics: { amount : {currencyCode: 'AdditionalCurrency2'} }
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
- cast( round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.AmountInAdditionalCurrency2) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) ) /
get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy), 2) as abap.dec(23, 2))// tax amount for a given material
else
cast( round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.AmountInAdditionalCurrency2) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) ) /
get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy), 2) as abap.dec(23, 2))// tax amount for a given material
end
end
as AmountInAdditionalCurrency2,
// @Semantics.amount.currencyCode: 'AdditionalCurrency2'
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
- cast( I_OperationalAcctgDocItem.AmountInAdditionalCurrency2 as abap.dec(23, 2) )
else
cast( I_OperationalAcctgDocItem.AmountInAdditionalCurrency2 as abap.dec(23, 2) )
end as TaxBaseAmtInAdditionalCrcy2,
// @Semantics.amount.currencyCode: 'AdditionalCurrency2'
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case when P_MY_StRpTxItmWithOriglDoc.TaxType = 'V' then
-cast( round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxAmountInAdditionalCurrency2) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) ) /
get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy), 2) as abap.dec(23, 2))
else
cast( round(( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxAmountInAdditionalCurrency2) * get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) ) /
get_numeric_value( P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy), 2) as abap.dec(23, 2))
end
end as TaxAmountInAdditionalCurrency2,
P_MY_StRpTxItmWithOriglDoc._AccountingDocument,
P_MY_StRpTxItmWithOriglDoc._GLAccount,
P_MY_StRpTxItmWithOriglDoc._TaxJurisdiction
}
//defer tax partial transfer
union select from P_MY_StRpTxItmWithOriglDoc(
P_StatryRptgEntity : $parameters.P_StatryRptgEntity,
P_StatryRptCategory : $parameters.P_StatryRptCategory,
P_StatryRptRunID : $parameters.P_StatryRptRunID)
inner join I_OperationalAcctgDocItem on I_OperationalAcctgDocItem.CompanyCode = P_MY_StRpTxItmWithOriglDoc.CompanyCode
and ( // defer tax case
I_OperationalAcctgDocItem.AccountingDocument = P_MY_StRpTxItmWithOriglDoc.TaxTransferDocument
and I_OperationalAcctgDocItem.FiscalYear = P_MY_StRpTxItmWithOriglDoc.TaxTransferDocumentYear
and I_OperationalAcctgDocItem.TaxCode = P_MY_StRpTxItmWithOriglDoc.TargetTaxCode
// defer tax partial transfer
and P_MY_StRpTxItmWithOriglDoc.PartialGrossAmtInLocalCrcy <> P_MY_StRpTxItmWithOriglDoc.GrossAmtInLocalCrcy
)
and I_OperationalAcctgDocItem.Product <> '' // exclude non-mateiral line item
and I_OperationalAcctgDocItem.AccountingDocumentItemType = '' // exclude discount line item
and P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType <> '' // exclude tax item with tax code not mapped to tax box
{
key P_MY_StRpTxItmWithOriglDoc.CompanyCode,
key P_MY_StRpTxItmWithOriglDoc.AccountingDocument,
key P_MY_StRpTxItmWithOriglDoc.FiscalYear,
key I_OperationalAcctgDocItem.AccountingDocumentItem,
key P_MY_StRpTxItmWithOriglDoc.TaxItem,
key P_MY_StRpTxItmWithOriglDoc.TaxCode,
key P_MY_StRpTxItmWithOriglDoc.TransactionTypeDetermination,
key P_MY_StRpTxItmWithOriglDoc.TaxItemGroupingVersion,
key P_MY_StRpTxItmWithOriglDoc.ValidFrom,
key P_MY_StRpTxItmWithOriglDoc.TaxBoxStructureType,
key P_MY_StRpTxItmWithOriglDoc.TaxGroup,
key P_MY_StRpTxItmWithOriglDoc.TaxBox,
key P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType,
key P_MY_StRpTxItmWithOriglDoc.TaxBoxAggregationOperation,
key I_OperationalAcctgDocItem.Product as Product,
key $parameters.P_StatryRptgEntity as StatryRptgEntity, //P_MY_StRpTxItmWithOriglDoc._ReportedItemsLog.StatryRptgEntity,
key $parameters.P_StatryRptCategory as StatryRptCategory, //P_MY_StRpTxItmWithOriglDoc._ReportedItemsLog.StatryRptCategory,
key $parameters.P_StatryRptRunID as StatryRptRunID, //P_MY_StRpTxItmWithOriglDoc._ReportedItemsLog.StatryRptRunID,
P_MY_StRpTxItmWithOriglDoc.StatryRptRun,
P_MY_StRpTxItmWithOriglDoc.CAReconciliationKey,
P_MY_StRpTxItmWithOriglDoc.TaxRate,
P_MY_StRpTxItmWithOriglDoc.TaxRateValidityStartDate,
P_MY_StRpTxItmWithOriglDoc.TaxType,
P_MY_StRpTxItmWithOriglDoc.GLAccount,
P_MY_StRpTxItmWithOriglDoc.BusinessPlace,
P_MY_StRpTxItmWithOriglDoc.TaxJurisdiction,
P_MY_StRpTxItmWithOriglDoc.LowestLevelTaxJurisdiction,
P_MY_StRpTxItmWithOriglDoc.AccountingDocumentType,
P_MY_StRpTxItmWithOriglDoc.ReferenceDocumentType,
P_MY_StRpTxItmWithOriglDoc.ReverseDocument,
P_MY_StRpTxItmWithOriglDoc.ReverseDocumentFiscalYear,
P_MY_StRpTxItmWithOriglDoc.DocumentReferenceID,
P_MY_StRpTxItmWithOriglDoc.Ledger,
P_MY_StRpTxItmWithOriglDoc.LedgerGroup,
P_MY_StRpTxItmWithOriglDoc.ReportingDate,
P_MY_StRpTxItmWithOriglDoc.PostingDate,
P_MY_StRpTxItmWithOriglDoc.DocumentDate,
P_MY_StRpTxItmWithOriglDoc.TaxReportingDate,
P_MY_StRpTxItmWithOriglDoc.FiscalPeriod,
P_MY_StRpTxItmWithOriglDoc.ExchangeRate,
P_MY_StRpTxItmWithOriglDoc.IsReversal,
P_MY_StRpTxItmWithOriglDoc.IsReversed,
P_MY_StRpTxItmWithOriglDoc.AccountingDocumentHeaderText,
P_MY_StRpTxItmWithOriglDoc.ReportingCountry,
P_MY_StRpTxItmWithOriglDoc.CompanyCodeCurrency,
// division(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency *
// cast(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio as abap.dec(10, 6) ) //partial transfer ratio
// , 100, 2) as TaxBaseAmountInCoCodeCrcy,
cast(round(get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio) //partial transfer ratio
/ 100, 2) as abap.dec(23, 2)) as TaxBaseAmountInCoCodeCrcy,
//I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency * transfer ratio as TaxBaseAmountInCoCodeCrcy,
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast (0 as abap.dec(23, 2) )
else
cast( round( get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) * get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxRate)
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio )/ 10000, 2 ) as abap.dec(23, 2)
) //material line shall be multiplied by transfer ratio also
end as TaxAmountInCoCodeCrcy,
P_MY_StRpTxItmWithOriglDoc.DocumentCurrency,
case P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType
when 'B' then
// division(I_OperationalAcctgDocItem.AmountInTransactionCurrency *
// cast(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio as abap.dec(10, 6) ) //partial transfer ratio
// , 100, 2)
//tax base amount for a given material
cast( round( get_numeric_value(I_OperationalAcctgDocItem.AmountInTransactionCurrency) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio ) //partial transfer ratio
/ 100, 2) as abap.dec(23, 2) )
else //when 'T'
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast (0 as abap.dec(23, 2) )
else
cast(
round( (get_numeric_value(I_OperationalAcctgDocItem.AmountInTransactionCurrency) * get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxRate )
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio )) / 10000, 2 ) as abap.dec(23, 2)
)
end
end as AmountInTransactionCurrency,
cast(round(get_numeric_value(I_OperationalAcctgDocItem.AmountInTransactionCurrency) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio) //partial transfer ratio
/ 100, 2) as abap.dec(23, 2) ) as TaxBaseAmountInTransCrcy,
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
cast(
round( (get_numeric_value(I_OperationalAcctgDocItem.AmountInTransactionCurrency) * get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxRate)
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio)) / 10000, 2 ) as abap.dec(23, 2)
)
end as TaxAmount,
case P_MY_StRpTxItmWithOriglDoc.ReportingCountry
when P_MY_StRpTxItmWithOriglDoc.CompanyCodeCountry then
P_MY_StRpTxItmWithOriglDoc.CompanyCodeCurrency
else
P_MY_StRpTxItmWithOriglDoc.CountryCurrency
end as ReportingCurrency,
case P_MY_StRpTxItmWithOriglDoc.ReportingCountry
when P_MY_StRpTxItmWithOriglDoc.CompanyCodeCountry then
case P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType
when 'B' then
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio ) //partial transfer ratio
/ 100, 2) as abap.dec(23, 2) ) //as AmountInCompanyCodeCurrency, //I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency //tax base amount for a given material line
else //when 'T'
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency ) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxRate )
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio ) / 10000, 2) as abap.dec(23, 2)) // tax amount for a given material
end
end
else // Plant Aborad Case
// TaxBaseAmountInRptgCrcy has to be reported from AmountInCountryCrcy,
// for a given material line AmountInCountryCrcy has to be indirectly derived by ratio
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
case P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType
when 'B' then
cast(round( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCountryCrcy )
* get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency )
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio )/ 100 / get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ), 2)
as abap.dec(23, 2) )
else //when 'T'
cast(round( get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxAmountInCountryCrcy)
* get_numeric_value(I_OperationalAcctgDocItem.AmountInCompanyCodeCurrency)
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio )/ 100 / get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy ) ,2)
as abap.dec(23, 2)
)
end
end
end as AmountInReportingCurrency,
P_MY_StRpTxItmWithOriglDoc.AdditionalCurrency1,
case P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType
when 'B' then
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInAdditionalCurrency1) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio ) //partial transfer ratio
/ 100, 2) as abap.dec(23, 2) ) //I_OperationalAcctgDocItem.AmountInAdditionalCurrency1 //tax base amount for a given material
else //when 'T'
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInAdditionalCurrency1) * get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxRate )
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio )/ 10000, 2 ) as abap.dec(23, 2)
)
end
end as AmountInAdditionalCurrency1,
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInAdditionalCurrency1) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio ) //partial transfer ratio
/ 100, 2) as abap.dec(23, 2) ) as TaxBaseAmtInAdditionalCrcy1, //I_OperationalAcctgDocItem.AmountInAdditionalCurrency1 as TaxBaseAmtInAdditionalCrcy1,
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInAdditionalCurrency1) * get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxRate )
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio )/ 10000, 2) as abap.dec(23, 2)
)
end as TaxAmountInAdditionalCurrency1,
P_MY_StRpTxItmWithOriglDoc.AdditionalCurrency2,
case P_MY_StRpTxItmWithOriglDoc.TaxDeclnAmountType
when 'B' then
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInAdditionalCurrency2) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio ) //partial transfer ratio
/ 100, 2) as abap.dec(23, 2) ) //I_OperationalAcctgDocItem.AmountInAdditionalCurrency2 //tax base amount for a given material
else //when 'T'
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInAdditionalCurrency2 ) * get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxRate )
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio )/ 10000, 2 ) as abap.dec(23, 2)
)
end
end as AmountInAdditionalCurrency2,
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInAdditionalCurrency2) *
get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio ) //partial transfer ratio
/ 100, 2) as abap.dec(23, 2) )
as TaxBaseAmtInAdditionalCrcy2, //I_OperationalAcctgDocItem.AmountInAdditionalCurrency2 as TaxBaseAmtInAdditionalCrcy2,
case P_MY_StRpTxItmWithOriglDoc.TaxBaseAmountInCoCodeCrcy
when 0 then
cast( 0 as abap.dec(23, 2) )
else
cast(round( get_numeric_value(I_OperationalAcctgDocItem.AmountInAdditionalCurrency2 ) * get_numeric_value(P_MY_StRpTxItmWithOriglDoc.TaxRate)
* get_numeric_value(P_MY_StRpTxItmWithOriglDoc.PartialTransferRatio)/ 10000, 2 ) as abap.dec(23, 2)
)
end as TaxAmountInAdditionalCurrency2,
P_MY_StRpTxItmWithOriglDoc._AccountingDocument,
P_MY_StRpTxItmWithOriglDoc._GLAccount,
P_MY_StRpTxItmWithOriglDoc._TaxJurisdiction
}