Exemplo n.º 1
0
Arquivo: mis.py Projeto: tedlaz/efka
def calc_ea(par, osyk_db):
    """
    Υπολογισμός επιδόματος αδείας

    """
    par['mtype'] = 'Μισθοδοσία Επιδόματος Αδείας'
    par['payroll_type'] = s.PTYPE[par['typ']]
    fin = {'par': par}
    apo = {}
    apo['meresea'] = rnd(par['meres'] / 25 * 2)
    apo['meso_imeromisthio'] = rnd(par['val'] / par['meres'])
    if par['typ'] == 1:
        if apo['meresea'] > 12.5:
            apo['meresea'] = 12.5
    elif par['typ'] == 2:
        if apo['meresea'] > 13:
            apo['meresea'] = 13
    elif par['typ'] == 3:
        if apo['meresea'] > 13:
            apo['meresea'] = 13
    apo['a_total'] = rnd(apo['meresea'] * apo['meso_imeromisthio'])
    apo['meres_efka'] = 0
    fin['apo'] = apo
    efka = calc_efka(osyk_db, par['kad'], par['eid'], par['per'],
                     apo['a_total'])
    fin['efka'] = efka
    year = str(par['per'])[:4]
    taxes = calc_tax_doro_pasxa_epidoma_adeias(year, efka['amount-after-efka'],
                                               par['paidia'])
    fin['taxes'] = taxes
    return fin
Exemplo n.º 2
0
Arquivo: mis.py Projeto: tedlaz/efka
def calc_astheneia(par, osyk_db):
    fin = {'par': par}
    apo = {}
    apo['a_eos3'] = rnd(par['eos3'] * par['imeromisthio'] / 2)
    apo['a_more3'] = rnd(par['more3'] * par['imeromisthio'])
    apo['a_efka'] = rnd(apo['a_eos3'] + apo['a_more3'])
    efka = calc_efka(osyk_db, par['kad'], par['eid'], par['per'],
                     apo['a_efka'])
    efka_epidoma = calc_efka(osyk_db, par['kad'], par['eid'], par['per'],
                             par['epidoma'])
    fin['apo'] = apo
    fin['efka'] = efka
    return fin
Exemplo n.º 3
0
def rndCoords(distance, zFlatness, center={"x":0,"y":0,"z":0}):
    distance = random.randrange(distance[0],distance[1])
    x = utils.rnd()
    y = utils.rnd()
    z = utils.rnd() * zFlatness
    l = math.fabs(x**3 + y**3 + z**3)**(1/3)
    k = distance / l
    return {
        "radius":distance,
        "x":float(x*k+center["x"]),
        "y":float(y*k+center["y"]),
        "z":float(z*k+center["z"])
    }
Exemplo n.º 4
0
 def calc_eisfores(self, amount):
     rvl = {
         'epikouriko': self.name,
         'pososto_ergazomenos%': self.penos,
         'pososto_ergodotis%': self.petis,
         'pososto_total': self.penos + self.petis,
         'amount': amount
     }
     rvl['kratiseis_ergazomenou'] = rnd(amount * self.penos / 100.0)
     total = rnd(amount * (self.penos + self.petis) / 100.0)
     rvl['kratiseis_ergodoti'] = total - rvl['kratiseis_ergazomenou']
     rvl['kratiseis_synolika'] = total
     return rvl
Exemplo n.º 5
0
Arquivo: mis.py Projeto: tedlaz/efka
def calc_mikta_apo_kathara(kat, kad, eid, per, paidia, osyk_db):
    """Υπολογισμός μικτών απόδοχών από καθαρές αποδοχές"""
    if per == 0:
        now = datetime.datetime.now()
        per = int(now.isoformat()[:7].replace('-', ''))
    apr = kat
    i = 0
    delta = 10
    while delta > 0.001:
        if i > 100:
            break
        i += 1
        arr = {
            'val': apr,
            'meres': 25,
            'paidia': paidia,
            'typ': 1,
            'per': per,
            'kad': kad,
            'eid': eid
        }
        res = calc_mis(arr, osyk_db)
        val = res['taxes']['katharo']
        delta = kat - val
        apr += delta
        arr['misthos'] = apr
    return {
        'kathara': kat,
        'mikta': rnd(apr),
        'kad': kad,
        'eid': eid,
        'per': per,
        'paidia': paidia,
        'iterations': i
    }
Exemplo n.º 6
0
 def randomtitle(self, allowparentheses=True):
     while True:
         if utils.rnd(100) < 80:
             name = random.choice(self.english_titles)
         else:
             name = random.choice(self.non_english_titles)
         if not allowparentheses and ("(" in name or ")" in name):
             continue
         return name
Exemplo n.º 7
0
Arquivo: erg.py Projeto: tedlaz/efka
 def __init__(self, poso, penos, ptotal):
     self.poso = poso
     self.pososto_ergazomenos = penos
     self.pososto_total = ptotal
     self.pososto_ergodotis = ptotal - penos
     ergazomenos = rnd(penos * poso / 100)
     ttotal = rnd(ptotal * poso / 100)
     ergodotis = rnd(ttotal - ergazomenos)
     super().__init__(ergazomenos=ergazomenos, ergodotis=ergodotis)
     self.kostos_ergodoti = rnd(self.poso + ergodotis)
     self.ergazomenos_katharo = rnd(self.poso - ergazomenos)
     kostos_ergodoti_check = rnd(self.total + self.ergazomenos_katharo)
     self.isok = self.kostos_ergodoti == kostos_ergodoti_check
Exemplo n.º 8
0
Arquivo: mis.py Projeto: tedlaz/efka
def calc_doro(par, osyk_db):
    """
        par: {
            'imeromisthio': 55,
            'total_meres': 15
        }
        dtyp: 1=Πάσχα, 2=Χριστούγεννα
        Στην περίπτωση των ημερομισθίων θα μπορούσε να γίνει υπολογισμός
        με βάση τις μικτές αποδοχές από Ιανουάριο έως Απρίλιο επί τον
        συντελεστη 0.15385(0.6154 / 4)
    """
    par['paidia'] = par.get('paidia', 0)
    fin = {'par': par}
    if par['doro_typ'] == 1:
        syn = 6.5
        orio_meres = 15
        par['mtype'] = 'Μισθοδοσία Δώρου Πάσχα'
    else:
        syn = 8
        orio_meres = 25
        par['mtype'] = 'Μισθοδοσία Δώρου Χριστουγέννων'
    apo = {}
    par['payroll_type'] = s.PTYPE[par['typ']]
    if par['typ'] == 1:
        apo['a_doro'] = rnd(par['val'] / 8)
    elif par['typ'] == 2:
        if par['meres'] == 0:
            return {'error': 'Πρέπει να δώσετε ημέρες εργασίας (meres)'}
        apo['a_doro'] = rnd(par['val'] * par['meres'] / syn)
        apo['orio_doroy'] = rnd(orio_meres * par['val'])
        if apo['a_doro'] > apo['orio_doroy']:
            apo['a_doro'] = rnd(apo['orio_doroy'])
    elif par['typ'] == 3:
        apo['a_doro'] = rnd(par['val'] / 8)
    else:
        fin['apo'] = {'error': 'Λάθος τύπος μισθοδοσίας'}
        return fin
    apo['a_total'] = rnd(apo['a_doro'] * s.PROSAFKSISI_DOROY)
    apo['meres_efka'] = 0
    fin['apo'] = apo
    efka = calc_efka(osyk_db, par['kad'], par['eid'], par['per'],
                     apo['a_total'])
    fin['efka'] = efka
    year = str(par['per'])[:4]
    taxes = calc_tax_doro_pasxa_epidoma_adeias(year, efka['amount-after-efka'],
                                               par['paidia'])
    fin['taxes'] = taxes
    return fin
Exemplo n.º 9
0
def randomrectangle_candidate(w, h):
    center = Point(rnd(w), rnd(h))
    rw = max(rnd(w * 0.9), 30) # Not too thin: minimum width and height 20 pixels.
    rh = max(rnd(h * 0.9), 20)
    r = Rectangle(
        Point(center.x - rw / 2, center.y + rh / 2),
        Point(center.x + rw / 2, center.y + rh / 2),
        Point(center.x + rw / 2, center.y - rh / 2),
        Point(center.x - rw / 2, center.y - rh / 2))
    # Now rotate it randomly. There's a fifty-fifty percent change that the rotation will be strongly vertical/horizontal aligned.
    if rnd(100) > 50:
        angle = rnd(360) # Completely arbitrary rotation.
    else:
        angle = rnd(4) - 2 # Almost horizontal/vertical ;-)
    r = rotate.rotatedrectangle(r, angle)
    # Check whether every coordinate of the rectangle lies within (0,0)-(w,h) (with a 5% margin)
    topmargin, rightmargin, bottommargin, leftmargin = h * 0.05, w * 0.95, h * 0.95, w * 0.05 
    for p in r:
        if p.x < leftmargin or p.x > rightmargin: return None
        if p.y < topmargin or p.y > bottommargin: return None
    return r
