fincen

package module
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

Moov Banner Logo

Project Documentation · API Endpoints · API Guide · Community · Blog

GoDoc Build Status Coverage Status Go Report Card Repo Size Apache 2 License Slack Channel Docker Pulls GitHub Stars Twitter

fincen

Moov's mission is to give developers an easy way to create and integrate bank processing into their own software products. Our open source projects are each focused on solving a single responsibility in financial services and designed around performance, scalability, and ease of use.

Moov's fincen project implements a reader, writer, and validator for Fincen BSA forms in an HTTP server and Go library.

Fincen (Financial crimes enforcment network) BSA data transmission methods for the the BSA E-Filing System.

A go library for reading and writing Fincen BSA forms. It is capable of generating, validating, and batching submissions.

The HTTP server is available in a Docker image and the Go package github.com/moov-io/fincen is available.

Table of contents

Project status

The project is Fincen which is a financial reporting for the United States.

There are many forms that are required in this project. Now implemented XML forms only in following link. (Non XML form will implement in another sub project) https://bsaefiling.fincen.treas.gov/FilingInformation.html

The final phase of the project will be a service that collects fillings and then on a scheduled time will batch the fillings and submit them electronically. https://bsaefiling.fincen.treas.gov/docs/SDTMRequirements.pdf

Supported Forms

  • FinCEN Currency Transaction Report (FinCEN Report 112)
  • FinCEN Designation of Exempt Person (FinCEN Report 110)
  • FinCEN Suspicious Activity Report (FinCEN Report 111)
  • Report of Foreign Bank and Financial Accounts (FinCEN Report 114)
  • Report of Cash Payments Over $10,000 Received in a Trade or Business (FinCEN Form 8300)

Usage

The Fincen project implements an HTTP server and Go library for creating and modifying Fincen BSA forms.

Docker

We publish a public Docker image moov/fincen on Docker Hub with every tagged release of Fincen.

Pull & start the Docker image:

docker pull moov/fincen:latest
docker run -p 8206:8206 -p 8207:8207 moov/fincen:latest

Validate a file on the HTTP server:

curl -X POST --data-binary "@./data/samples/ctr_batch.txt" http://localhost:8088/validator
{"status":"valid file"}

Reformat the file with generated attributes:

curl -X POST --data-binary "@./data/samples/ctr_batch.txt" http://localhost:8088/reformat
<EFilingBatchXML ActivityCount="1" TotalAmount="47000" PartyCount="6" SeqNum="1"
                     xsi:schemaLocation="www.fincen.gov/base https://www.fincen.gov/base https://www.fincen.gov/base/EFL_8300XBatchSchema.xsd"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xmlns:fc2="www.fincen.gov/base">
    <Activity SeqNum="1">
...
Google Cloud Run

To get started in a hosted environment you can deploy this project to the Google Cloud Platform.

From your Google Cloud dashboard create a new project and call it:

moov-fincen-demo

Enable the Container Registry API for your project and associate a billing account if needed. Then, open the Cloud Shell terminal and run the following Docker commands, substituting your unique project ID:

docker pull moov/fincen
docker tag moov/fincen gcr.io/<PROJECT-ID>/fincen
docker push gcr.io/<PROJECT-ID>/fincen

Deploy the container to Cloud Run:

gcloud run deploy --image gcr.io/<PROJECT-ID>/fincen --port 8206

Select your target platform to 1, service name to fincen, and region to the one closest to you (enable Google API service if a prompt appears). Upon a successful build you will be given a URL where the API has been deployed:

https://YOUR-FINCEN-APP-URL.a.run.app

Now you can list files stored in-memory:

curl https://YOUR-FINCEN-APP-URL.a.run.app/files

You should get this response:

null
Go library

This project uses Go Modules and Go v1.18 or newer. See Golang's install instructions for help setting up Go. You can download the source code and we offer tagged and released versions as well. We highly recommend you use a tagged release for production.

