EGYADMIN commited on
Commit
c9676bf
·
verified ·
1 Parent(s): 21826c6

Update modules/pricing/pricing_app.py

Browse files
Files changed (1) hide show
  1. modules/pricing/pricing_app.py +60 -1
modules/pricing/pricing_app.py CHANGED
@@ -453,5 +453,64 @@ class PricingApp:
453
  )
454
 
455
  if st.button("إضافة البند", key="add_boq_item"):
456
- if new_code and ne
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  (Content truncated due to size limit. Use line ranges to read in chunks)
 
453
  )
454
 
455
  if st.button("إضافة البند", key="add_boq_item"):
456
+ if new_code and new_description and new_quantity > 0 and new_unit_price > 0:
457
+ # حساب السعر الإجمالي
458
+ new_total_price = new_quantity * new_unit_price
459
+
460
+ # إضافة بند جديد
461
+ new_id = max([item['id'] for item in st.session_state.bill_of_quantities]) + 1
462
+ st.session_state.bill_of_quantities.append({
463
+ 'id': new_id,
464
+ 'code': new_code,
465
+ 'description': new_description,
466
+ 'unit': new_unit,
467
+ 'quantity': new_quantity,
468
+ 'unit_price': new_unit_price,
469
+ 'total_price': new_total_price,
470
+ 'category': new_category
471
+ })
472
+
473
+ st.success(f"تمت إضافة البند بنجاح: {new_description}")
474
+ # تحديث الصفحة لعرض البند الجديد
475
+ st.rerun()
476
+ else:
477
+ st.error("يرجى إدخال جميع البيانات المطلوبة بشكل صحيح")
478
+
479
+ # عرض ملخص جدول الكميات
480
+ st.markdown("### ملخص جدول الكميات")
481
+
482
+ # تجميع البيانات حسب الفئة
483
+ category_totals = {}
484
+ for item in st.session_state.bill_of_quantities:
485
+ category = item['category']
486
+ if category in category_totals:
487
+ category_totals[category] += item['total_price']
488
+ else:
489
+ category_totals[category] = item['total_price']
490
+
491
+ # إنشاء DataFrame للرسم البياني
492
+ category_df = pd.DataFrame({
493
+ 'الفئة': list(category_totals.keys()),
494
+ 'المبلغ': list(category_totals.values())
495
+ })
496
+
497
+ # ترتيب البيانات تنازليًا حسب المبلغ
498
+ category_df = category_df.sort_values('المبلغ', ascending=False)
499
+
500
+ # إنشاء رسم بياني شريطي
501
+ fig = px.bar(
502
+ category_df,
503
+ x='الفئة',
504
+ y='المبلغ',
505
+ title='إجمالي تكلفة البنود حسب الفئة',
506
+ color='الفئة',
507
+ text_auto=True
508
+ )
509
+
510
+ st.plotly_chart(fig, use_container_width=True)
511
+
512
+ # حساب إجمالي جدول الكميات
513
+ total_boq = sum(item['total_price'] for item in st.session_state.bill_of_quantities)
514
+
515
+ st.markdown(f"### إجمالي جدول الكميات: **{total_boq:,.0f} ريال**")
516
  (Content truncated due to size limit. Use line ranges to read in chunks)