add billing process
This commit is contained in:
@@ -20,9 +20,9 @@ class GoodsReception:
|
|||||||
expand=True
|
expand=True
|
||||||
)
|
)
|
||||||
self.product_mesure_unit.value = 'kg'
|
self.product_mesure_unit.value = 'kg'
|
||||||
self.product_quantity = ft.TextField(label="Cantitate")
|
self.product_quantity = ft.TextField(label="Cantitate (Numar de unitati)")
|
||||||
self.product_price = ft.TextField(label="Pret")
|
self.product_price = ft.TextField(label="Pret pe unitate")
|
||||||
self.product_vat = ft.TextField(label="TVA (0 pentru neplatitor de TVA)", value="0")
|
self.product_vat = ft.TextField(label="TVA% (0 pentru neplatitor de TVA)", value="0")
|
||||||
|
|
||||||
self.bill_number = ft.TextField(label="Serie si numar")
|
self.bill_number = ft.TextField(label="Serie si numar")
|
||||||
self.bill_date = ft.TextField(label="Data", read_only=True, expand=True)
|
self.bill_date = ft.TextField(label="Data", read_only=True, expand=True)
|
||||||
@@ -80,7 +80,8 @@ class GoodsReception:
|
|||||||
self.all_bills,
|
self.all_bills,
|
||||||
self.on_add_product_btn_click,
|
self.on_add_product_btn_click,
|
||||||
self.on_edit_provider_bill_btn_click,
|
self.on_edit_provider_bill_btn_click,
|
||||||
self.on_delete_provider_bill_btn_click
|
self.on_delete_provider_bill_btn_click,
|
||||||
|
self.on_view_list_btn_click
|
||||||
),
|
),
|
||||||
spacing=10,
|
spacing=10,
|
||||||
expand=True,
|
expand=True,
|
||||||
@@ -107,15 +108,110 @@ class GoodsReception:
|
|||||||
|
|
||||||
self.edit_item = None
|
self.edit_item = None
|
||||||
|
|
||||||
self.placeholder = ft.Column()
|
self.add_product_dialog = ft.AlertDialog(
|
||||||
|
title=ft.Text("Adauga produs"),
|
||||||
self.add_group = ft.Row(
|
content=ft.Column(
|
||||||
self.product_name,
|
[
|
||||||
self.product_quantity,
|
self.product_name,
|
||||||
self.product_mesure_unit,
|
self.product_quantity,
|
||||||
self.product_quantity,
|
self.product_mesure_unit,
|
||||||
|
self.product_price,
|
||||||
|
self.product_vat
|
||||||
|
],
|
||||||
|
width=400,
|
||||||
|
height=300
|
||||||
|
),
|
||||||
|
actions=[
|
||||||
|
ft.Button(
|
||||||
|
"Salveaza",
|
||||||
|
icon=ft.Icons.SAVE,
|
||||||
|
on_click=self.on_save_product_btn_click
|
||||||
|
),
|
||||||
|
ft.TextButton(
|
||||||
|
"Anuleaza",
|
||||||
|
on_click=self.on_cancel_product_btn_click
|
||||||
|
)
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.selected_bill = None
|
||||||
|
|
||||||
|
self.products_table = ft.DataTable(
|
||||||
|
columns=[
|
||||||
|
ft.DataColumn(ft.Text("Produs")),
|
||||||
|
ft.DataColumn(ft.Text("Cantitate")),
|
||||||
|
ft.DataColumn(ft.Text("Unitate\nde masura")),
|
||||||
|
ft.DataColumn(ft.Text("Pret\nfara TVA")),
|
||||||
|
ft.DataColumn(ft.Text("Procent\nTVA(%)")),
|
||||||
|
ft.DataColumn(ft.Text("Pret\nproduse")),
|
||||||
|
ft.DataColumn(ft.Text("Valoare\nTVA")),
|
||||||
|
ft.DataColumn(ft.Text("Pret\nfinal")),
|
||||||
|
],
|
||||||
|
rows=[]
|
||||||
|
)
|
||||||
|
|
||||||
|
self.placeholder = ft.Column([self.products_table])
|
||||||
|
|
||||||
|
def show_bill_products(self):
|
||||||
|
all_products = self.bulk_products_manager.get_products_by_bill_id(self.selected_bill['id'])[::-1]
|
||||||
|
print(all_products)
|
||||||
|
self.products_table.rows.clear()
|
||||||
|
for product in all_products:
|
||||||
|
print(product)
|
||||||
|
price = round((product['price']*product['quantity'])*product['vat']/100+(product['price']*product['quantity']),2)
|
||||||
|
product_price = product['price']*product['quantity']
|
||||||
|
vat_value = (product['price']*product['quantity'])*product['vat']/100
|
||||||
|
self.products_table.rows.append(
|
||||||
|
ft.DataRow(
|
||||||
|
cells=[
|
||||||
|
ft.DataCell(ft.Text(product['name'])),
|
||||||
|
ft.DataCell(ft.Text(product['quantity'])),
|
||||||
|
ft.DataCell(ft.Text(product['mesure_unit'])),
|
||||||
|
ft.DataCell(ft.Text(product['price'])),
|
||||||
|
ft.DataCell(ft.Text(product['vat'])),
|
||||||
|
ft.DataCell(ft.Text(product_price)),
|
||||||
|
ft.DataCell(ft.Text(vat_value)),
|
||||||
|
ft.DataCell(ft.Text(price)),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.products_table.update()
|
||||||
|
|
||||||
|
def on_save_product_btn_click(self, e):
|
||||||
|
name = self.product_name.value
|
||||||
|
quantity = self.product_quantity.value
|
||||||
|
mesure_unit = self.product_mesure_unit.value
|
||||||
|
price = self.product_price.value
|
||||||
|
vat = self.product_vat.value
|
||||||
|
self.bulk_products_manager.add_bulk_products_product(
|
||||||
|
bill_id=self.selected_bill['id'],
|
||||||
|
name=name,
|
||||||
|
mesure_unit=mesure_unit,
|
||||||
|
quantity=quantity,
|
||||||
|
price=price,
|
||||||
|
vat=vat
|
||||||
|
)
|
||||||
|
self.reset_values()
|
||||||
|
self.page.close(self.add_product_dialog)
|
||||||
|
self.show_bill_products()
|
||||||
|
|
||||||
|
def on_cancel_product_btn_click(self, e):
|
||||||
|
self.reset_values()
|
||||||
|
self.page.close(self.add_product_dialog)
|
||||||
|
|
||||||
|
def reset_values(self):
|
||||||
|
self.product_name.value = ''
|
||||||
|
self.product_name.update()
|
||||||
|
self.product_quantity.value = ''
|
||||||
|
self.product_quantity.update()
|
||||||
|
self.product_mesure_unit.value = 'kg'
|
||||||
|
self.product_mesure_unit.update()
|
||||||
|
self.product_price.value = ''
|
||||||
|
self.product_price.update()
|
||||||
|
self.product_vat.value = '0'
|
||||||
|
self.product_vat.update()
|
||||||
|
|
||||||
|
|
||||||
def on_confirm_delete_bill_btn_click(self, e):
|
def on_confirm_delete_bill_btn_click(self, e):
|
||||||
self.page.close(self.delete_bill_dialog)
|
self.page.close(self.delete_bill_dialog)
|
||||||
self.bill_manager.remove(self.delete_item_id)
|
self.bill_manager.remove(self.delete_item_id)
|
||||||
@@ -128,8 +224,13 @@ class GoodsReception:
|
|||||||
self.delete_item_id = None
|
self.delete_item_id = None
|
||||||
|
|
||||||
def on_add_product_btn_click(self, item):
|
def on_add_product_btn_click(self, item):
|
||||||
|
self.selected_bill = item
|
||||||
self.page.open(self.add_product_dialog)
|
self.page.open(self.add_product_dialog)
|
||||||
|
|
||||||
|
def on_view_list_btn_click(self, item):
|
||||||
|
self.selected_bill = item
|
||||||
|
self.show_bill_products()
|
||||||
|
|
||||||
def on_edit_provider_bill_btn_click(self, item):
|
def on_edit_provider_bill_btn_click(self, item):
|
||||||
self.edit_item = item
|
self.edit_item = item
|
||||||
self.bill_number.value = item['number']
|
self.bill_number.value = item['number']
|
||||||
@@ -147,7 +248,7 @@ class GoodsReception:
|
|||||||
if provider['id'] == id:
|
if provider['id'] == id:
|
||||||
return provider['provider_name']
|
return provider['provider_name']
|
||||||
|
|
||||||
def create_bill_list(self, items, on_click_handler, on_click_handler2, on_click_handler3):
|
def create_bill_list(self, items, on_click_handler, on_click_handler2, on_click_handler3, on_click_handler4):
|
||||||
"""Helper to create list items for a column."""
|
"""Helper to create list items for a column."""
|
||||||
return [
|
return [
|
||||||
ft.Container(
|
ft.Container(
|
||||||
@@ -171,6 +272,10 @@ class GoodsReception:
|
|||||||
),
|
),
|
||||||
ft.Row(
|
ft.Row(
|
||||||
[
|
[
|
||||||
|
ft.IconButton(
|
||||||
|
icon=ft.Icons.PREVIEW,
|
||||||
|
on_click=lambda e, id=item: on_click_handler4(id)
|
||||||
|
),
|
||||||
ft.IconButton(
|
ft.IconButton(
|
||||||
icon=ft.Icons.EDIT,
|
icon=ft.Icons.EDIT,
|
||||||
on_click=lambda e, id=item: on_click_handler2(id),
|
on_click=lambda e, id=item: on_click_handler2(id),
|
||||||
@@ -179,7 +284,7 @@ class GoodsReception:
|
|||||||
icon=ft.Icons.DELETE,
|
icon=ft.Icons.DELETE,
|
||||||
on_click=lambda e, id=item['id']: on_click_handler3(id),
|
on_click=lambda e, id=item['id']: on_click_handler3(id),
|
||||||
icon_color=ft.Colors.RED,
|
icon_color=ft.Colors.RED,
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
|
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
|
||||||
expand=True
|
expand=True
|
||||||
@@ -260,7 +365,8 @@ class GoodsReception:
|
|||||||
list_value,
|
list_value,
|
||||||
self.on_add_product_btn_click,
|
self.on_add_product_btn_click,
|
||||||
self.on_edit_provider_bill_btn_click,
|
self.on_edit_provider_bill_btn_click,
|
||||||
self.on_delete_provider_bill_btn_click
|
self.on_delete_provider_bill_btn_click,
|
||||||
|
self.on_view_list_btn_click
|
||||||
)
|
)
|
||||||
self.bills_list.update()
|
self.bills_list.update()
|
||||||
|
|
||||||
@@ -285,7 +391,8 @@ class GoodsReception:
|
|||||||
[
|
[
|
||||||
self.bills_list,
|
self.bills_list,
|
||||||
self.placeholder
|
self.placeholder
|
||||||
]
|
],
|
||||||
|
vertical_alignment=ft.CrossAxisAlignment.START
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ class OrdersPage:
|
|||||||
self.phone.update()
|
self.phone.update()
|
||||||
self.status.value = self.selected_user['status']
|
self.status.value = self.selected_user['status']
|
||||||
self.status.update()
|
self.status.update()
|
||||||
|
#self.date.value = item['']
|
||||||
for product in self.selected_order_products:
|
for product in self.selected_order_products:
|
||||||
name_label = ft.Text(
|
name_label = ft.Text(
|
||||||
"Denumire produs",
|
"Denumire produs",
|
||||||
|
|||||||
@@ -82,16 +82,17 @@ class BulkProducts:
|
|||||||
return result
|
return result
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_product_by_bill_id(self, bill_id):
|
def get_products_by_bill_id(self, bill_id):
|
||||||
with sqlite3.connect(self.db_path) as conn:
|
with sqlite3.connect(self.db_path) as conn:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
SELECT * FROM bulk_products WHERE bill_id = ?
|
SELECT * FROM bulk_products WHERE bill_id = ?
|
||||||
""",(bill_id, ))
|
""",(bill_id, ))
|
||||||
row = cursor.fetchone()
|
rows = cursor.fetchall()
|
||||||
result = []
|
result = []
|
||||||
if row:
|
if rows:
|
||||||
result = {
|
for row in rows:
|
||||||
|
buffer = {
|
||||||
"id": row[0],
|
"id": row[0],
|
||||||
"bill_id": row[1],
|
"bill_id": row[1],
|
||||||
"name": row[2],
|
"name": row[2],
|
||||||
@@ -101,8 +102,9 @@ class BulkProducts:
|
|||||||
"vat": row[6],
|
"vat": row[6],
|
||||||
"created_at": row[7]
|
"created_at": row[7]
|
||||||
}
|
}
|
||||||
|
result.append(buffer)
|
||||||
return result
|
return result
|
||||||
return None
|
return []
|
||||||
|
|
||||||
def remove(self, id):
|
def remove(self, id):
|
||||||
with sqlite3.connect(self.db_path) as conn:
|
with sqlite3.connect(self.db_path) as conn:
|
||||||
|
|||||||
Reference in New Issue
Block a user