$ git@github.com:moov-io/fincen.git

$ go get -u github.com/moov-io/fincen

The package github.com/moov-io/fincen offers a Go-based Fincen file reader and writer.

Build report form

Creating XML Batch Reporting form

Fincen project used general XML batch reporting form struct. Available types are "SUBMISSION", "CTRX", "SARX", "DOEPX", "FBARX", "8300X"

// create report with type
newReport := NewReport(fincen.ReportSubmission)

Adding activities by each type

Activity should add into the form struct using sub package

// create activity (ctr)
var newActivity currency_transaction.ActivityType

...
setting newActivity
...

err := newReport.AppendActivity(&newActivity)

Generating new xml attributes

err = newReport.GenerateAttrs()

Validating report form

err = newReport.Validate()
Command Line

The fincen binary on each release can be used on the command line.

Work seamlessly with Fincen BSA form from the command line.

Usage:
  fincen <command> [flags]

Available commands:
  summary: display form summary
  validate: validate financial report form
  reformat: reformat financial report for
In-browser Fincen form parser

Using our in-browser utility, you can instantly verify and reformat Fincen BSA forms.

Learn about Fincen

FAQ

Is there an in-browser tool? Yes! You can find our browser utility at http://oss.moov.io/fincen/.

Getting help

channel info
Project Documentation Our project documentation available online.
Twitter @moov You can follow Moov.io's Twitter feed to get updates on our project(s). You can also tweet us questions or just share blogs or stories.
GitHub Issue If you are able to reproduce a problem please open a GitHub Issue under the specific project that caused the error.
moov-io slack Join our slack channel to have an interactive discussion about the development of the project.

Supported and tested platforms

  • 64-bit Linux (Ubuntu, Debian), macOS, and Windows

Note: 32-bit platforms have known issues and are not supported.

Contributing

Yes please! Please review our Contributing guide and Code of Conduct to get started!

This project uses Go Modules and Go v1.18 or newer. See Golang's install instructions for help setting up Go. You can download the source code and we offer tagged and released versions as well. We highly recommend you use a tagged release for production.

License

Apache License 2.0 - See LICENSE for details.

Documentation

Index

Constants

View Source
const (
	IndicateLegalName     = "L"
	IndicateDoingBusiness = "DBA"
	IndicateKnownAs       = "AKA"
)
View Source
const (
	ReportSubmission = "SUBMISSION"
	Report112        = "CTRX"
	Report111        = "SARX"
	Report110        = "DOEPX"
	Report114        = "FBARX"
	Form8300         = "8300X"
	NameSpace        = "fc2"
)
View Source
const Version = "v0.3.6"

Variables

View Source
var (
	DefaultXMLIntent        = "  "
	DefaultValidateFunction = "Validate"
	SequenceFieldName       = "SeqNum"
)

Functions

func CheckInvolved

func CheckInvolved(element string, elements ...string) bool

func GenerateSeqNumbers added in v0.2.0

func GenerateSeqNumbers(r interface{}, seqNumber *SeqNumber) error

GenerateSeqNumbers generate unique sequence numbers

func Marshal added in v0.2.7

func Marshal(v any) ([]byte, error)

Marshal will return an error if asked to marshal a channel, function, or map.

func MarshalIndent added in v0.2.7

func MarshalIndent(v any, prefix, indent string) ([]byte, error)

MarshalIndent works like Marshal, but each XML element begins on a new indented line that starts with prefix and is followed by one or more copies of indent according to the nesting depth.

func NewErrFieldRequired

func NewErrFieldRequired(typeStr string) error

NewErrFieldRequired returns an error when a field is required

func NewErrFiledOmitted

func NewErrFiledOmitted(typeStr string) error

NewErrFiledOmitted returns an error that the field should be omitted

func NewErrMinMaxRange

func NewErrMinMaxRange(typeStr string) error

