Commit 4e0c2844 by Amelin Konstantin

Add RegAmendTradeTemplate

parent 674d4e52
...@@ -38,7 +38,7 @@ object Main { ...@@ -38,7 +38,7 @@ object Main {
case Success(v) if v == "commoditySwap" => case Success(v) if v == "commoditySwap" =>
if (debugMode) new CommoditySwapTemplate(source) with Logger else new CommoditySwapTemplate(source) if (debugMode) new CommoditySwapTemplate(source) with Logger else new CommoditySwapTemplate(source)
case Success(v) if v == "masterAgreementTerms" => case Success(v) if v == "masterAgreementTerms" =>
throw new Exception("Undefined trade type") if (debugMode) new MasterAgreementTemplate(source) with Logger else new MasterAgreementTemplate(source)
case Failure(_) => case Failure(_) =>
Try { (source \ "markToMarketValuation").head } match { Try { (source \ "markToMarketValuation").head } match {
case Success(_) => case Success(_) =>
......
package templates
import scala.xml.Node
class MasterAgreementTemplate(source: Node) extends Template(source) {
def template: Node = {
<rtsrep:fairValueReportRegistration xmlns:fpml="http://www.fpml.org/FpML-5/recordkeeping"
xmlns:fpmlext="http://www.fpml.org/FpML-5/ext" xmlns:rtsrep="http://www.fpml.ru/repository"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" fpmlVersion="5-7">
<fpml:header>
<fpml:messageId>{ get(source \ "header" \"messageId") }</fpml:messageId>
<fpml:sentBy>{ get(source \ "header" \ "sentBy") }</fpml:sentBy>
<fpml:sendTo>{ get(source \ "header" \ "sendTo") }</fpml:sendTo>
<fpml:creationTimestamp>{ get(source \ "header" \ "creationTimestamp") }</fpml:creationTimestamp>
<fpml:implementationSpecification>
<fpml:version>2</fpml:version>
</fpml:implementationSpecification>
</fpml:header>
<fpml:isCorrection>{ get(source \ "isCorrection") }</fpml:isCorrection>
<fpml:correlationId correlationIdScheme="">{ get(source \ "correlationId") }</fpml:correlationId>
<rtsrep:fairValueReport>
<rtsrep:fairValueReportId>{ get(source \ "markToMarketValuation" \ "MTMIdentifier") }</rtsrep:fairValueReportId>
<rtsrep:tradeId>{ get(source \ "markToMarketValuation" \ "markToMarketDetails" \ "markToMarketInformation" \ "tradeId") }</rtsrep:tradeId>
<rtsrep:valuationTechnique>{ get(source \ "markToMarketValuation" \ "valuationMethod") }</rtsrep:valuationTechnique>
<rtsrep:fairValue>
<fpml:currency>{ get(source \ "markToMarketValuation" \ "markToMarketDetails" \ "markToMarketInformation" \ "currency") }</fpml:currency>
<fpml:amount>{ get(source \ "markToMarketValuation" \ "markToMarketDetails" \ "markToMarketInformation" \ "amount") }</fpml:amount>
</rtsrep:fairValue>
<rtsrep:valuationDate>{ get(source \ "markToMarketValuation" \ "markToMarketDetails" \ "valuationDateTime") }</rtsrep:valuationDate>
</rtsrep:fairValueReport>
{ for { s <- source \ "party"
id = get(s, "id").mkString
if id != "Sender" && id != "UTIGeneratingParty" } yield {
<fpml:party id={ id }>
<fpml:partyId partyIdScheme={ get(s \ "partyId", "partyIdScheme") }>{ get(s \ "partyId") }</fpml:partyId>
<fpml:partyName>{ get(s \ "partyName") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
</fpml:party>
}
}
</rtsrep:fairValueReportRegistration>
}
def isStraight = true
}
package templates
import scala.xml.Node
abstract class RegAmendTradeTemplate(source: Node) extends Template(source) {
protected[this] def templateTrade: Node
def template: Node = {
<fpml:nonpublicExecutionReport xmlns:fpml="http://www.fpml.org/FpML-5/recordkeeping"
xmlns:fpmlext="http://www.fpml.org/FpML-5/ext" xmlns:rtsrep="http://www.fpml.ru/repository"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" fpmlVersion="5-7">
<fpml:header>
<fpml:messageId>{ get(source \ "header" \"messageId") }</fpml:messageId>
<fpml:sentBy>{ get(source \ "header" \ "sentBy") }</fpml:sentBy>
<fpml:sendTo>{ get(source \ "header" \ "sendTo") }</fpml:sendTo>
<fpml:creationTimestamp>{ get(source \ "header" \ "creationTimestamp") }</fpml:creationTimestamp>
<fpml:implementationSpecification>
<fpml:version>2</fpml:version>
</fpml:implementationSpecification>
</fpml:header>
<fpml:isCorrection>{ get(source \ "isCorrection") }</fpml:isCorrection>
<fpml:correlationId correlationIdScheme="">{ get(source \ "correlationId") }</fpml:correlationId>
{ if (get(source \ "isCorrection").mkString == "false") templateTrade
else
<fpml:amendment>
{ templateTrade }
{ /* agreementDate isn`t present in the source */ }
<fpml:agreementDate>{ get(source \ "asOfDate") }</fpml:agreementDate>
</fpml:amendment>
}
{ for { s <- source \ "party"
id = get(s, "id").mkString
if id != "Sender" && id != "UTIGeneratingParty" } yield {
<fpml:party id={ id }>
<fpml:partyId partyIdScheme={ get(s \ "partyId", "partyIdScheme") }>{ get(s \ "partyId") }</fpml:partyId>
<fpml:partyName>{ get(s \ "partyName") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
</fpml:party>
}
}
{ for (s <- source \ "trade" \ "nsdSpecificTradeFields" \ "clientDetails") yield {
<fpml:party id={ get(s \ "id") }>
<fpml:partyId>{ get(s \ "id") }</fpml:partyId>
<fpml:partyName>{ get(s \ "name") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
</fpml:party>
}
}
</fpml:nonpublicExecutionReport>
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment