Skip to content

Commit

Permalink
Merge pull request #37 from hmrc/refactor-financial-transaction-code
Browse files Browse the repository at this point in the history
Do not use main or sub values to identify charge codes
  • Loading branch information
cybersaurus authored Feb 1, 2018
2 parents e948883 + e0c1270 commit e098cb3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 33 deletions.
10 changes: 8 additions & 2 deletions app/uk/gov/hmrc/epayeapi/models/in/EpayeReads.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@
package uk.gov.hmrc.epayeapi.models.in

import play.api.libs.json.Json.reads
import play.api.libs.json.{Format, Json, Reads}
import play.api.libs.json._
import uk.gov.hmrc.epayeapi.models.TaxYear

trait EpayeReads {
implicit lazy val taxYearReads: Reads[TaxYear] = reads[TaxYear]
implicit lazy val epayeTaxMonthReads: Reads[EpayeTaxMonth] = reads[EpayeTaxMonth]
implicit lazy val epayeCodeReads: Reads[EpayeCode] = new Reads[EpayeCode]() {
override def reads(json: JsValue): JsResult[EpayeCode] =
json match {
case JsString(name) => JsSuccess(EpayeCode(name))
case _ => JsError()
}
}

implicit lazy val annualTotalReads: Reads[AnnualTotal] = reads[AnnualTotal]
implicit lazy val lineItemReads: Reads[LineItem] = reads[LineItem]
Expand All @@ -40,7 +47,6 @@ trait EpayeReads {
implicit lazy val epayeMonthlyCreditsReads: Reads[EpayeMonthlyCredits] = reads[EpayeMonthlyCredits]
implicit lazy val epayeMonthlyChargesDetailsReads: Reads[EpayeMonthlyChargesDetails] = reads[EpayeMonthlyChargesDetails]
implicit lazy val epayeMonthlyStatementItemReads: Reads[EpayeMonthlyStatementItem] = reads[EpayeMonthlyStatementItem]
implicit lazy val epayeCodeReads: Reads[EpayeCode] = reads[EpayeCode]
implicit lazy val epayeMonthlyPaymentDetailsReads: Reads[EpayeMonthlyPaymentDetails] = reads[EpayeMonthlyPaymentDetails]
implicit lazy val epayeMonthlyPaymentItemReads: Reads[EpayeMonthlyPaymentItem] = reads[EpayeMonthlyPaymentItem]
implicit lazy val epayeMonthlyBalanceReads: Reads[EpayeMonthlyBalance] = reads[EpayeMonthlyBalance]
Expand Down
36 changes: 6 additions & 30 deletions test/resources/epaye/monthly-statement/in/2017-3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,15 @@
"fps": {
"items": [
{
"code": {
"main": "2000",
"sub": "1020",
"name": "RTI_IN_YEAR_CHARGE_NIC1"
},
"code": "RTI_IN_YEAR_CHARGE_NIC1",
"amount": 300
},
{
"code": {
"main": "2000",
"sub": "1100",
"name": "RTI_IN_YEAR_CHARGE_STUDENT_LOAN_DEDUCTION"
},
"code": "RTI_IN_YEAR_CHARGE_STUDENT_LOAN_DEDUCTION",
"amount": 300
},
{
"code": {
"main": "2000",
"sub": "1000",
"name": "RTI_IN_YEAR_CHARGE_INCOME_TAX"
},
"code": "RTI_IN_YEAR_CHARGE_INCOME_TAX",
"amount": 500
}
],
Expand Down Expand Up @@ -52,19 +40,11 @@
"eps": {
"items": [
{
"code": {
"main": "2130",
"sub": "1355",
"name": "RTI_EMPLOYMENT_ALLOWANCE_CHARGE"
},
"code": "RTI_EMPLOYMENT_ALLOWANCE_CHARGE",
"amount": 300
},
{
"code": {
"main": "2030",
"sub": "1290",
"name": "RTI_SHARED_PARENT_PAY"
},
"code": "RTI_SHARED_PARENT_PAY",
"amount": 200
}
],
Expand All @@ -84,11 +64,7 @@
"writeOffs": {
"items": [
{
"code": {
"main": "2000",
"sub": "1020",
"name": "RTI_IN_YEAR_CHARGE_NIC1"
},
"code": "RTI_IN_YEAR_CHARGE_NIC1",
"amount": 50
}
],
Expand Down
1 change: 0 additions & 1 deletion test/uk/gov/hmrc/epayeapi/router/ApiRouterTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/


package uk.gov.hmrc.epayeapi.router


Expand Down

0 comments on commit e098cb3

Please sign in to comment.