Follow us on...
Follow us on G+ Follow us on Twitter Follow us on Facebook Watch us on YouTube
Register
Results 1 to 10 of 10
  1. Status
    Offline
    Forum Guru Array
    Join Date
    Jan 2008
    Posts
    1,727
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    1 (100%)

    Jump to Comments

    Mikrotik Automated Billing

    9 Comments by dencow Published on 30-04-2009 11:55
    Nemu di wikinya mikrotik nih ( dan scriptnya di )
    belom coba implementasi sih.... soalnya diriku saat ini ga pake user manager Click here to enlarge

    Oke.. dimulai aja kali ya... coba terjemahin, coba implementasinya ya ntar aja deh kalau punya stock barang ekstra...


    Billing ostomastis ini menggunakan script dan fungsinya adalah melakukan penagihan ke klien setiap akhir bulan secara ostomastis Click here to enlarge

    Syarat untuk dapat menggunakan fitur ini adalah pengguna mikrotik versi 3.0rc5 keatas dan menggunakan user manager serta ada sumber daya perangkat yang memadai disamping pengertian mengenai scripting.

    Oh ya, syarat yang lain adalah harus memiliki akses ke server SMTP Click here to enlarge

    Juga format di user manager harus punya field berikut ini (cek di "/tool user-manager user print" tanpa tanda kutip)

    First Name
    Last Name
    E-mail Address
    Pool Name
    Comment Field
    Nah ini dia contoh script lengkapnya...

    Code:
     :local uptime
     :local count
     :local usrname
     :local clientname
     :local clientsurname
     :local poolname
     :local accounttype
     :local discount
     :local amount
     :local discountedamount
     :local discountcheck
     :local date
     :local invoice
     :local nextinvoicenumber
     :local bytesin
     :local bytesout
     :local bytestotal
     :local gigstotal
     :local email
     :local basecharge
     :local usagecharge
     :local total
     :local disabled
     :local doespay
     :local server
     :local newcomment
     :local comment
     :local cap
     :local warning
     :local lastinvoicemonth
     :local month
     :local monthnum
     :local newmonthnum
     :local lastmonth
     
     :set server [:resolve smtp.yourserver.com]
     
     :set month [:pick [/system clock get date] 0 3]
     
     :if ([$month] = jan) do={ :set newmonthnum 01 }
     :if ([$month] = feb) do={ :set newmonthnum 02 }
     :if ([$month] = mar) do={ :set newmonthnum 03 }
     :if ([$month] = apr) do={ :set newmonthnum 04 }
     :if ([$month] = may) do={ :set newmonthnum 05 }
     :if ([$month] = jun) do={ :set newmonthnum 06 }
     :if ([$month] = jul) do={ :set newmonthnum 07 }
     :if ([$month] = aug) do={ :set newmonthnum 08 }
     :if ([$month] = sep) do={ :set newmonthnum 09 }
     :if ([$month] = oct) do={ :set newmonthnum 10 }
     :if ([$month] = nov) do={ :set newmonthnum 11 }
     :if ([$month] = dec) do={ :set newmonthnum 12 }
     
     # Loop through all the users in User Manager - My only  Subscriber is Admin
     /tool user-manager user
     :foreach i in=[ /tool user-manager user find subscriber=admin ] do={
    
     #Pull out all the information I need 
     
     :set disabled [get $i disabled]
     
     :if ([$disabled] = false) do={
     #pull some data from it, and print it on screen
     :set date [/system clock get date]
     :set usrname [get $i name]
     :set uptime [get $i uptime-used]
     :set clientname [get $i first-name]
     :set clientsurname [get $i last-name]
     :set poolname [get $i pool-name]
     :set discountcheck [get $i discount]
     :set comment [get $i comment]
     :set invoice [:pick $comment 0 5] 
     :set cap [:pick $comment 5 9]
     :set warning [:pick $comment 9 11]
     :set lastmonth [:pick $comment 11 13]
     :set lastinvoicemonth [:pick $comment 11 13]
     :set nextinvoicenumber ($invoice + 1)
     :if ([get $i download-used] > 0) do={ :set bytesin [get $i download-used] } else={ :set bytesin 0 }
     :if ([get $i upload-used] > 0) do={ :set bytesout [get $i upload-used] } else={ :set bytesout 0 } 
     :set bytestotal ($bytesin + $bytesout)
     :set gigstotal ($bytestotal / 1000000)
     
     :set email [get $i email]
     :set basecharge 140
     :set usagecharge 0
     :put $poolname
    
     :set newcomment "$nextinvoicenumber$cap$warning$newmonthnum"
     /tool user-manager user set $i comment=$newcomment
     :if ([$discountcheck] > 0 ) do={ :set discount [get $i discount] } else={ :set discount 0 }
    
     #Here, I set the Cost based on what Package the clients have - usage based, discounts... blabla.
     # I have an in-house mail server to handle all the outgoing e-mail
    
     # For Capped Services
     
     :if ([$poolname] = "64")  do={ :set amount "220" }
     :if ([$poolname] = "128") do={ :set amount "330" }
     :if ([$poolname] = "256") do={ :set amount "450" }
     
     # For Uncapped Services
     
     :if ([$poolname] = "64uncapped") do={ :set amount "550" }
     :if ([$poolname] = "128uncapped") do={ :set amount "675" }
     :if ([$poolname] = "256uncapped") do={ :set amount "800" }
     
     :if ([$poolname] = "usagebased") do={ :set usagecharge ((($gigstotal/100) * 7) + 7) }
     :if ([$poolname] = "usagebased") do={ :set amount $basecharge}
     :set discountedamount ($amount - $discount) 
     :set total ($discountedamount + $usagecharge)
     :if ([$total] = 0) do={ :set doespay "This is a Complimentary Account"} else={ :set doespay "-" }
     
     #this one E-mails a basics-only invoice to Accounts for my WISP:
     
     /tool e-mail send to=accounts@YourWISP.com from=NoReply@YourWISP.com server=$server subject="Invoice for user $usrname" body="Sent Invoice to $email
     
     Invoice:         $usrname-$date-$invoice
     Date:            $date
     Data:            $gigstotal MB
     Uptime:          $uptime
     Subtotal:      R $amount.00
     Usage Charge:  R $usagecharge.00
     Discount:     -R $discount.00
     
     Total:         R $total.00
     
     $doespay"
     :log info "Sent Invoice for $usrname to Accounting"
     
     #this one sends a more elaborate version with all the necessary information to the Client's E-mail addy.
     
     /tool e-mail send to=$email from=NoReply@YourWISP.com server=$server subject="Wireless Statement" body="Dear $clientname $clientsurname
     Statement For Wireless Internet Services $poolname kbps Package
    
     Statement Number:   $usrname-$date-$invoice
     
     This is a statement for user account: $usrname
     Your current total uptime is $uptime
     Total Data Transferred: $gigstotal MB
     
     
     Subtotal:        R $amount.00
     Usage Charge:    R $usagecharge.00
     Discount:       -R $discount.00
                     ---------
     Total:           R $total.00
                     =========
     
     This is the payable amount on your user account.
     
     Our Banking Details are as follow:
     
     Bank: YourBankName
     Branch: YourBranchName
     Account: YourAccountNumber
     Holder: YourAccountHolder
     Reference: $usrname
     
     Please remember to state your Username as reference
     for the deposit, in order to avoid confusion among transactions.
    
     If you have received this statement in error, please reply to this E-mail
     stating that you are not the intended recipient, and then delete this message.
     Should there be any incorrect information on this report, 
     please inform us immediately.
     
     Warm Regards
     YourWISP"
     
     :log info "Kirim tagihan untuk user $usrname ke $email"
     /tool user-manager user reset-counters $i
     }
     }

    Untuk detail info per bagian di scriptingnya...

    "Definisi Variabel yang akan digunakan"
    Code:
     :local uptime
     :local count
     :local usrname
     :local clientname
     :local clientsurname
     :local poolname
     :local accounttype
     :local discount
     :local amount
     :local discountedamount
     :local discountcheck
     :local date
     :local invoice
     :local nextinvoicenumber
     :local bytesin
     :local bytesout
     :local bytestotal
     :local gigstotal
     :local email
     :local basecharge
     :local usagecharge
     :local total
     :local disabled
     :local doespay
     :local server
     :local newcomment
     :local comment
     :local cap
     :local warning
     :local lastinvoicemonth
     :local month
     :local monthnum
     :local newmonthnum
     :local lastmonth
    Bagian ini melakukan proses pengambilan alamat IP dari server SMTP yang ingin anda gunakan.

    Code:
    :set server [:resolve smtp.yourserver.com]
    Kalau anda sudah tau nomor IP nya misal 202.12.34.56 ya tulis aja langsung.

    Code:
    :set server 202.12.34.56
    karena bagian komentar diisi integer aja maka ga bisa digunakan nama bulan, oleh karena itu musti didefinisikan disini

    Code:
     :set month [:pick [/system clock get date] 0 3]
     
     :if ([$month] = jan) do={ :set newmonthnum 01 }
     :if ([$month] = feb) do={ :set newmonthnum 02 }
     :if ([$month] = mar) do={ :set newmonthnum 03 }
     :if ([$month] = apr) do={ :set newmonthnum 04 }
     :if ([$month] = may) do={ :set newmonthnum 05 }
     :if ([$month] = jun) do={ :set newmonthnum 06 }
     :if ([$month] = jul) do={ :set newmonthnum 07 }
     :if ([$month] = aug) do={ :set newmonthnum 08 }
     :if ([$month] = sep) do={ :set newmonthnum 09 }
     :if ([$month] = oct) do={ :set newmonthnum 10 }
     :if ([$month] = nov) do={ :set newmonthnum 11 }
     :if ([$month] = dec) do={ :set newmonthnum 12 }
    sekarang buat looping untuk semua user di usermanagernya.
    karena pada contoh ini subscriber nya di set admin saja maka dibuat seperti ini

    Code:
     /tool user-manager user
     :foreach i in=[ /tool user-manager user find subscriber=admin ] do={
     
     :set disabled [get $i disabled]
     
     :if ([$disabled] = false) do={
     :set date [/system clock get date]
     :set usrname [get $i name]
     :set uptime [get $i uptime-used]
     :set clientname [get $i first-name]
     :set clientsurname [get $i last-name]
     :set poolname [get $i pool-name]
     :set discountcheck [get $i discount]
     :set comment [get $i comment]
     :set invoice [:pick $comment 0 5] 
     :set cap [:pick $comment 5 9]
     :set warning [:pick $comment 9 11]
     :set lastmonth [:pick $comment 11 13]
     :set lastinvoicemonth [:pick $comment 11 13]
     :set nextinvoicenumber ($invoice + 1)
    Nah yang berikut ini semua informasi yang akan digunakan pada proses looping yang diekstrak dari User Manager dan dari sumber lain yang tersedia.

    Simalakama yang dihadapi adalah jika user yang didapat di data hasil ekstrak belum pernah login pada bulan tersebut sehingga ga ada data download yang didapat, maka script akan jadi error Click here to enlarge
    Oleh karena itu dicoba script akan melakukan pemaksaan mengisi data dengan "0" sebagai jumlah pemakaian si usernya.

    Code:
     :if ([get $i download-used] > 0) do={ :set bytesin [get $i download-used] } else={ :set bytesin 0 }
     :if ([get $i upload-used] > 0) do={ :set bytesout [get $i upload-used] } else={ :set bytesout 0 } 
     :set bytestotal ($bytesin + $bytesout)
     :set gigstotal ($bytestotal / 1000000)
     
     :set email [get $i email]
     :set basecharge 140
     :set usagecharge 0
    Nah sampai disini sudah didapat apa yang diperlukan untuk pengambilan data dari bagian komentar. Hal yang diupdate hanyalah bagian nomor tagihan dan nomor bulannya.

    Code:
     :set newcomment "$nextinvoicenumber$cap$warning$newmonthnum"
     /tool user-manager user set $i comment=$newcomment
     :if ([$discountcheck] > 0 ) do={ :set discount [get $i discount] } else={ :set discount 0 }
    weh... ada diskon ya? kali aja ada user kita yang dititipin sebagai repeater di atap rumahnya... tulis aja deh..
    Ganti xxxx dengan nominal diskonnya.

    Code:
     /tool user-manager user set [/tool user-manager user find name=YourUser] discount=xxxx
    Sekarang ditentukan berapa banyak nominal hutang yang harus dibayar si klien atas layanan yang sudah diberikan...

    # For Capped Services

    :if ([$poolname] = "64") do={ :set amount "220" }
    :if ([$poolname] = "128") do={ :set amount "330" }
    :if ([$poolname] = "256") do={ :set amount "450" }

    # For Uncapped Services

    :if ([$poolname] = "64uncapped") do={ :set amount "550" }
    :if ([$poolname] = "128uncapped") do={ :set amount "675" }
    :if ([$poolname] = "256uncapped") do={ :set amount "800" }
    untuk yang berbasis pemakaian, disini di charge 7 unit dari mata uang si pembuat script ini (kayaknya sih orang india dengan mata uang Rupee, CMIIW) setiap 100MB plus 7 lagi untuk kompensasi "or part there of" yang terpotong pada hasil pembagian.

    Code:
     :if ([$poolname] = "usagebased") do={ :set usagecharge ((($gigstotal/100) * 7) + 7) }
     :if ([$poolname] = "usagebased") do={ :set amount $basecharge}
     :set discountedamount ($amount - $discount) 
     :set total ($discountedamount + $usagecharge)
     :if ([$total] = 0) do={ :set doespay "This is a Complimentary Account"} else={ :set doespay "-" }
    Nah sekarang susun dulu deh emailnya... buat notifikasi ke kita sendiri.

    Code:
     /tool e-mail send to=accounts@YourWISP.com from=NoReply@YourWISP.com server=$server subject="Invoice for user $usrname" body="Sent Invoice to $email
     
     Invoice:         $usrname-$date-$invoice
     Date:            $date
     Data:            $gigstotal MB
     Uptime:          $uptime
     Subtotal:      R $amount.00
     Usage Charge:  R $usagecharge.00
     Discount:     -R $discount.00
     
     Total:         R $total.00
     
     $doespay"
    Lalu tulis catatan bukti pengiriman email

    Code:
     :log info "Sent Invoice for $usrname to Accounting"
    Nah sekarang buat email untuk dikirimkan ke kliennya...

    Code:
     /tool e-mail send to=$email from=NoReply@YourWISP.com server=$server subject="Wireless Statement" body="Dear $clientname $clientsurname
     Statement For Wireless Internet Services $poolname kbps Package
     
     Statement Number:   $usrname-$date-$invoice
     
     This is a statement for user account: $usrname
     Your current total uptime is $uptime
     Total Data Transferred: $gigstotal MB
     
     Subtotal:        R $amount.00
     Usage Charge:    R $usagecharge.00
     Discount:       -R $discount.00
                      ---------
     Total:           R $total.00
                      =========
     
     This is the payable amount on your user account.
     
     ....Bla bla bla...
     
     Warm Regards
     YourWISP"
    Catat bukti pengiriman emailnya...

    Code:
     :log info "Kirim tagihan untuk user $usrname ke $email"
    Akhirnya, hapus penghitungan "Usage" dan "Uptime" agar siap untuk itung lagi bulan depan, juga akhiri proses loopingnya.

    Code:
     /tool user-manager user reset-counters $i
     }
     }


    semoga berkenan dan bisa saling sharing untuk pengembangannya Click here to enlarge

  2. The Following 14 Users Say Thank You to dencow For This Useful Post:

    + Show/Hide list of the thanked


  3. Total Comments 9

    Comments

  4. #2
    Status
    Offline
    yogaponsel's Avatar
    Forum Guru
    Join Date
    Oct 2008
    Location
    "BnetAkses"
    Posts
    2,511
    Reviews
    Read 0 Reviews
    Downloads
    1
    Uploads
    0
    Feedback Score
    0
    Click here to enlarge Originally Posted by dencow Click here to enlarge
    Nemu di wikinya mikrotik nih ( dan scriptnya di )
    belom coba implementasi sih.... soalnya diriku saat ini ga pake user manager Click here to enlarge

    Oke.. dimulai aja kali ya... coba terjemahin, coba implementasinya ya ntar aja deh kalau punya stock barang ekstra...


    Billing ostomastis ini menggunakan script dan fungsinya adalah melakukan penagihan ke klien setiap akhir bulan secara ostomastis Click here to enlarge

    Syarat untuk dapat menggunakan fitur ini adalah pengguna mikrotik versi 3.0rc5 keatas dan menggunakan user manager serta ada sumber daya perangkat yang memadai disamping pengertian mengenai scripting.

    Oh ya, syarat yang lain adalah harus memiliki akses ke server SMTP Click here to enlarge

    Juga format di user manager harus punya field berikut ini (cek di "/tool user-manager user print" tanpa tanda kutip)



    Nah ini dia contoh script lengkapnya...

    Code:
     :local uptime
     :local count
     :local usrname
     :local clientname
     :local clientsurname
     :local poolname
     :local accounttype
     :local discount
     :local amount
     :local discountedamount
     :local discountcheck
     :local date
     :local invoice
     :local nextinvoicenumber
     :local bytesin
     :local bytesout
     :local bytestotal
     :local gigstotal
     :local email
     :local basecharge
     :local usagecharge
     :local total
     :local disabled
     :local doespay
     :local server
     :local newcomment
     :local comment
     :local cap
     :local warning
     :local lastinvoicemonth
     :local month
     :local monthnum
     :local newmonthnum
     :local lastmonth
     
     :set server [:resolve smtp.yourserver.com]
     
     :set month [:pick [/system clock get date] 0 3]
     
     :if ([$month] = jan) do={ :set newmonthnum 01 }
     :if ([$month] = feb) do={ :set newmonthnum 02 }
     :if ([$month] = mar) do={ :set newmonthnum 03 }
     :if ([$month] = apr) do={ :set newmonthnum 04 }
     :if ([$month] = may) do={ :set newmonthnum 05 }
     :if ([$month] = jun) do={ :set newmonthnum 06 }
     :if ([$month] = jul) do={ :set newmonthnum 07 }
     :if ([$month] = aug) do={ :set newmonthnum 08 }
     :if ([$month] = sep) do={ :set newmonthnum 09 }
     :if ([$month] = oct) do={ :set newmonthnum 10 }
     :if ([$month] = nov) do={ :set newmonthnum 11 }
     :if ([$month] = dec) do={ :set newmonthnum 12 }
     
     # Loop through all the users in User Manager - My only  Subscriber is Admin
     /tool user-manager user
     :foreach i in=[ /tool user-manager user find subscriber=admin ] do={
    
     #Pull out all the information I need 
     
     :set disabled [get $i disabled]
     
     :if ([$disabled] = false) do={
     #pull some data from it, and print it on screen
     :set date [/system clock get date]
     :set usrname [get $i name]
     :set uptime [get $i uptime-used]
     :set clientname [get $i first-name]
     :set clientsurname [get $i last-name]
     :set poolname [get $i pool-name]
     :set discountcheck [get $i discount]
     :set comment [get $i comment]
     :set invoice [:pick $comment 0 5] 
     :set cap [:pick $comment 5 9]
     :set warning [:pick $comment 9 11]
     :set lastmonth [:pick $comment 11 13]
     :set lastinvoicemonth [:pick $comment 11 13]
     :set nextinvoicenumber ($invoice + 1)
     :if ([get $i download-used] > 0) do={ :set bytesin [get $i download-used] } else={ :set bytesin 0 }
     :if ([get $i upload-used] > 0) do={ :set bytesout [get $i upload-used] } else={ :set bytesout 0 } 
     :set bytestotal ($bytesin + $bytesout)
     :set gigstotal ($bytestotal / 1000000)
     
     :set email [get $i email]
     :set basecharge 140
     :set usagecharge 0
     :put $poolname
    
     :set newcomment "$nextinvoicenumber$cap$warning$newmonthnum"
     /tool user-manager user set $i comment=$newcomment
     :if ([$discountcheck] > 0 ) do={ :set discount [get $i discount] } else={ :set discount 0 }
    
     #Here, I set the Cost based on what Package the clients have - usage based, discounts... blabla.
     # I have an in-house mail server to handle all the outgoing e-mail
    
     # For Capped Services
     
     :if ([$poolname] = "64")  do={ :set amount "220" }
     :if ([$poolname] = "128") do={ :set amount "330" }
     :if ([$poolname] = "256") do={ :set amount "450" }
     
     # For Uncapped Services
     
     :if ([$poolname] = "64uncapped") do={ :set amount "550" }
     :if ([$poolname] = "128uncapped") do={ :set amount "675" }
     :if ([$poolname] = "256uncapped") do={ :set amount "800" }
     
     :if ([$poolname] = "usagebased") do={ :set usagecharge ((($gigstotal/100) * 7) + 7) }
     :if ([$poolname] = "usagebased") do={ :set amount $basecharge}
     :set discountedamount ($amount - $discount) 
     :set total ($discountedamount + $usagecharge)
     :if ([$total] = 0) do={ :set doespay "This is a Complimentary Account"} else={ :set doespay "-" }
     
     #this one E-mails a basics-only invoice to Accounts for my WISP:
     
     /tool e-mail send to=accounts@YourWISP.com from=NoReply@YourWISP.com server=$server subject="Invoice for user $usrname" body="Sent Invoice to $email
     
     Invoice:         $usrname-$date-$invoice
     Date:            $date
     Data:            $gigstotal MB
     Uptime:          $uptime
     Subtotal:      R $amount.00
     Usage Charge:  R $usagecharge.00
     Discount:     -R $discount.00
     
     Total:         R $total.00
     
     $doespay"
     :log info "Sent Invoice for $usrname to Accounting"
     
     #this one sends a more elaborate version with all the necessary information to the Client's E-mail addy.
     
     /tool e-mail send to=$email from=NoReply@YourWISP.com server=$server subject="Wireless Statement" body="Dear $clientname $clientsurname
     Statement For Wireless Internet Services $poolname kbps Package
    
     Statement Number:   $usrname-$date-$invoice
     
     This is a statement for user account: $usrname
     Your current total uptime is $uptime
     Total Data Transferred: $gigstotal MB
     
     
     Subtotal:        R $amount.00
     Usage Charge:    R $usagecharge.00
     Discount:       -R $discount.00
                     ---------
     Total:           R $total.00
                     =========
     
     This is the payable amount on your user account.
     
     Our Banking Details are as follow:
     
     Bank: YourBankName
     Branch: YourBranchName
     Account: YourAccountNumber
     Holder: YourAccountHolder
     Reference: $usrname
     
     Please remember to state your Username as reference
     for the deposit, in order to avoid confusion among transactions.
    
     If you have received this statement in error, please reply to this E-mail
     stating that you are not the intended recipient, and then delete this message.
     Should there be any incorrect information on this report, 
     please inform us immediately.
     
     Warm Regards
     YourWISP"
     
     :log info "Kirim tagihan untuk user $usrname ke $email"
     /tool user-manager user reset-counters $i
     }
     }

    Untuk detail info per bagian di scriptingnya...

    "Definisi Variabel yang akan digunakan"
    Code:
     :local uptime
     :local count
     :local usrname
     :local clientname
     :local clientsurname
     :local poolname
     :local accounttype
     :local discount
     :local amount
     :local discountedamount
     :local discountcheck
     :local date
     :local invoice
     :local nextinvoicenumber
     :local bytesin
     :local bytesout
     :local bytestotal
     :local gigstotal
     :local email
     :local basecharge
     :local usagecharge
     :local total
     :local disabled
     :local doespay
     :local server
     :local newcomment
     :local comment
     :local cap
     :local warning
     :local lastinvoicemonth
     :local month
     :local monthnum
     :local newmonthnum
     :local lastmonth
    Bagian ini melakukan proses pengambilan alamat IP dari server SMTP yang ingin anda gunakan.

    Code:
    :set server [:resolve smtp.yourserver.com]
    Kalau anda sudah tau nomor IP nya misal 202.12.34.56 ya tulis aja langsung.

    Code:
    :set server 202.12.34.56
    karena bagian komentar diisi integer aja maka ga bisa digunakan nama bulan, oleh karena itu musti didefinisikan disini

    Code:
     :set month [:pick [/system clock get date] 0 3]
     
     :if ([$month] = jan) do={ :set newmonthnum 01 }
     :if ([$month] = feb) do={ :set newmonthnum 02 }
     :if ([$month] = mar) do={ :set newmonthnum 03 }
     :if ([$month] = apr) do={ :set newmonthnum 04 }
     :if ([$month] = may) do={ :set newmonthnum 05 }
     :if ([$month] = jun) do={ :set newmonthnum 06 }
     :if ([$month] = jul) do={ :set newmonthnum 07 }
     :if ([$month] = aug) do={ :set newmonthnum 08 }
     :if ([$month] = sep) do={ :set newmonthnum 09 }
     :if ([$month] = oct) do={ :set newmonthnum 10 }
     :if ([$month] = nov) do={ :set newmonthnum 11 }
     :if ([$month] = dec) do={ :set newmonthnum 12 }
    sekarang buat looping untuk semua user di usermanagernya.
    karena pada contoh ini subscriber nya di set admin saja maka dibuat seperti ini

    Code:
     /tool user-manager user
     :foreach i in=[ /tool user-manager user find subscriber=admin ] do={
     
     :set disabled [get $i disabled]
     
     :if ([$disabled] = false) do={
     :set date [/system clock get date]
     :set usrname [get $i name]
     :set uptime [get $i uptime-used]
     :set clientname [get $i first-name]
     :set clientsurname [get $i last-name]
     :set poolname [get $i pool-name]
     :set discountcheck [get $i discount]
     :set comment [get $i comment]
     :set invoice [:pick $comment 0 5] 
     :set cap [:pick $comment 5 9]
     :set warning [:pick $comment 9 11]
     :set lastmonth [:pick $comment 11 13]
     :set lastinvoicemonth [:pick $comment 11 13]
     :set nextinvoicenumber ($invoice + 1)
    Nah yang berikut ini semua informasi yang akan digunakan pada proses looping yang diekstrak dari User Manager dan dari sumber lain yang tersedia.

    Simalakama yang dihadapi adalah jika user yang didapat di data hasil ekstrak belum pernah login pada bulan tersebut sehingga ga ada data download yang didapat, maka script akan jadi error Click here to enlarge
    Oleh karena itu dicoba script akan melakukan pemaksaan mengisi data dengan "0" sebagai jumlah pemakaian si usernya.

    Code:
     :if ([get $i download-used] > 0) do={ :set bytesin [get $i download-used] } else={ :set bytesin 0 }
     :if ([get $i upload-used] > 0) do={ :set bytesout [get $i upload-used] } else={ :set bytesout 0 } 
     :set bytestotal ($bytesin + $bytesout)
     :set gigstotal ($bytestotal / 1000000)
     
     :set email [get $i email]
     :set basecharge 140
     :set usagecharge 0
    Nah sampai disini sudah didapat apa yang diperlukan untuk pengambilan data dari bagian komentar. Hal yang diupdate hanyalah bagian nomor tagihan dan nomor bulannya.

    Code:
     :set newcomment "$nextinvoicenumber$cap$warning$newmonthnum"
     /tool user-manager user set $i comment=$newcomment
     :if ([$discountcheck] > 0 ) do={ :set discount [get $i discount] } else={ :set discount 0 }
    weh... ada diskon ya? kali aja ada user kita yang dititipin sebagai repeater di atap rumahnya... tulis aja deh..
    Ganti xxxx dengan nominal diskonnya.

    Code:
     /tool user-manager user set [/tool user-manager user find name=YourUser] discount=xxxx
    Sekarang ditentukan berapa banyak nominal hutang yang harus dibayar si klien atas layanan yang sudah diberikan...



    untuk yang berbasis pemakaian, disini di charge 7 unit dari mata uang si pembuat script ini (kayaknya sih orang india dengan mata uang Rupee, CMIIW) setiap 100MB plus 7 lagi untuk kompensasi "or part there of" yang terpotong pada hasil pembagian.

    Code:
     :if ([$poolname] = "usagebased") do={ :set usagecharge ((($gigstotal/100) * 7) + 7) }
     :if ([$poolname] = "usagebased") do={ :set amount $basecharge}
     :set discountedamount ($amount - $discount) 
     :set total ($discountedamount + $usagecharge)
     :if ([$total] = 0) do={ :set doespay "This is a Complimentary Account"} else={ :set doespay "-" }
    Nah sekarang susun dulu deh emailnya... buat notifikasi ke kita sendiri.

    Code:
     /tool e-mail send to=accounts@YourWISP.com from=NoReply@YourWISP.com server=$server subject="Invoice for user $usrname" body="Sent Invoice to $email
     
     Invoice:         $usrname-$date-$invoice
     Date:            $date
     Data:            $gigstotal MB
     Uptime:          $uptime
     Subtotal:      R $amount.00
     Usage Charge:  R $usagecharge.00
     Discount:     -R $discount.00
     
     Total:         R $total.00
     
     $doespay"
    Lalu tulis catatan bukti pengiriman email

    Code:
     :log info "Sent Invoice for $usrname to Accounting"
    Nah sekarang buat email untuk dikirimkan ke kliennya...

    Code:
     /tool e-mail send to=$email from=NoReply@YourWISP.com server=$server subject="Wireless Statement" body="Dear $clientname $clientsurname
     Statement For Wireless Internet Services $poolname kbps Package
     
     Statement Number:   $usrname-$date-$invoice
     
     This is a statement for user account: $usrname
     Your current total uptime is $uptime
     Total Data Transferred: $gigstotal MB
     
     Subtotal:        R $amount.00
     Usage Charge:    R $usagecharge.00
     Discount:       -R $discount.00
                      ---------
     Total:           R $total.00
                      =========
     
     This is the payable amount on your user account.
     
     ....Bla bla bla...
     
     Warm Regards
     YourWISP"
    Catat bukti pengiriman emailnya...

    Code:
     :log info "Kirim tagihan untuk user $usrname ke $email"
    Akhirnya, hapus penghitungan "Usage" dan "Uptime" agar siap untuk itung lagi bulan depan, juga akhiri proses loopingnya.

    Code:
     /tool user-manager user reset-counters $i
     }
     }


    semoga berkenan dan bisa saling sharing untuk pengembangannya Click here to enlarge
    na is info juragan.. coba dulu ya .... memet dan commentnya belakangan .. okClick here to enlargeClick here to enlarge

  5. The Following User Says Thank You to yogaponsel For This Useful Post:


  6. #3
    Status
    Offline
    amedya's Avatar
    Member
    Join Date
    Jun 2008
    Location
    0.0.0.0/0
    Posts
    296
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    Click here to enlarge Originally Posted by yogaponsel Click here to enlarge
    na is info juragan.. coba dulu ya .... memet dan commentnya belakangan .. okClick here to enlargeClick here to enlarge
    Mangtab Gan infonya menuju Tkp>>>>Test...

  7. #4
    Status
    Offline
    limaliang88's Avatar
    Calon Member
    Join Date
    Jun 2008
    Posts
    77
    Reviews
    Read 0 Reviews
    Downloads
    1
    Uploads
    0
    Feedback Score
    0
    laksanakan tugas akang dulu.... di cicil. ^^^^Click here to enlargeClick here to enlarge

  8. #5
    Status
    Offline
    Skyper's Avatar
    Newbie
    Join Date
    May 2009
    Posts
    68
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    Thanks Bro..Click here to enlarge

  9. The Following User Says Thank You to Skyper For This Useful Post:


  10. #6
    Status
    Offline
    cooling's Avatar
    Member
    Join Date
    Dec 2007
    Posts
    209
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    Kalo gak ada :

    * First Name
    * Last Name
    * E-mail Address
    * Pool Name
    * Comment Field
    bagaimana yah cara aktifkan?

    Thanks

  11. #7
    Status
    Offline
    dencow's Avatar
    Forum Guru
    Join Date
    Jan 2008
    Posts
    1,727
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    1 (100%)
    Click here to enlarge Originally Posted by cooling Click here to enlarge
    Kalo gak ada :

    * First Name
    * Last Name
    * E-mail Address
    * Pool Name
    * Comment Field

    bagaimana yah cara aktifkan?

    Thanks
    buat dulu lah boss, coba jalan lah ke
    Code:
    /tool user-manager user
    lalu tinggal add deh informasi yang diperlukan diatas

  12. #8
    Status
    Offline
    rablydotconf's Avatar
    Baru Gabung
    Join Date
    Aug 2009
    Posts
    14
    Reviews
    Read 0 Reviews
    Downloads
    11
    Uploads
    0
    Feedback Score
    0
    nice info ganClick here to enlarge

  13. #9
    Status
    Offline
    RB750's Avatar
    Calon Member
    Join Date
    Nov 2009
    Posts
    83
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    nice tutz.........

  14. #10
    Status
    Offline
    gd budi's Avatar
    Baru Gabung
    Join Date
    Aug 2011
    Posts
    1
    Reviews
    Read 0 Reviews
    Downloads
    0
    Uploads
    0
    Feedback Score
    0
    thx infona gan..
    saya dah cb implementasikan.. billingna sudah mau dikirim ke email client tp penggunaan datanya dikirim 0, apa yg kurang ya??.

    terus bagian di bwah ini fungsi codena untuk apa ya?? maaf banyak nanya gan.. maklum masih nubi dalam bidang mikrotik..

    untuk yang berbasis pemakaian, disini di charge 7 unit dari mata uang si pembuat script ini (kayaknya sih orang india dengan mata uang Rupee, CMIIW) setiap 100MB plus 7 lagi untuk kompensasi "or part there of" yang terpotong pada hasil pembagian.
    Code:
     
    if ([$poolname] = "usagebased") do={ :set usagecharge ((($gigstotal/100) * 7) + 7) }
     :if ([$poolname] = "usagebased") do={ :set amount $basecharge}
     :set discountedamount ($amount - $discount) 
     :set total ($discountedamount + $usagecharge)
     :if ([$total] = 0) do={ :set doespay "This is a Complimentary Account"} else={ :set doespay "-" }

 

 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Articles

  1. (ask) Billing Untuk hot spot
    By ace in forum Wireless Networking
    Replies: 9
    Last Post: 11-03-2013, 15:56
  2. ask about PPPoE + Billing
    By seroja in forum General Networking
    Replies: 5
    Last Post: 26-05-2009, 12:12
  3. help me :radius dan billing server
    By nh4edy in forum Beginner Basics
    Replies: 13
    Last Post: 31-01-2009, 18:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
ads