NewErrMinMaxRange returns an error that the field has min/max element range

func NewErrValueInvalid

func NewErrValueInvalid(typeStr string) error

NewErrTextLength returns an error that the length of value is invalid

func NumericStringField

func NumericStringField(s string, max uint) string

NumericStringField return number string with filling zero

func Ptr added in v0.2.7

func Ptr[T any](t T) *T

func Validate

func Validate(r interface{}, args ...string) error

Validate is trying to run Validate(...string) function of fields

func ValidateDateText

func ValidateDateText(str string) bool

ValidateDateText check input string is date string (YYYYMMDD)

func ValidateNumericCharacters

func ValidateNumericCharacters(str string, min, max int) bool

ValidateNumericCharacters check input string is numeric characters

func ValidateSeqNumbers added in v0.2.5

func ValidateSeqNumbers(r interface{}) (map[SeqNumber]bool, error)

ValidateSeqNumbers verify unique sequence numbers

Types

type DateYYYYMMDDOrBlankType

type DateYYYYMMDDOrBlankType string

Must match the pattern (19|20)[0-9][0-9](0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[01])|

func (DateYYYYMMDDOrBlankType) Validate

func (r DateYYYYMMDDOrBlankType) Validate() error

type DateYYYYMMDDOrBlankTypeDOB

type DateYYYYMMDDOrBlankTypeDOB string

Must match the pattern (19|20)[0-9][0-9](0[0-9]|1[0-2])(0[0-9]|1[0-9]|2[0-9]|3[01])|

func (DateYYYYMMDDOrBlankTypeDOB) Validate

func (r DateYYYYMMDDOrBlankTypeDOB) Validate() error

type DateYYYYMMDDType

type DateYYYYMMDDType string

Must match the pattern (19|20)[0-9][0-9](0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[01])

func (DateYYYYMMDDType) Validate

func (r DateYYYYMMDDType) Validate() error

type DateYYYYType

type DateYYYYType string

Must match the pattern (19|20)[0-9][0-9]

func (DateYYYYType) Validate

func (r DateYYYYType) Validate() error

type Element

type Element interface {
	Validate(args ...string) error
}

Element defines interface of complex xml elements args:

1: ActivityPartyTypeCode
2: FilerTypeIndividualIndicator (true/false)
1: disableValidateAttrs (EFilingBatchXML only)

type ElementActivity

type ElementActivity interface {
	Validate(args ...string) error
	FormTypeCode() string
	TotalAmount() float64
	PartyCount(args ...string) int64
}

Element defines interface of complex xml elements

type RestrictNumeric14

type RestrictNumeric14 string

func (RestrictNumeric14) Validate

func (r RestrictNumeric14) Validate() error

type RestrictString100

type RestrictString100 string

Must match the pattern \S+( +\S+)*|

func (RestrictString100) Validate

func (r RestrictString100) Validate() error

type RestrictString15

type RestrictString15 string

Must match the pattern \S+( +\S+)*|

func (RestrictString15) Validate

func (r RestrictString15) Validate() error

type RestrictString150

type RestrictString150 string

Must match the pattern \S+( +\S+)*|

func (RestrictString150) Validate

func (r RestrictString150) Validate() error

type RestrictString16

type RestrictString16 string

Must match the pattern \S+( +\S+)*|

func (RestrictString16) Validate

func (r RestrictString16) Validate() error

type RestrictString2

type RestrictString2 string

Must match the pattern \S+( +\S+)*|

func (RestrictString2) Validate

func (r RestrictString2) Validate() error

type RestrictString20

type RestrictString20 string

Must match the pattern \S+( +\S+)*|

func (RestrictString20) Validate

func (r RestrictString20) Validate() error

type RestrictString25

type RestrictString25 string

Must match the pattern \S+( +\S+)*|

func (RestrictString25) Validate

func (r RestrictString25) Validate() error

type RestrictString3

type RestrictString3 string

