abougouffa / pyIslam

pyIslam, a Python library to calculate prayer times, hijri date, qiblah direction and more
http://abougouffa.github.io/pyIslam
GNU Lesser General Public License v3.0
94 stars 32 forks source link

Zakat calculation routines #1

Closed abougouffa closed 4 years ago

monsef-alahem commented 4 years ago
#awsoq jam' wisq  = 195 kg hanafi wa 122.4 kg jomhor
#nisab 5 awsoq tomor
#mitkal dahab = 5 gramme
#nisab fida = 595 gr
#nisab dahab = 85 gr

def calculateZakat(amount) :
    #minimal amount is 4000 dollars approximately this days
    nisab = 4000 
    if amount <= nisab:
        return 0
    result = amount / 10 / 4
    return result   

def calculateZakatHarvest(weight, irrigationType = 'artificial', method = 'hanafi') :
    #minimal weight in kilogramme
    nisab = 975
    if method == 'hanafi' :
        nisab =  975
    elif method == 'other' :
        nisab = 612
    else :
        print('invalid methode')
        return

    if weight <= nisab:
        return 0

    if irrigationType == 'artificial':
        result = weight / 20
        return result   
    elif irrigationType == 'natural':
        result = weight / 10
        return result   
    else :
        print('invalid type of irrigation')
        return

#testing
print(str(calculateZakat(10000)) + ' $')
print(str(calculateZakatHarvest(10000)) + ' Kg')
print(str(calculateZakatHarvest(10000,'natural','other')) + ' Kg')
abougouffa commented 4 years ago

Salam, Thank you very much @monsef-alahem , As we haven't implemented any Zakat class yet, you can go ahead and clone the repo, add a new file with your code and open a pull request; I will be very happy to merge your code :smile:

monsef-alahem commented 4 years ago

Alaykom asalam, i'm very grateful to you for creating this library, i was strugling finding accruate praytime calculation algorithm without using database for my app, and here it is ! So this is the least i can do :) i'm still working on Mirhat class, i'll merge the code as soon as i'm done inchaa Allah.