{"id":18327215,"url":"https://github.com/dalikewara/cmtxgo","last_synced_at":"2025-07-10T09:38:58.835Z","repository":{"id":64307514,"uuid":"447948747","full_name":"dalikewara/cmtxgo","owner":"dalikewara","description":"cmtxgo generates cemtext format in Golang. Cemtext file format is a format used by banks to allow for batch transactions","archived":false,"fork":false,"pushed_at":"2022-09-13T07:40:41.000Z","size":162,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T16:54:21.315Z","etag":null,"topics":["banks","cemtex","cmtxgo","golang","helper","package","tool","toolkit"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dalikewara.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"dalikewara","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-01-14T11:46:33.000Z","updated_at":"2024-01-26T12:19:38.000Z","dependencies_parsed_at":"2023-01-15T11:00:42.340Z","dependency_job_id":null,"html_url":"https://github.com/dalikewara/cmtxgo","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dalikewara/cmtxgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fcmtxgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fcmtxgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fcmtxgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fcmtxgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalikewara","download_url":"https://codeload.github.com/dalikewara/cmtxgo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalikewara%2Fcmtxgo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264559720,"owners_count":23628040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["banks","cemtex","cmtxgo","golang","helper","package","tool","toolkit"],"created_at":"2024-11-05T19:09:58.114Z","updated_at":"2025-07-10T09:38:58.814Z","avatar_url":"https://github.com/dalikewara.png","language":"Go","funding_links":["https://github.com/sponsors/dalikewara"],"categories":[],"sub_categories":[],"readme":"# cmtxgo\n\n[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/github.com/dalikewara/cmtxgo)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/dalikewara/cmtxgo)\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/dalikewara/cmtxgo)\n![GitHub license](https://img.shields.io/github/license/dalikewara/cmtxgo)\n\n**cmtxgo** generates cemtext format in Golang. Cemtext file format is a format used by banks to allow for batch\ntransactions. Banks adopted this format by default, but they may have different format style. This package allows you to\ncreate a cemtext format by your own style—that means you can use it to meet your bank cemtext requirements.\n\n\u003e If you're working with JavaScript, you can use this module instead -\u003e [https://github.com/dalikewara/vcmcemtex](https://github.com/dalikewara/vcmcemtex)\n\n## Getting started\n\n### Installation\n\nYou can use the `go install` method:\n\n```bash\ngo install github.com/dalikewara/cmtxgo@latest\n```\n\nor, you can also use the `go get` method (DEPRECATED since `go1.17`):\n\n```bash\ngo get github.com/dalikewara/cmtxgo\n```\n\n### Usage\n\nA cemtext format commonly has 3 sections: `header`, `detail` and `footer`.\n\n```text\n(header) 0                 01BQL       MY NAME                   1111111004231633  230410\n(detail) 1123-456157108231 530000001234S R SMITH                       TEST BATCH        062-000 12223123MY ACCOUNT      00001200\n(detail) 1123-783 12312312 530000002200J K MATTHEWS                    TEST BATCH        062-000 12223123MY ACCOUNT      00000030\n(detail) 1456-789   125123 530003123513P R JONES                       TEST BATCH        062-000 12223123MY ACCOUNT      00000000\n(detail) 1121-232    11422 530000002300S MASLIN                        TEST BATCH        062-000 12223123MY ACCOUNT      00000000\n(footer) 7999-999            000312924700031292470000000000                        000004\n```\n\nEvery section detailed information about the transaction, and they can be separated by new line `\\n` or just combined to\na single string. Both is valid, because it depends on the bank specification\u0026mdash;some Indonesian bank uses single\nstring format, for example:\n\n```text\n0                 01BQL       MY NAME                   1111111004231633  2304101123-456157108231 530000001234S R SMITH                       TEST BATCH        062-000 12223123MY ACCOUNT      000012001123-783 12312312 530000002200J K MATTHEWS                    TEST BATCH        062-000 12223123MY ACCOUNT      000000301456-789   125123 530003123513P R JONES                       TEST BATCH        062-000 12223123MY ACCOUNT      000000001121-232    11422 530000002300S MASLIN                        TEST BATCH        062-000 12223123MY ACCOUNT      000000007999-999            000312924700031292470000000000                        000004\n```\n\n\u003e Ref: [https://www.cemtexaba.com/aba-format](https://www.cemtexaba.com/aba-format)\n\nThis is the very basic usage of this package:\n\n```go\ncmtx := cmtxgo.NewCmtx()\n\n// Set header\ncmtx.SetHeader(\u0026cmtxgo.Field{\n    \"myHeaderFieldName\": \u0026cmtxgo.Attribute{\n        Order:  1,\n        Type:   \"lpz\",\n        Length: 11,\n        Value:  \"999\",\n    },\n    \"myHeaderFieldName2\": \u0026cmtxgo.Attribute{\n        Order:  2,\n        Type:   \"rps\",\n        Length: 35,\n        Value:  \"My COMPANY\",\n    },\n})\n\n// Set detail\ndetailData := []map[string]interface{}{\n    {\n        \"myDetailFieldName\":  \"123-456-789\",\n        \"myDetailFieldName2\": \"John Doe\",\n        \"myDetailFieldName3\": \"1000000\",\n    },\n    {\n        \"myDetailFieldName\":  \"098-765-432\",\n        \"myDetailFieldName2\": \"Adam Smith\",\n        \"myDetailFieldName3\": \"1005500\",\n    },\n    {\n        \"myDetailFieldName\":  \"123-098-456\",\n        \"myDetailFieldName2\": \"Dali Kewara\",\n        \"myDetailFieldName3\": \"204000\",\n    },\n}\ncmtx.SetDetail(\u0026cmtxgo.Field{\n    \"myDetailFieldName\": \u0026cmtxgo.Attribute{\n        Order:  1,\n        Type:   \"rps\",\n        Length: 15,\n    },\n    \"myDetailFieldName2\": \u0026cmtxgo.Attribute{\n        Order:  2,\n        Type:   \"rps\",\n        Length: 20,\n    },\n    \"myDetailFieldName3\": \u0026cmtxgo.Attribute{\n        Order:  3,\n        Type:   \"lpz\",\n        Length: 11,\n    },\n}, \u0026detailData)\n\n// Set footer\ncmtx.SetFooter(\u0026cmtxgo.Field{\n    \"myFooterFieldName\": \u0026cmtxgo.Attribute{\n        Order:  1,\n        Type:   \"lpz\",\n        Length: 11,\n        Value:  fmt.Sprintf(\"%v\", len(detailData)),\n    },\n    \"myFooterFieldName2\": \u0026cmtxgo.Attribute{\n        Order:  2,\n        Type:   \"lpz\",\n        Length: 35,\n        Value:  \"2209500\",\n    },\n})\n\n// Generate the cemtext format as string\ncmtxStr := cmtx.Generate()\n```\n\nThe output is:\n\n```text\n00000000999My COMPANY                         123-456-789    John Doe            00001000000098-765-432    Adam Smith          00001005500123-098-456    Dali Kewara         000002040000000000000300000000000000000000000000002209500\n```\n\nIf you want to save the cemtext format into a file, just use `GenerateToFile` method instead:\n\n```go\nerr := cmtx.GenerateToFile(\"/path/to/filename.ctx\")\nif err != nil {\n    panic(err)\n}\n```\n\n### Attribute\n\n- `Order`: sorts the generation of the fields. Example:\n\n```go\ncmtx.SetHeader(\u0026cmtxgo.Field{\n    \"first\": \u0026cmtxgo.Attribute{\n        Order:  2,\n        Type:   \"lps\",\n        Length: 6,\n        Value:  \"Second\",\n    },\n    \"second\": \u0026cmtxgo.Attribute{\n        Order:  1,\n        Type:   \"lps\",\n        Length: 5,\n        Value:  \"First\",\n    },\n})\n// Output: \"FirstSecond\"\n```\n\n- `Type`: formats the field value based on padding type. Available padding type: `lps`, `lpz`, `rps`, `rpz`. \nDefault is `rps`.\n  - `lps`: Left Padding Space (ex: \"  john doe\")\n  - `lpz`: Left Padding Zero (ex: \"0000000123\")\n  - `rps`: Right Padding Space (ex: \"john doe   \")\n  - `rpz`: Right Padding Zero (ex: \"1230000000\")\n- `Length`: sets max length to the field value.\n- `Value`: sets field value. This only effect on `header` \u0026 `footer` section.\nFor `detail` section, the field value got from the matched field name in detail data.\nIf Value is empty, DefaultValue will be used.\n- `DefaultValue`: sets the default value to the field if the Value is empty. Default is \"\".\n- `RemoveAllChars`: removes specified characters from the field value. Example:\n\n```go\ncmtx.SetFooter(\u0026cmtxgo.Field{\n    \"total_amount\": \u0026cmtxgo.Attribute{\n        Order:          1,\n        Type:           \"lpz\",\n        Length:         10,\n        Value:          \"1.000.000.000\",\n        RemoveAllChars: \".\",\n    },\n})\n// Output: \"1000000000\"\n```\n\n- `ReplaceAllChars`: ReplaceAllChars replaces specified characters with the new one from the field value. Example:\n\n```go\ncmtx.SetFooter(\u0026cmtxgo.Field{\n    \"total_amount\": \u0026cmtxgo.Attribute{\n        Order:           1,\n        Type:            \"lpz\",\n        Length:          13,\n        Value:           \"1.000.000.000\",\n        ReplaceAllChars: [2]string{\".\", \",\"},\n    },\n})\n// Output: \"1,000,000,000\"\n```\n\n### Option\n\n- `MaxLengthPerSection`: sets max length on every section value.\n- `AddCharPerSection`: adds specified character at the end of the value on every section. Keep in mind that this will add \nnew character, so it will break the value length setting.\n\n## Release\n\n### Changelog\n\nRead at [CHANGELOG.md](https://github.com/dalikewara/cmtxgo/blob/master/CHANGELOG.md)\n\n### Credits\n\nCopyright \u0026copy; 2022 [Dali Kewara](https://www.dalikewara.com)\n\n### License\n\n[MIT License](https://github.com/dalikewara/cmtxgo/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalikewara%2Fcmtxgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalikewara%2Fcmtxgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalikewara%2Fcmtxgo/lists"}