Must match the pattern \S+( +\S+)*|

func (RestrictString3) Validate

func (r RestrictString3) Validate() error

type RestrictString30

type RestrictString30 string

Must match the pattern \S+( +\S+)*|

func (RestrictString30) Validate

func (r RestrictString30) Validate() error

type RestrictString35

type RestrictString35 string

Must match the pattern \S+( +\S+)*|

func (RestrictString35) Validate

func (r RestrictString35) Validate() error

type RestrictString39

type RestrictString39 string

Must match the pattern \S+( +\S+)*|

func (RestrictString39) Validate

func (r RestrictString39) Validate() error

type RestrictString4

type RestrictString4 string

Must match the pattern \S+( +\S+)*|

func (RestrictString4) Validate

func (r RestrictString4) Validate() error

type RestrictString40

type RestrictString40 string

Must match the pattern \S+( +\S+)*|

func (RestrictString40) Validate

func (r RestrictString40) Validate() error

type RestrictString4000

type RestrictString4000 string

May be no more than 4000 items long

func (RestrictString4000) Validate

func (r RestrictString4000) Validate() error

type RestrictString50

type RestrictString50 string

Must match the pattern \S+( +\S+)*|

func (RestrictString50) Validate

func (r RestrictString50) Validate() error

type RestrictString512

type RestrictString512 string

Must match the pattern \S+( +\S+)*|

func (RestrictString512) Validate

func (r RestrictString512) Validate() error

type RestrictString517

type RestrictString517 string

Must match the pattern \S+( +\S+)*|

func (RestrictString517) Validate

func (r RestrictString517) Validate() error

type RestrictString525

type RestrictString525 string

Must match the pattern \S+( +\S+)*|

func (RestrictString525) Validate

func (r RestrictString525) Validate() error

type RestrictString6

type RestrictString6 string

Must match the pattern \S+( +\S+)*|

func (RestrictString6) Validate

func (r RestrictString6) Validate() error

type RestrictString750

type RestrictString750 string

Must match the pattern \S+( +\S+)*|

func (RestrictString750) Validate

func (r RestrictString750) Validate() error

type RestrictString9

type RestrictString9 string

Must match the pattern \S+( +\S+)*|

func (RestrictString9) Validate

func (r RestrictString9) Validate() error

type SeqNumber

type SeqNumber int64

May be one of C, D, E, F

func (SeqNumber) Validate

func (r SeqNumber) Validate() error

type ValidateAccountTypeCodeType

type ValidateAccountTypeCodeType string

May be one of 1, 2, 999

func (ValidateAccountTypeCodeType) Validate

func (r ValidateAccountTypeCodeType) Validate() error

type ValidateAssetAttributeTypeIDTypeCode

type ValidateAssetAttributeTypeIDTypeCode int64

May be one of 1, 2, 3, 4

func (ValidateAssetAttributeTypeIDTypeCode) Validate

type ValidateAssetSubtypeIDTypeCode

type ValidateAssetSubtypeIDTypeCode int64

May be one of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 46, 47

func (ValidateAssetSubtypeIDTypeCode) Validate

type ValidateAssetTypeIDTypeCode

type ValidateAssetTypeIDTypeCode int64

May be one of 5, 6

func (ValidateAssetTypeIDTypeCode) Validate

func (r ValidateAssetTypeIDTypeCode) Validate() error

type ValidateCyberEventIndicatorsTypeCode

type ValidateCyberEventIndicatorsTypeCode string

May be one of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 999

func (ValidateCyberEventIndicatorsTypeCode) Validate

type ValidateEFilingAccountTypeCodeType

type ValidateEFilingAccountTypeCodeType string

May be one of 141, 142, 143, 144

func (ValidateEFilingAccountTypeCodeType) Validate

type ValidateElectronicAddressTypeCode

type ValidateElectronicAddressTypeCode string

May be one of E, U

func (ValidateElectronicAddressTypeCode) Validate

