|
| 1 | +// Licensed to The Moov Authors under one or more contributor |
| 2 | +// license agreements. See the NOTICE file distributed with |
| 3 | +// this work for additional information regarding copyright |
| 4 | +// ownership. The Moov Authors licenses this file to you under |
| 5 | +// the Apache License, Version 2.0 (the "License"); you may |
| 6 | +// not use this file except in compliance with the License. |
| 7 | +// You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package issues |
| 19 | + |
| 20 | +import ( |
| 21 | + "testing" |
| 22 | + "time" |
| 23 | + |
| 24 | + "github.com/moov-io/ach" |
| 25 | + |
| 26 | + "github.com/stretchr/testify/require" |
| 27 | +) |
| 28 | + |
| 29 | +func TestIssue1168(t *testing.T) { |
| 30 | + // Batch Header |
| 31 | + bh := ach.NewBatchHeader() |
| 32 | + bh.ServiceClassCode = 200 |
| 33 | + bh.CompanyName = "COMPANY" |
| 34 | + bh.CompanyIdentification = "IDENTIFICATION" |
| 35 | + bh.StandardEntryClassCode = ach.WEB |
| 36 | + bh.CompanyEntryDescription = "DESCRIPTION" |
| 37 | + bh.CompanyDescriptiveDate = time.Now().Format("060102") |
| 38 | + bh.EffectiveEntryDate = time.Now().Add(time.Hour * 24).Format("060102") |
| 39 | + bh.ODFIIdentification = "1" |
| 40 | + |
| 41 | + ed := &ach.EntryDetail{ |
| 42 | + TransactionCode: ach.SavingsCredit, |
| 43 | + DFIAccountNumber: "54321", |
| 44 | + RDFIIdentification: "12345678", |
| 45 | + CheckDigit: "0", |
| 46 | + Amount: 0, |
| 47 | + IndividualName: "Jane Doe", |
| 48 | + TraceNumber: "445566778899", |
| 49 | + } |
| 50 | + |
| 51 | + b1 := ach.NewBatchWEB(bh) |
| 52 | + b1.AddEntry(ed) |
| 53 | + |
| 54 | + // Require that Batches cannot have zero amounts |
| 55 | + require.ErrorContains(t, b1.Create(), ach.ErrBatchAmountZero.Error()) |
| 56 | + |
| 57 | + ed.TransactionCode = ach.SavingsPrenoteCredit |
| 58 | + require.NoError(t, b1.Create()) |
| 59 | +} |
0 commit comments