forked from persian-tools/go-persian-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
bill
Amir Iranmanesh edited this page Aug 11, 2026
·
2 revisions
Parse and validate Iranian utility bills.
import "github.com/amiranmanesh/go-persian-tools/bill"
params := bill.Params{BillID: 1117753200140, PaymentID: 12070160}In v1.0.x this type was
bill.BillParamswithBillId/PaymentIdfields. The type name still works as a deprecated alias; the fields were renamed toBillID/PaymentID, which Go cannot alias.
| Function | Returns | Example |
|---|---|---|
GetBillType(params) |
string |
تلفن ثابت |
GetCurrency(params) |
int |
120000 |
GetBarCode(params) |
string |
111775320014000012070160 |
VerifyBillID(params) |
bool |
true |
bill.GetBillType(params) // تلفن ثابت
bill.GetCurrency(params) // 120000
bill.GetBarCode(params) // 111775320014000012070160
bill.VerifyBillID(params) // trueThe second-to-last digit of the bill id selects the service:
| Digit | Type |
|---|---|
| 1 | آب |
| 2 | برق |
| 3 | گاز |
| 4 | تلفن ثابت |
| 5 | تلفن همراه |
| 6 | عوارض شهرداری |
| 8 | سازمان مالیات |
| 9 | جرایم راهنمایی و رانندگی |
Anything else returns "unknown", and VerifyBillID treats an unknown type as
invalid even when the control digit checks out.
GetCurrency scales the payment id. An unset Currency, or one with
Rial: true, uses the 1000 multiplier; Toman: true uses 100.
bill.GetCurrency(bill.Params{BillID: ..., PaymentID: 1770160}) // 17000
bill.GetCurrency(bill.Params{BillID: ..., PaymentID: 1770160, Currency: bill.Currency{Toman: true}}) // 1700Packages
Project