type ValidateExemptBasisTypeCode

type ValidateExemptBasisTypeCode string

May be one of C, D, E, F

func (ValidateExemptBasisTypeCode) Validate

func (r ValidateExemptBasisTypeCode) Validate() error

type ValidateIndicatorNullType added in v0.3.2

type ValidateIndicatorNullType string

May be one of Y

func (ValidateIndicatorNullType) Validate added in v0.3.2

func (r ValidateIndicatorNullType) Validate() error

type ValidateIndicatorType

type ValidateIndicatorType string

May be one of Y,

func (ValidateIndicatorType) Validate

func (r ValidateIndicatorType) Validate() error

type ValidateInstrumentProductServiceTypeCode

type ValidateInstrumentProductServiceTypeCode int

May be one of 35, 16, 39, 26, 40, 34

func (ValidateInstrumentProductServiceTypeCode) Validate

type ValidateLateFilingReasonCodeType

type ValidateLateFilingReasonCodeType string

May be one of 1, 2, 3, 4, 5, 6, 7, 8, 9, 999

func (ValidateLateFilingReasonCodeType) Validate

type ValidateOrganizationCodeType

type ValidateOrganizationCodeType int

May be one of 1, 2, 3, 4, 5, 11, 12, 999

func (ValidateOrganizationCodeType) Validate

func (r ValidateOrganizationCodeType) Validate() error

type ValidateOrganizationSubtypeCodeCtrType

type ValidateOrganizationSubtypeCodeCtrType int

May be one of 101, 102, 103, 1999

func (ValidateOrganizationSubtypeCodeCtrType) Validate

type ValidateOrganizationSubtypeCodeSarType

type ValidateOrganizationSubtypeCodeSarType int

May be one of 101, 102, 103, 503, 504, 508, 513, 514, 535, 528, 529, 533, 534, 539, 540, 541, 542, 1999, 5999

func (ValidateOrganizationSubtypeCodeSarType) Validate

type ValidatePartyTypeCode

type ValidatePartyTypeCode string

May be one of I, O, U

func (ValidatePartyTypeCode) Validate

func (r ValidatePartyTypeCode) Validate() error

type ValidatePhoneNumberCodeType

type ValidatePhoneNumberCodeType string

May be one of F, M, R, W

func (ValidatePhoneNumberCodeType) Validate

func (r ValidatePhoneNumberCodeType) Validate() error

type ValidateSuspiciousActivitySubtypeID

type ValidateSuspiciousActivitySubtypeID int

May be one of 106, 111, 112, 113, 114, 301, 304, 305, 308, 309, 310, 312, 320, 321, 322, 323, 324, 325, 401, 402, 403, 404, 405, 409, 501, 502, 504, 505, 506, 507, 601, 603, 604, 608, 609, 701, 801, 804, 805, 806, 807, 808, 809, 812, 820, 821, 822, 823, 824, 901, 903, 904, 905, 907, 908, 909, 910, 911, 913, 917, 920, 921, 922, 924, 925, 926, 927, 928, 1001, 1003, 1005, 1006, 1007, 1101, 1102, 1201, 1202, 1203, 1204, 1999, 3999, 4999, 5999, 6999, 7999, 8999, 9999, 10999, 11999, 12999

func (ValidateSuspiciousActivitySubtypeID) Validate

type ValidateSuspiciousActivityTypeID

type ValidateSuspiciousActivityTypeID int

May be one of 1, 12, 3, 4, 5, 6, 7, 8, 9, 10, 11

func (ValidateSuspiciousActivityTypeID) Validate

type ValidateTimeDataOrBlankType

type ValidateTimeDataOrBlankType string

Must match the pattern ([0-1][0-9]|(2[0-3])):[0-5][0-9]:[0-5][0-9]|

func (ValidateTimeDataOrBlankType) Validate

func (r ValidateTimeDataOrBlankType) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL