Skip to content
Amir Iranmanesh edited this page Aug 11, 2026 · 2 revisions

bill

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.BillParams with BillId / PaymentId fields. The type name still works as a deprecated alias; the fields were renamed to BillID / PaymentID, which Go cannot alias.

API

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) // true

Bill types

The 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.

Currency

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}}) // 1700

Clone this wiki locally