From 33e8793857b6cf3c99c2c275d9317fa90a9d2086 Mon Sep 17 00:00:00 2001 From: Richard Bull Date: Fri, 14 Feb 2025 11:34:23 +0000 Subject: [PATCH 1/2] SAN-230 Add reason to Penalties / Payment endpoints for Penalty summary and Penalty paid screens [Late filing of accounts | Failure to file a confirmation statement] * Add reason to TransactionListItem, TransactionItem, TransactionDao model Update Swagger Docs * GET /company/{company_number}/penalties/late-filing/{penalty_reference_type} * GET /company/{company_number}/penalties/late-filing/payable/{payable_ref} --- assets/penalty_details.yml | 2 +- go.mod | 4 +- go.sum | 60 +----------- ...erate_transaction_list_from_e5_response.go | 10 ++ ..._transaction_list_from_e5_response_test.go | 52 ++++++++++- issuer_gateway/private/match_penalty.go | 1 + issuer_gateway/private/match_penalty_test.go | 32 ++++--- spec/schema.json | 93 ++++++++++++------- transformers/payable_resource.go | 2 + version | 2 +- 10 files changed, 150 insertions(+), 108 deletions(-) diff --git a/assets/penalty_details.yml b/assets/penalty_details.yml index 580c7cf..a9df052 100644 --- a/assets/penalty_details.yml +++ b/assets/penalty_details.yml @@ -15,5 +15,5 @@ details: ResourceKind: "penalty#sanctions" ProductType: "penalty-sanctions" EmailReceivedAppId: "penalty-payment-api.penalty_payment_received_email" - EmailFilingDesc: "Sanctions Penalty Payment" + EmailFilingDesc: "Failure to file a confirmation statement" EmailMsgType: "penalty_payment_received_email" \ No newline at end of file diff --git a/go.mod b/go.mod index eff4eeb..560d7ab 100644 --- a/go.mod +++ b/go.mod @@ -9,10 +9,11 @@ require ( github.com/companieshouse/go-sdk-manager v0.1.12 github.com/companieshouse/go-session-handler v0.1.5 github.com/companieshouse/gofigure v0.1.4 - github.com/companieshouse/penalty-payment-api-core v1.0.8 + github.com/companieshouse/penalty-payment-api-core v1.1.2 github.com/golang/mock v1.6.0 github.com/gorilla/mux v1.8.0 github.com/jarcoal/httpmock v1.0.4 + github.com/pkg/errors v0.9.1 github.com/smartystreets/goconvey v1.7.2 go.mongodb.org/mongo-driver v1.10.2 gopkg.in/go-playground/validator.v9 v9.31.0 @@ -45,7 +46,6 @@ require ( github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/montanaflynn/stats v0.6.6 // indirect github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/smartystreets/assertions v1.2.0 // indirect github.com/stretchr/objx v0.4.0 // indirect diff --git a/go.sum b/go.sum index 35f20e5..ebdf789 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,4 @@ -cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go/compute v1.7.0 h1:v/k9Eueb8aAJ0vZuxKMrgm6kPhCLZU9HxFU+AFDs9Uk= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 h1:2T/jmrHeTezcCM58lvEQXs0UpQJCo5SoGAcg+mbSTIg= github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Shopify/sarama v1.23.1 h1:XxJBCZEoWJtoWjf/xRbmGUpAmTZGnuuF0ON0EvxxBrs= @@ -13,7 +10,6 @@ github.com/companieshouse/api-sdk-go v0.1.35/go.mod h1:y7Mly0M9Jfgq/hhlWNodyWI9F github.com/companieshouse/api-sdk-go v0.1.62 h1:QSz4QqZCHsVzQKrjGAm9GL6v5x2HXuuIZVbF2cJeRDs= github.com/companieshouse/api-sdk-go v0.1.62/go.mod h1:EPQs0VpscYj7QFKYRlZk6T8a64py54/fqwt6QrCuYZY= github.com/companieshouse/chs.go v1.1.0/go.mod h1:LVtty6/5ttvNf12V/nPySaIFgfYPLeT0jymabuzmSDg= -github.com/companieshouse/chs.go v1.1.10/go.mod h1:fI/z3fegJtQyjOWP2HSj+im96Djn399DbckG3Mi1eAo= github.com/companieshouse/chs.go v1.2.2/go.mod h1:93vQ2qlzSbZenUOFet+pAJzxHdz+w6BF1IvJ56lvC7c= github.com/companieshouse/chs.go v1.2.8 h1:HY2Wgd9MIKSaFplZ6FvQ+LdLoKrt53mikP8Kvmmk5X0= github.com/companieshouse/chs.go v1.2.8/go.mod h1:93vQ2qlzSbZenUOFet+pAJzxHdz+w6BF1IvJ56lvC7c= @@ -30,10 +26,9 @@ github.com/companieshouse/go-session-handler v0.1.5/go.mod h1:2lBRj2gEzuXNdgxHqH github.com/companieshouse/gofigure v0.1.0/go.mod h1:W7NZ4kQdDXqvqK1f7EKTc+pnnqpF1b7RcqRa17yAy2Q= github.com/companieshouse/gofigure v0.1.4 h1:BN7Dqn0xvNHwC+KHOUHigwP7ajkfHORos3hKRtEACUU= github.com/companieshouse/gofigure v0.1.4/go.mod h1:lBAsI13q21rMce+pO7x4xUYAXzO0MchuDsZUbCs0Yng= -github.com/companieshouse/htmlform v0.1.0 h1:oozdJabOBTFNgx1j4J4ojCD/3CTqcA7DEoiDKLZnLPY= github.com/companieshouse/htmlform v0.1.0/go.mod h1:fWScPVYjGyeBhYwppGaGRDtCQ5hMd3t3Q+0I6HaUZT4= -github.com/companieshouse/penalty-payment-api-core v1.0.8 h1:ShdZro7HsFe8SoRRpJezAMH6OEM/AifNrWtFM5T54Ek= -github.com/companieshouse/penalty-payment-api-core v1.0.8/go.mod h1:g0AHck3Ez+m3aqOdZBMLq+6GeNUwZCC+IuAXYzj6FnI= +github.com/companieshouse/penalty-payment-api-core v1.1.2 h1:00SlMHAwTyKJ/aeDEjyuXQWYNb7OVq90nwoXQza4SmY= +github.com/companieshouse/penalty-payment-api-core v1.1.2/go.mod h1:9cqGa5ZlpwYqFh5NlqIJJK39G4p2wBdoWJkuVW8Ssxc= github.com/companieshouse/private-api-sdk-go v0.1.11/go.mod h1:EaRgxVpcHv6IZ1LKp2xqE4rdEsQwgYqVz3g/BIHQVD4= github.com/companieshouse/private-api-sdk-go v0.1.13 h1:o9PD1aSVu3+tbf/WUZT/wX1e0DNx+9xcJugbqo7rbxE= github.com/companieshouse/private-api-sdk-go v0.1.13/go.mod h1:g1zvBCn8Tyc45x+5BmlHsq+BYwuekd5FLRaFOqTUu+A= @@ -47,21 +42,14 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/elodina/go-avro v0.0.0-20160406082632-0c8185d9a3ba h1:QkK2L3uvEaZJ40iFZbiMKz/yQF/MI2uaNO2iyV/ve6w= github.com/elodina/go-avro v0.0.0-20160406082632-0c8185d9a3ba/go.mod h1:3A7SOsr8WBIpkWUsqzMpR3tIQbanKqxZcis2GSl12Nk= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -75,30 +63,22 @@ github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/pat v1.0.1 h1:OeSoj6sffw4/majibAY2BAUsXjNP7fEE+w30KickaL4= github.com/gorilla/pat v1.0.1/go.mod h1:YeAe0gNeiNT5hoiZRI4yiOky6jVdNvfO2N6Kav/HmxY= -github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY= github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= -github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ= github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ian-kent/envconf v0.0.0-20141026121121-c19809918c02 h1:dU8zq210pt1b71X8xh9GOxC7uBHNtQ9BYC+Lb6SA/mA= github.com/ian-kent/envconf v0.0.0-20141026121121-c19809918c02/go.mod h1:1m5fo3aKG2moYtGHC4I2nFkXmG97+vCeaEIWC+mXTSI= -github.com/ian-kent/gofigure v0.0.0-20170502192241-c9dc3a1359af h1:oxo0HMosJCLANWHuCqK4Q5osVtEhNE+eAttHsz9lbV8= github.com/ian-kent/gofigure v0.0.0-20170502192241-c9dc3a1359af/go.mod h1:dDnv8KaO0exx5ZUA/gvkuUvj8aX7njir7sOwoAk8MKo= github.com/jarcoal/httpmock v1.0.4 h1:jp+dy/+nonJE4g4xbVtl9QdrUNbn6/3hDT5R4nDIZnA= github.com/jarcoal/httpmock v1.0.4/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= @@ -110,18 +90,15 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/justinas/alice v0.0.0-20171023064455-03f45bd4b7da/go.mod h1:oLH0CmIaxCGXD67VKGR5AacGXZSMznlmeqM8RzPrcY8= github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo= github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA= -github.com/justinas/nosurf v0.0.0-20190416172904-05988550ea18 h1:ci3v0mUqcCewO25ntt7hprt2ZMNA0AWI6s6qV0rSpc0= github.com/justinas/nosurf v0.0.0-20190416172904-05988550ea18/go.mod h1:Aucr5I5chr4OCuuVB4LTuHVrKHBuyRSo7vM2hqrcb7E= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -145,14 +122,12 @@ github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41 h1:GeinFsrjWz97fAxVUEd github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.2.1 h1:F++O52m40owAmADcojzM+9gyjmMOY/T4oYJkgFDH8RE= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da h1:p3Vo3i64TCLY7gIfzeQaUJ+kppEO5WQG3cL8iE8tGHU= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= @@ -171,45 +146,33 @@ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMT github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/unrolled/render v1.0.1 h1:VDDnQQVfBMsOsp3VaCJszSO0nkBIVEYoPWeRThk9spY= github.com/unrolled/render v1.0.1/go.mod h1:gN9T0NhL4Bfbwu8ann7Ry/TGHYfosul+J0obPf6NBdM= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/wvanbergen/kafka v0.0.0-20171203153745-e2edea948ddf h1:TOV5PC6fIWwFOFra9xJfRXZcL2pLhMI8oNuDugNxg9Q= github.com/wvanbergen/kafka v0.0.0-20171203153745-e2edea948ddf/go.mod h1:nxx7XRXbR9ykhnC8lXqQyJS0rfvJGxKyKw/sT1YOttg= -github.com/wvanbergen/kazoo-go v0.0.0-20180202103751-f72d8611297a h1:ILoU84rj4AQ3q6cjQvtb9jBjx4xzR/Riq/zYhmDQiOk= github.com/wvanbergen/kazoo-go v0.0.0-20180202103751-f72d8611297a/go.mod h1:vQQATAGxVK20DC1rRubTJbZDDhhpA4QfU02pMdPxGO4= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= -github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= -github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0= github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk= github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4= -github.com/yuin/goldmark v1.3.5 h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.mongodb.org/mongo-driver v1.8.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= go.mongodb.org/mongo-driver v1.10.2 h1:4Wk3cnqOrQCn0P92L3/mmurMxzdvWWs5J9jinAVKD+k= go.mongodb.org/mongo-driver v1.10.2/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -228,7 +191,6 @@ golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= @@ -237,7 +199,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -246,31 +207,21 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= @@ -279,9 +230,7 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= -gopkg.in/bluesuncorp/validator.v5 v5.10.3 h1:clgxLhQVQIE5krWHyYuqJralvQ9SkkTh3AdZGeQL2D4= gopkg.in/bluesuncorp/validator.v5 v5.10.3/go.mod h1:ScQmud/GM3iSR85jRE+8BI8E8oFv5oj4qyd5Xaw7hgE= -gopkg.in/bsm/sarama-cluster.v2 v2.1.15 h1:iELfaYDWd+x3wz4j/Z48fTx3idGITVePYf5Fzr/d1XU= gopkg.in/bsm/sarama-cluster.v2 v2.1.15/go.mod h1:PH+cn1N1hKueFCL+6Kz/HLj3ARW4Oop7WH3u0Ivp14w= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= @@ -289,7 +238,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/jcmturner/aescts.v1 v1.0.1 h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hrEw= @@ -313,7 +261,3 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/issuer_gateway/private/generate_transaction_list_from_e5_response.go b/issuer_gateway/private/generate_transaction_list_from_e5_response.go index 8cc1c5d..70c98cf 100644 --- a/issuer_gateway/private/generate_transaction_list_from_e5_response.go +++ b/issuer_gateway/private/generate_transaction_list_from_e5_response.go @@ -60,6 +60,7 @@ func buildTransactionListItemFromE5Transaction(e5Transaction *e5.Transaction, al transactionListItem.OriginalAmount = e5Transaction.Amount transactionListItem.Outstanding = e5Transaction.OutstandingAmount transactionListItem.Type = getTransactionType(e5Transaction, allowedTransactionsMap) + transactionListItem.Reason = getReason(e5Transaction) return transactionListItem, nil } @@ -74,3 +75,12 @@ func getTransactionType(e5Transaction *e5.Transaction, allowedTransactionsMap *m return types.Other.String() } } + +func getReason(transaction *e5.Transaction) string { + if transaction.CompanyCode == utils.LateFilingPenalty { + return "Late filing of accounts" + } else if transaction.CompanyCode == utils.Sanctions && (transaction.TransactionSubType == "S1" && transaction.TypeDescription == "CS01") { + return "Failure to file a confirmation statement" + } + return "Penalty" +} diff --git a/issuer_gateway/private/generate_transaction_list_from_e5_response_test.go b/issuer_gateway/private/generate_transaction_list_from_e5_response_test.go index 9bde1b0..c11f4fd 100644 --- a/issuer_gateway/private/generate_transaction_list_from_e5_response_test.go +++ b/issuer_gateway/private/generate_transaction_list_from_e5_response_test.go @@ -2,10 +2,11 @@ package private import ( "errors" + "testing" + "github.com/companieshouse/penalty-payment-api-core/models" "github.com/companieshouse/penalty-payment-api/config" "github.com/companieshouse/penalty-payment-api/e5" - "testing" . "github.com/smartystreets/goconvey/convey" ) @@ -85,3 +86,52 @@ func TestUnitGenerateTransactionListFromE5Response(t *testing.T) { So(transactionList, ShouldNotBeNil) }) } + +func TestUnit_getReason(t *testing.T) { + Convey("Get reason", t, func() { + type args struct { + transaction *e5.Transaction + } + testCases := []struct { + name string + args args + want string + }{ + { + name: "Late filing of accounts", + args: args{transaction: &e5.Transaction{ + CompanyCode: "LP", + TransactionType: "1", + TransactionSubType: "Other", + }}, + want: "Late filing of accounts", + }, + { + name: "Failure to file a confirmation statement", + args: args{transaction: &e5.Transaction{ + CompanyCode: "C1", + TransactionType: "1", + TransactionSubType: "S1", + TypeDescription: "CS01", + }}, + want: "Failure to file a confirmation statement", + }, + { + name: "Penalty", + args: args{transaction: &e5.Transaction{ + CompanyCode: "C1", + TransactionType: "1", + TransactionSubType: "S1", + }}, + want: "Penalty", + }, + } + for _, tc := range testCases { + Convey(tc.name, func() { + got := getReason(tc.args.transaction) + + So(got, ShouldEqual, tc.want) + }) + } + }) +} diff --git a/issuer_gateway/private/match_penalty.go b/issuer_gateway/private/match_penalty.go index 8ed2200..e4e61e3 100644 --- a/issuer_gateway/private/match_penalty.go +++ b/issuer_gateway/private/match_penalty.go @@ -47,6 +47,7 @@ func MatchPenalty(referenceTransactions []models.TransactionListItem, MadeUpDate: transaction.MadeUpDate, IsDCA: transaction.IsDCA, IsPaid: transaction.IsPaid, + Reason: transaction.Reason, } matchedPenalties = append(matchedPenalties, matchedPenalty) } else { diff --git a/issuer_gateway/private/match_penalty_test.go b/issuer_gateway/private/match_penalty_test.go index cabd9b1..d23278f 100644 --- a/issuer_gateway/private/match_penalty_test.go +++ b/issuer_gateway/private/match_penalty_test.go @@ -15,6 +15,7 @@ func TestUnitMatchPenalty(t *testing.T) { TransactionID: "121", Type: "penalty", Amount: 150, + Reason: "Failure to file a confirmation statement", }, } matchedPenalties := []models.TransactionItem{ @@ -23,6 +24,7 @@ func TestUnitMatchPenalty(t *testing.T) { Amount: 150, Type: "penalty", MadeUpDate: "2017-06-30", + Reason: "Failure to file a confirmation statement", IsDCA: false, IsPaid: false, }, @@ -32,6 +34,7 @@ func TestUnitMatchPenalty(t *testing.T) { TransactionID string Type string MadeUpDate string + Reason string IsDCA bool IsPaid bool OriginalAmount float64 @@ -39,20 +42,20 @@ func TestUnitMatchPenalty(t *testing.T) { WantMatched []models.TransactionItem WantError error }{ - {TransactionID: "120", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", OriginalAmount: 150, - IsDCA: false, IsPaid: false, WantMatched: nil, WantError: ErrTransactionDoesNotExist}, - {TransactionID: "121", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", OriginalAmount: 200, - IsDCA: false, IsPaid: false, WantMatched: nil, WantError: ErrTransactionIsPartPaid}, - {TransactionID: "121", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", OriginalAmount: 150, - IsDCA: false, IsPaid: true, WantMatched: nil, WantError: ErrTransactionIsPaid}, - {TransactionID: "121", Outstanding: 100, Type: "other", MadeUpDate: "2017-06-30", OriginalAmount: 100, - IsDCA: false, IsPaid: false, WantMatched: nil, WantError: ErrTransactionNotPayable}, - {TransactionID: "121", Outstanding: 100, Type: "penalty", MadeUpDate: "2017-06-30", OriginalAmount: 100, - IsDCA: false, IsPaid: false, WantMatched: nil, WantError: ErrTransactionAmountMismatch}, - {TransactionID: "121", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", OriginalAmount: 150, - IsDCA: true, IsPaid: false, WantMatched: nil, WantError: ErrTransactionDCA}, - {TransactionID: "121", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", OriginalAmount: 150, - IsDCA: false, IsPaid: false, WantMatched: matchedPenalties, WantError: nil}, + {TransactionID: "120", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", Reason: "Failure to file a confirmation statement", + OriginalAmount: 150, IsDCA: false, IsPaid: false, WantMatched: nil, WantError: ErrTransactionDoesNotExist}, + {TransactionID: "121", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", Reason: "Failure to file a confirmation statement", + OriginalAmount: 200, IsDCA: false, IsPaid: false, WantMatched: nil, WantError: ErrTransactionIsPartPaid}, + {TransactionID: "121", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", Reason: "Failure to file a confirmation statement", + OriginalAmount: 150, IsDCA: false, IsPaid: true, WantMatched: nil, WantError: ErrTransactionIsPaid}, + {TransactionID: "121", Outstanding: 100, Type: "other", MadeUpDate: "2017-06-30", Reason: "Failure to file a confirmation statement", + OriginalAmount: 100, IsDCA: false, IsPaid: false, WantMatched: nil, WantError: ErrTransactionNotPayable}, + {TransactionID: "121", Outstanding: 100, Type: "penalty", MadeUpDate: "2017-06-30", Reason: "Failure to file a confirmation statement", + OriginalAmount: 100, IsDCA: false, IsPaid: false, WantMatched: nil, WantError: ErrTransactionAmountMismatch}, + {TransactionID: "121", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", Reason: "Failure to file a confirmation statement", + OriginalAmount: 150, IsDCA: true, IsPaid: false, WantMatched: nil, WantError: ErrTransactionDCA}, + {TransactionID: "121", Outstanding: 150, Type: "penalty", MadeUpDate: "2017-06-30", Reason: "Failure to file a confirmation statement", + OriginalAmount: 150, IsDCA: false, IsPaid: false, WantMatched: matchedPenalties, WantError: nil}, } Convey("matchPenalty works correctly for different scenarios", t, func() { @@ -66,6 +69,7 @@ func TestUnitMatchPenalty(t *testing.T) { IsDCA: testCase.IsDCA, IsPaid: testCase.IsPaid, MadeUpDate: testCase.MadeUpDate, + Reason: testCase.Reason, }, } matched, err := MatchPenalty(refTransactions, transactionsToMatch, companyNumber) diff --git a/spec/schema.json b/spec/schema.json index 540ba39..15afbfd 100644 --- a/spec/schema.json +++ b/spec/schema.json @@ -2,8 +2,8 @@ "swagger": "2.0", "info": { "version": "1.1.0", - "title": "Penalty Payment Service (PPS) API", - "description": "An API that creates, patches, and retrieves Penalty Payment Service (PPS) sessions, as well as interacting with the E5 finance system" + "title": "Penalty Payment API", + "description": "An API for retrieving Penalties from the E5 finance system and recording / viewing Penalty Payments" }, "host": "api.companieshouse.gov.uk", "schemes": [ @@ -26,7 +26,7 @@ "tags": [ "Healthcheck" ], - "description": "Check the health of the Penalty Payment Service (PPS) API", + "description": "Check the health of the Penalty Payment API", "responses": { "200": { "description": "Healthy" @@ -79,7 +79,7 @@ ], "responses": { "200": { - "description": "a list of payable transactions", + "description": "A list of payable transactions", "schema": { "allOf": [ { @@ -103,10 +103,10 @@ "description": "Bad request - Invalid input" }, "404": { - "description": "the company does not exist" + "description": "The company does not exist" }, "500": { - "description": "there was a problem communicating with the finance backend" + "description": "There was a problem communicating with the finance backend" } } } @@ -148,12 +148,12 @@ "description": "Bad request - Invalid input" }, "500": { - "description": "there was a problem handling your request" + "description": "There was a problem handling your request" } } } }, - "/company/{company_number}/penalties/late-filing/payable/{payable_id}": { + "/company/{company_number}/penalties/late-filing/payable/{payable_ref}": { "parameters": [ { "in": "path", @@ -163,7 +163,7 @@ }, { "in": "path", - "name": "payable_id", + "name": "payable_ref", "required": true, "type": "string" } @@ -178,18 +178,18 @@ ], "responses": { "200": { - "description": "A representation of the full PPS payable resource", + "description": "A representation of the full Penalty payable resource", "schema": { "$ref": "#/definitions/PayableResource" } }, "500": { - "description": "the payable resource is not present in the request context" + "description": "The payable resource is not present in the request context" } } } }, - "/company/{company_number}/penalties/late-filing/payable/{payable_id}/payment": { + "/company/{company_number}/penalties/late-filing/payable/{payable_ref}/payment": { "parameters": [ { "in": "path", @@ -199,7 +199,7 @@ }, { "in": "path", - "name": "payable_id", + "name": "payable_ref", "required": true, "type": "string" } @@ -220,10 +220,10 @@ "description": "Bad request - Invalid input" }, "404": { - "description": "payable resource does not exist or has insufficient data" + "description": "Payable resource does not exist or has insufficient data" }, "500": { - "description": "payable resource does not exist or has insufficient data" + "description": "Payable resource does not exist or has insufficient data" } @@ -245,7 +245,7 @@ "description": "Mark this resource as paid. This will also mark the transactions as paid in E5", "responses": { "204": { - "description": "The PPS payable resource has successfully been marked as paid" + "description": "The Penalty payable resource has successfully been marked as paid" } } } @@ -322,12 +322,20 @@ "type": "number", "format": "float" }, + "type": { + "type": "string" + }, "made_up_date": { "type": "string", "format": "date" }, - "type": { - "type": "string" + "reason": { + "type": "string", + "enum": [ + "Late filing of accounts", + "Failure to file a confirmation statement", + "Penalty" + ] } } } @@ -408,7 +416,7 @@ "properties": { "id": { "type": "string", - "description": "the transaction reference" + "description": "The transaction reference" }, "etag": { "type": "string" @@ -418,7 +426,7 @@ }, "is_paid": { "type": "boolean", - "description": "indicates if this transaction has been paid" + "description": "Indicates if this transaction has been paid" }, "is_dca": { "type": "boolean" @@ -426,12 +434,12 @@ "due_date": { "type": "string", "format": "date", - "description": "when this payment of this transaction is due by" + "description": "When this payment of this transaction is due by" }, "made_up_date": { "type": "string", "format": "date", - "description": "cross reference the made up date of the accounts that were late being filed" + "description": "Cross reference the made up date of the accounts that were late being filed" }, "transaction_date": { "type": "string", @@ -440,12 +448,12 @@ "original_amount": { "type": "number", "format": "float", - "description": "the original amount for this transaction" + "description": "The original amount for this transaction" }, "outstanding": { "type": "number", "format": "float", - "description": "the amount outstanding. if this is less than the original amount, then it indicates this has been part paid" + "description": "The amount outstanding. If this is less than the original amount, then it indicates this has been part paid" }, "type": { "type": "string", @@ -455,6 +463,14 @@ "court-costs", "other" ] + }, + "reason": { + "type": "string", + "enum": [ + "Late filing of accounts", + "Failure to file a confirmation statement", + "Penalty" + ] } } }, @@ -547,7 +563,8 @@ "available_payment_methods", "links", "kind", - "resource_kind" + "resource_kind", + "product_type" ], "title": "cost", "properties": { @@ -556,8 +573,12 @@ "type": "string" }, "description_identifier": { - "description": "The enumuration identifier of the description.", - "type": "string" + "description": "The enumeration identifier of the description.", + "type": "string", + "enum": [ + "late-filing-penalty", + "penalty-sanctions" + ] }, "description_values": { "type": "object", @@ -577,8 +598,7 @@ "items": { "type": "string", "enum": [ - "credit-card", - "account" + "credit-card" ] } }, @@ -588,7 +608,6 @@ "items": { "type": "string", "enum": [ - "data-maintenance", "penalty" ] } @@ -602,7 +621,19 @@ }, "resource_kind": { "description": "The `kind` of the resource this cost represents", - "type": "string" + "type": "string", + "enum": [ + "late-filing-penalty#late-filing-penalty", + "penalty#sanctions" + ] + }, + "product_type": { + "description": "The product type of the cost.

For enumeration descriptions see product_type section in the enumeration mappings.

", + "type": "string", + "enum": [ + "late-filing-penalty", + "penalty-sanctions" + ] } } } diff --git a/transformers/payable_resource.go b/transformers/payable_resource.go index 82902fe..bc38153 100644 --- a/transformers/payable_resource.go +++ b/transformers/payable_resource.go @@ -20,6 +20,7 @@ func PayableResourceRequestToDB(req *models.PayableRequest) *models.PayableResou Amount: tx.Amount, MadeUpDate: tx.MadeUpDate, Type: tx.Type, + Reason: tx.Reason, } } @@ -85,6 +86,7 @@ func PayableResourceDBToRequest(payableDao *models.PayableResourceDao) *models.P Amount: val.Amount, MadeUpDate: val.MadeUpDate, Type: val.Type, + Reason: val.Reason, } transactions = append(transactions, tx) } diff --git a/version b/version index 2eb3c4f..5a2a580 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.5 +0.6 From 1f2d2f4ed5afdd785fd054dd38877a24ac4ac566 Mon Sep 17 00:00:00 2001 From: Richard Bull Date: Fri, 14 Feb 2025 12:03:54 +0000 Subject: [PATCH 2/2] Fix 3 code smells in assets/penalty_details.yml --- assets/penalty_details.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/penalty_details.yml b/assets/penalty_details.yml index a9df052..2f7ef9a 100644 --- a/assets/penalty_details.yml +++ b/assets/penalty_details.yml @@ -7,8 +7,8 @@ details: ResourceKind: "late-filing-penalty#late-filing-penalty" ProductType: "late-filing-penalty" EmailReceivedAppId: "penalty-payment-api.penalty_payment_received_email" - EmailFilingDesc: "Late filing of accounts" - EmailMsgType: "penalty_payment_received_email" + EmailFilingDesc: "Late filing of accounts" + EmailMsgType: "penalty_payment_received_email" C1: Description: "Sanctions Penalty Payment" DescriptionId: "penalty-sanctions" @@ -16,4 +16,4 @@ details: ProductType: "penalty-sanctions" EmailReceivedAppId: "penalty-payment-api.penalty_payment_received_email" EmailFilingDesc: "Failure to file a confirmation statement" - EmailMsgType: "penalty_payment_received_email" \ No newline at end of file + EmailMsgType: "penalty_payment_received_email"