Skip to content
moov-ioPublic

About

Fincen BSA E-Filing forms

Topics

Resources

Contributing

Security policy

Stars

38 stars

Watchers

6 watching

Forks

Latest commit

 

History

329 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moov Banner Logo

Project Documentation · API Endpoints · Community · Blog

GoDoc Build Status Coverage Status Go Report Card Repo Size Apache 2 License 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 Enforcement Network) BSA data transmission methods for 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.gov/filing-information

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.gov/SDTM

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

The HTTP server listens on :8206. The admin server (health probes and metrics) listens on :8207. The /validator and /reformat endpoints accept multipart/form-data with a file field named input.

Validate a file on the HTTP server:

curl -F "input=@./data/samples/ctr_batch.xml" http://localhost:8206/validator
{"status":"valid file"}

The same command works with the sar_batch.xml, doep_batch.xml, fbar_batch.xml, and 8300_batch.xml samples.

Reformat the file with generated attributes. Attributes are regenerated only when you send generate_attrs=true. You can also send format=json for JSON output. /validator accepts disable_attrs=true to skip attribute checks.

Send xsd=true to /validator to also validate the file against the official FinCEN batch schema for its form type. The schema files are bundled with the server, so this check does not use the network. Schema validation is off by default. It applies to XML batch files only, not to JSON files or acknowledgement files.

curl -F "input=@./data/samples/ctr_batch.xml" -F "xsd=true" http://localhost:8206/validator
{"status":"valid file"}

When the file does not pass schema validation, the response has an xsd_errors list:

{"error":"official schema validation failed: line 2: /fc2:EFilingBatchXML: required attribute PartyCount is missing","xsd_errors":[{"line":2,"path":"/fc2:EFilingBatchXML","message":"required attribute PartyCount is missing"}]}

A valid file response, with or without xsd=true, does not mean that FinCEN will accept the file. The BSA E-Filing System also applies business rules that this server does not check.

curl -F "input=@./data/samples/ctr_batch.xml" -F "generate_attrs=true" http://localhost:8206/reformat
<fc2:EFilingBatchXML TotalAmount="47000" PartyCount="6" ActivityCount="1" xsi:schemaLocation="www.fincen.gov/base https://www.fincen.gov/system/files/schema/base/EFL_CTRXBatchSchema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fc2="www.fincen.gov/base">
  <fc2:FormTypeCode>CTRX</fc2:FormTypeCode>
  <fc2:Activity SeqNum="1">
    ...

The /validator and /reformat endpoints return these HTTP status codes:

Status Meaning
200 The file is valid (/validator), or the reformatted report is in the response body (/reformat).
400 The request is not multipart/form-data, the input field is missing, or the file is not an XML or JSON batch report. With xsd=true, the file is a JSON file or an acknowledgement file.
422 The file was read, but it does not pass validation. The error field shows the problem, for example {"error":"The TotalAmount has invalid value"}. With xsd=true, the xsd_errors field shows each schema error.

Version v0.4.0 and earlier returned 501 for files that could not be read and for files that did not pass validation.

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 check that the service is running:

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

You should get this response:

PONG

The HTTP API provides /ping, /validator, and /reformat. There is no /files endpoint.

Go library

This project uses Go Modules and Go 1.26 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 once a release is cut from current master. The GitHub release marked Latest is older than master, and go get may resolve v0.3.6, which is not on the current master branch.

git clone https://github.com/moov-io/fincen.git

go get github.com/moov-io/fincen

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

Build report form

Create a batch with batch.NewReport and a form constant:

Constant Form type
fincen.Report112 CTRX (Currency Transaction Report)
fincen.Report111 SARX (Suspicious Activity Report)
fincen.Report110 DOEPX (Designation of Exempt Person)
fincen.Report114 FBARX (Foreign Bank and Financial Accounts)
fincen.Form8300 8300X (Cash Payments Over $10,000)
fincen.ReportSubmission SUBMISSION (acknowledgement)

Generate attributes, then generate sequence numbers, then validate. Validate() fails when counts are stale. Validate() checks the library's field and attribute rules only. It does not validate a document against the official FinCEN XSD files in data/xsd. A successful Validate() result (or an HTTP /validator response of valid file) does not mean that FinCEN would accept the file.

To also validate an XML batch file against the official FinCEN batch schema for its form type, use the optional package github.com/moov-io/fincen/pkg/schema. The schema files are bundled with the module, so this check does not use the network. A file that passes both checks can still be rejected by FinCEN, because the BSA E-Filing System also applies business rules.

if err := schema.Validate(xmlBytes); err != nil {
    // err is a schema.Errors value with one schema.Issue (line, path, message) for each problem.
    log.Fatal(err)
}

A complete CTR example is in examples/currency_transaction_write. Run examples from the repository root:

go run ./examples/currency_transaction_write
go run ./examples/currency_transaction_read
package main

import (
    "encoding/xml"
    "fmt"
    "log"

    "github.com/moov-io/fincen"
    "github.com/moov-io/fincen/pkg/batch"
    "github.com/moov-io/fincen/pkg/currency_transaction"
)

func main() {
    report := batch.NewReport(fincen.Report112)
    activity := currency_transaction.NewActivity()
    // Fill activity fields. See examples/currency_transaction_write for a complete CTR.

    if err := report.AppendActivity(activity); err != nil {
        log.Fatal(err)
    }
    if err := report.GenerateAttrs(); err != nil {
        log.Fatal(err)
    }
    if err := report.GenerateSeqNumbers(); err != nil {
        log.Fatal(err)
    }
    if err := report.Validate(); err != nil {
        log.Fatal(err)
    }

    out, err := xml.MarshalIndent(report, "", "  ")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(string(out))
}

Command Line

The fincen-<os>-amd64 asset on each release is the HTTP server, not the CLI. The command-line tool lives in cmd/fincen. Build it from this repository, or install it with Go from current master until a new tagged release includes the CLI:

go install github.com/moov-io/fincen/cmd/fincen@master

# or, from a clone of this repository:
go build -o bin/fincen ./cmd/fincen
Work seamlessly with Fincen BSA forms from the command line.

Usage:
  fincen <command> [flags]

Available commands:
  summary: display form summary
  validate: validate financial report form
  reformat: reformat financial report form

Validate flags:
  -xsd
        also validate an XML batch file against the official FinCEN batch schema

Reformat flags:
  -generate-attrs
        regenerate batch attributes
  -format string
        output format, xml or json (default "xml")
./bin/fincen validate data/samples/ctr_batch.xml
./bin/fincen validate -xsd data/samples/ctr_batch.xml
./bin/fincen reformat -generate-attrs data/samples/ctr_batch.xml

In-browser Fincen form parser

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

Learn about Fincen

FinCEN XML Schema 2.0 documents

The library follows the FinCEN XML Schema 2.0 user guides (August 2021):

Other FinCEN documents for batch filers:

The official batch schemas are at https://www.fincen.gov/system/files/schema/base/: CTR, DOEP, SAR, FBAR, and 8300.

FAQ

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

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 to get started!

This project uses Go Modules and Go 1.26 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 once a release is cut from current master.

License

Apache License 2.0 - See LICENSE for details.

About

Fincen BSA E-Filing forms

Topics

Resources

Contributing

Security policy

Stars

38 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages