Example #1
0
def checkout():
    sale = Sale(request.form)
    configuration = config.Config()
    cart = ShoppingCart()
    cart_items = cart.cart_items
    clients = Client.get_all_clients()
    branchId = sale.branchId
    if request.form['Discount'] is not '':
        sale.apply_discount()

    if sale.is_valid(branchId):
        sale.create_sale(cart_items, branchId)
        cart.update_cart_items_stock(branchId)
        cart.clear_cart()
        sale.save_sale_ticket(cart_items)
        sale.print_sale_ticket(cart_items)
        Alert.raise_success_alert('Sale Created')
        return render_template('cart/checkout.html',
                               sale=sale,
                               configuration=configuration)

    return render_template('cart/info.html',
                           cart=cart,
                           cart_items=cart_items,
                           clients=clients,
                           configuration=configuration)
Example #2
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        user = User(request.form)
        if user.is_valid():
            user.create_user()
            Alert.raise_success_alert('User Created')

    return render_template('users/create.html', configuration=configuration)
Example #3
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        client = Client(request.form)
        if client.is_valid_create():
            client.create_client()
            Alert.raise_success_alert('Client Created')

    return render_template('clients/create.html', configuration=configuration)
Example #4
0
 def _is_valid_login(user, password):
     if user is None:
         Alert.raise_danger_alert('Incorrect User')
         return False
     elif not check_password_hash(user['password'], password):
         Alert.raise_danger_alert('Incorrect Password')
         return False
     else:
         return True
Example #5
0
    def is_valid_create(self):
        if self._client_exist():
            Alert.raise_danger_alert('Client Exist')
        elif not self._is_valid():
            pass
        else:
            return True

        return False
Example #6
0
 def _is_valid(self):
     if not self._name_is_valid():
         Alert.raise_danger_alert('Invalid Name, Please use only letters')
     elif not self._contact_phone_is_valid():
         Alert.raise_danger_alert(
             'Invalid Phone Number, Please use only numbers')
     else:
         return True
     return False
Example #7
0
def dashboard():
    configuration = config.Config()

    if g.user is None:
        Alert.raise_danger_alert('Not Logged In')
        return redirect(url_for('authentication.login'))

    else:
        return render_template('dashboard/index.html',
                               configuration=configuration)
Example #8
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        category = Category(request.form)
        if category.is_valid():
            category.create_category()
            Alert.raise_success_alert('Category Created')

    return render_template('categories/create.html',
                           configuration=configuration)
Example #9
0
def update(id):
    configuration = config.Config()
    if request.method == 'POST':
        user = User(request.form)
        user.update_user(id)
        Alert.raise_success_alert('User Updated')

    else:
        user = User.get_user_by_id(id)

    return render_template('users/update.html', user=user, configuration=configuration)
Example #10
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        article = Article(request.form)
        if article._is_valid():
            article.create_article()
            Alert.raise_success_alert('Article Created')
    categories = Category.get_all_categories()

    return render_template('articles/create.html',
                           categories=categories,
                           configuration=configuration)
Example #11
0
def update(id):
    configuration = config.Config()
    if request.method == 'POST':
        client = Client(request.form)
        if client.is_valid_update():
            client.update_client(id)
            Alert.raise_success_alert('Client Updated')
    else:
        client = Client.get_client_by_id(id)

    return render_template('clients/update.html',
                           client=client,
                           configuration=configuration)
Example #12
0
def update(id):
    configuration = config.Config()
    if request.method == 'POST':
        category = Category(request.form)
        if category.is_valid():
            category.update_category(id)
            Alert.raise_success_alert('Category Updated')
    else:
        category = Category.get_category_by_id(id)

    return render_template('categories/update.html',
                           category=category,
                           configuration=configuration)
Example #13
0
def update(id):
    configuration = config.Config()
    article = Article.get_article_by_id(id)

    if request.method == 'POST':
        article = Article(request.form)
        article.update_article(id)
        Alert.raise_success_alert('Article Updated')

    categories = Category.get_all_categories()
    return render_template('articles/update.html',
                           article=article,
                           categories=categories,
                           configuration=configuration)
Example #14
0
 def is_valid(self, branchId):
     cart = ShoppingCart()
     if self.operationType == 'credit' and not self._client_has_discount():
         Alert.raise_danger_alert("Client has no Discount")
         return False
     elif self._is_empty_sale():
         Alert.raise_danger_alert('Empty Sale')
         return False
     elif self.payMethod == 'Cash' and not self._cash_is_enough():
         Alert.raise_danger_alert('Cash is Not Enought')
         return False
     elif not cart.there_is_enought_stock(branchId):
         Alert.raise_danger_alert('Not Enought Stock')
         return False
     else:
         return True
Example #15
0
 def _is_valid(self):
     if self._article_name_exists():
         Alert.raise_danger_alert("Article Exist")
         return False
     else:
         return True
Example #16
0
 def is_valid(self):
     if self._category_exist():
         Alert.raise_danger_alert('Category Exist')
         return False
     else:
         return True
Example #17
0
 def is_valid(self):
     if self._user_exist():
         Alert.raise_danger_alert('User Exist')
         return False
     else:
         return True