New data
This commit is contained in:
@@ -16,9 +16,9 @@ from .products import Products
|
||||
from .members_products import MembersProducts
|
||||
from .members_actions import MembersActions
|
||||
from .members_pending import MembersPending
|
||||
|
||||
from .products_details import ProductsDetails
|
||||
|
||||
__all__ = ['Members','Customer', 'Account', 'Products',
|
||||
'MembersProducts', 'MembersActions', 'MembersPending', 'Loan', 'Transaction', 'Repayment',
|
||||
'MembersProducts', 'MembersActions', 'MembersPending', 'ProductsDetails', 'Loan', 'Transaction', 'Repayment',
|
||||
'LoanCharge', 'Offer', 'Charge', 'RACCheck', 'LoanRepaymentSchedule',
|
||||
'TransactionOffer', 'RepaymentsData', 'Salary']
|
||||
@@ -36,9 +36,8 @@ class MembersProducts(db.Model):
|
||||
@classmethod
|
||||
def get_member_productlist_by_member_id(cls, member_id):
|
||||
member_products = cls.query.filter_by(member_id=str(member_id))
|
||||
|
||||
if not member_products:
|
||||
raise ValueError(f"Products for member_id = {member_id} not found")
|
||||
return None
|
||||
return member_products
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from itertools import product
|
||||
from app.extensions import db
|
||||
from app.models.customer import Customer
|
||||
from app.models.account import Account
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import relationship
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from sqlalchemy import and_, or_, not_
|
||||
from sqlalchemy.sql import func
|
||||
import json
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class ProductsDetails(db.Model):
|
||||
__tablename__ = 'products'
|
||||
|
||||
id = db.Column(
|
||||
db.Integer,
|
||||
primary_key=True,
|
||||
autoincrement=True,
|
||||
)
|
||||
|
||||
product_id = db.Column(db.String(25), nullable=False)
|
||||
details = db.Column(db.String(5000), nullable=False)
|
||||
added = db.Column(db.DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_product_details_with_product_id(cls, product_id):
|
||||
"""
|
||||
Get customer's active loans by loan_id.
|
||||
"""
|
||||
productItem = cls.query.filter_by(product_id = product_id).first()
|
||||
if not productItem:
|
||||
raise ValueError(f"pProduct with ID {product_id} does not exist.")
|
||||
return productItem
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Convert the Loan object to a dictionary format for JSON serialization.
|
||||
"""
|
||||
return {
|
||||
'id': self.id,
|
||||
'product_id': self.product_id,
|
||||
'details': self.details,
|
||||
'added': self.added
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Products {self.id}>'
|
||||
Reference in New Issue
Block a user