Exemplo n.º 10
0
Arquivo: taxes.py Projeto: tedlaz/efka
def calc_tax_period(year, monthly_income, children=0, barytis=14):
    """Monthly calculation"""
    syn = barytis
    income = monthly_income * syn
    tax = calc_tax(year, income, children)
    tax['monthly_income'] = monthly_income
    tax['barytis'] = barytis
    tax['foros-poy-analogei-mina'] = rnd(tax['foros-poy-analogei'] / syn)
    tax['ekptosi-parakratithentos-foroy-mina'] = rnd(
        tax['ekptosi-parakratithentos-foroy'] / syn)
    tax['foros-poy-parakratithike-mina'] = rnd(
        tax['foros-poy-analogei-mina'] -
        tax['ekptosi-parakratithentos-foroy-mina'])
    tax['eea-mina'] = rnd(tax['eea'] / syn)
    tax['total-tax-mina'] = rnd(tax['foros-poy-parakratithike-mina'] +
                                tax['eea-mina'])
    tax['katharo'] = rnd(monthly_income - tax['total-tax-mina'])
    return tax
Exemplo n.º 11
0
def calc_efka(database, kad, eid, per, amount):
    """Calculate efka"""
    kpk = get_kpk(database, kad, eid, per)
    if kpk is None:
        return {
            'error': 'Δεν βρέθηκε ΚΑΔ για το συνδυασμό kad, eid, per',
            'kad': kad,
            'eid': eid,
            'per': per
        }
    penos = kpk['ergnos'] / 100.0
    ptota = kpk['synolo'] / 100.0
    kpk['amount'] = amount
    kpk['efka-ergazomenos'] = rnd(amount * penos, 2)
    kpk['efka-total'] = rnd(amount * ptota, 2)
    kpk['efka-ergodotis'] = rnd(kpk['efka-total'] - kpk['efka-ergazomenos'], 2)
    kpk['amount-after-efka'] = rnd(amount - kpk['efka-ergazomenos'], 2)
    kpk['total-kost'] = rnd(amount + kpk['efka-ergodotis'], 2)
    kpk['total-kost-check'] = rnd(kpk['efka-total'] + kpk['amount-after-efka'],
                                  2)
    return kpk
Exemplo n.º 12
0
 def test_rnd_01(self):
     self.assertEqual(utils.rnd(10.555, 2), 10.56)
Exemplo n.º 13
0
Arquivo: mis.py Projeto: tedlaz/efka
def calc_mis(par, osyk_db):
    """
    par: Dictionary με τις παρουσίες του εργαζομένου
    """
    par['ores'] = par.get('ores', 0)
    # Έλεγχοι για να έχουμε είτε μισθο είτε ημερομίσθιο είτε ωρομίσθιο
    valid_par, error_dic = check_par(par)
    if not valid_par:
        return error_dic
    par['month_year'] = humanize_period(par['per'])
    par['ores_nyxta'] = par.get('ores_nyxta', 0)
    par['ores_argia'] = par.get('ores_argia', 0)
    par['ores_yperergasia'] = par.get('ores_yperergasia', 0)
    par['meres_argia'] = par.get('meres_argia', 0)
    par['paidia'] = par.get('paidia', 0)
    par['mtype'] = 'Μισθοδοσία μηνός'
    fin = {'par': par}
    apo = {}
    par['payroll_type'] = s.PTYPE[par['typ']]
    if par['typ'] == 1:
        if par['meres'] == 0:
            par['meres'] = 25
        apo['misthos'] = par['val']
        apo['imeromisthio'] = rnd(par['val'] / s.EFKA_MERES_MHNA)
        apo['oromisthio'] = rnd(apo['imeromisthio'] * s.EFKA_MERES_BDOMADA /
                                s.EFKA_ORES_BDOMADA)
        apo['a_meres'] = rnd(par['meres'] / s.EFKA_MERES_MHNA * par['val'])
        apo['a_yperergasia'] = rnd(par['ores_yperergasia'] * apo['oromisthio'])
        apo['a_nyxta'] = rnd(par['ores_nyxta'] * apo['oromisthio'] *
                             s.POSOSTO_NYXTA)
        apo['a_argia_ores'] = rnd(par['ores_argia'] * apo['oromisthio'] *
                                  s.POSOSTO_ARGIA)
        apo['a_argia_meres'] = rnd(par['meres_argia'] * apo['imeromisthio'] *
                                   s.POSOSTO_ARGIA)
        apo['a_total'] = rnd(apo['a_meres'] + apo['a_yperergasia'] +
                             apo['a_nyxta'] + apo['a_argia_ores'] +
                             apo['a_argia_meres'])
        apo['meres_efka'] = par['meres']
    elif par['typ'] == 2:
        apo['imeromisthio'] = par['val']
        apo['oromisthio'] = rnd(par['val'] * s.EFKA_MERES_BDOMADA /
                                s.EFKA_ORES_BDOMADA)
        apo['a_meres'] = rnd(par['meres'] * par['val'])
        apo['a_yperergasia'] = rnd(par['ores_yperergasia'] * apo['oromisthio'])
        apo['a_nyxta'] = rnd(par['ores_nyxta'] * apo['oromisthio'] *
                             s.POSOSTO_NYXTA)
        apo['a_argia_ores'] = rnd(par['ores_argia'] * apo['oromisthio'] *
                                  s.POSOSTO_ARGIA)
        apo['a_argia_meres'] = rnd(par['meres_argia'] * par['val'] *
                                   s.POSOSTO_ARGIA)
        apo['a_total'] = rnd(apo['a_meres'] + apo['a_yperergasia'] +
                             apo['a_nyxta'] + apo['a_argia_ores'] +
                             apo['a_argia_meres'])
        apo['meres_efka'] = par['meres']
    elif par['typ'] == 3:
        apo['oromisthio'] = par['val']
        apo['a_ores'] = rnd(par['ores'] * par['val'])
        apo['a_yperergasia'] = rnd(par['ores_yperergasia'] * par['val'])
        apo['a_nyxta'] = rnd(par['ores_nyxta'] * par['val'] * s.POSOSTO_NYXTA)
        apo['a_argia_ores'] = rnd(par['ores_argia'] * par['val'] *
                                  s.POSOSTO_ARGIA)
        apo['a_total'] = rnd(apo['a_ores'] + apo['a_yperergasia'] +
                             apo['a_nyxta'] + apo['a_argia_ores'])

        apo['oresAnaMera'] = rnd(par['ores'] / par['meres'])
        apo['imeromisthio'] = rnd(apo['oresAnaMera'] * par['val'])
        if apo['imeromisthio'] >= s.EFKA_CLASS_1:
            par['meres_efka'] = par['meres']
        else:
            par['meres_efka'] = rnd(apo['a_total'] / s.EFKA_CLASS_1, 0)
    else:
        fin['apo'] = {'error': 'Λάθος τύπος μισθοδοσίας'}
        return fin
    fin['apo'] = apo
    # Εφ όσον έχουν πάει όλα καλά μέχρι εδώ συνεχίζουμε
    efka = calc_efka(osyk_db, par['kad'], par['eid'], par['per'],
                     apo['a_total'])
    fin['efka'] = efka
    year = str(par['per'])[:4]
    taxes = calc_tax_monthly(year, efka['amount-after-efka'], par['paidia'])
    fin['taxes'] = taxes
    return fin
Exemplo n.º 14
0
Arquivo: erg.py Projeto: tedlaz/efka
 def __init__(self, ergazomenos=0, ergodotis=0):
     self.ergazomenos = rnd(ergazomenos)
     self.ergodotis = rnd(ergodotis)
Exemplo n.º 15
0
Arquivo: erg.py Projeto: tedlaz/efka
 def total(self):
     return rnd(self.ergazomenos + self.ergodotis)
Exemplo n.º 16
0
Arquivo: erg.py Projeto: tedlaz/efka
 def __add__(self, another):
     enos = rnd(self.ergazomenos + another.ergazomenos)
     etis = rnd(self.ergodotis + another.ergodotis)
     return Cost(enos, etis)
Exemplo n.º 17
0
 def test_rnd_02(self):
     self.assertEqual(utils.rnd(10.554, 2), 10.55)
Exemplo n.º 18
0
def randompastelcolor():
    hue = rnd(360)
    lightness = rnd(0.8, 0.9)
    saturation = rnd(0.5, 1)
    return colorspace.hsl2rgb1(hue, saturation, lightness)
Exemplo n.º 19
0
def randomcolor(transfrom=None, transto=None):
    if transfrom is None:
        return rnd(1), rnd(1), rnd(1)
    else:
        return rnd(1), rnd(1), rnd(1), rnd(transfrom, transto)