def factory_fee_model( fee_code: str, amount: int): """Return the fee code model.""" fee_code_master = FeeCode(code=fee_code, amount=amount) fee_code_master.save() return fee_code_master
def create_linked_data(filing_type_code: str, corp_type_code: str, fee_code: str): """Return a valid fee schedule object, creates the related objects first.""" corp_type = CorpType(code=corp_type_code, description='TEST') corp_type.save() fee_code_master = FeeCode(code=fee_code, amount=100) fee_code_master.save() filing_type = FilingType(code=filing_type_code, description='TEST') filing_type.save()
def test_fee_schedule_with_service_fees_for_basic_user(session): """Assert that fee with service fees can be retrieved.""" # Create a transaction fee tran_fee_code = 'TRAN' corp_type_code = 'XCORP' fee_code = 'FEE01' fee_code_master = FeeCode(code=tran_fee_code, amount=10) fee_code_master.save() fee_code_master = FeeCode(code=fee_code, amount=100) fee_code_master.save() corp_type = CorpType(code=corp_type_code, service_fee_code=tran_fee_code, description='TEST') corp_type.save() filing_type = FilingType(code=FILING_TYPE_CODE, description='TEST') filing_type.save() fee_schedule = services.FeeSchedule() fee_schedule.filing_type_code = FILING_TYPE_CODE fee_schedule.corp_type_code = corp_type_code fee_schedule.fee_code = fee_code fee_schedule.fee_start_date = date.today() fee_schedule.save() fee_schedule = services.FeeSchedule.find_by_corp_type_and_filing_type( corp_type=corp_type_code, filing_type_code=FILING_TYPE_CODE, valid_date=date.today(), include_service_fees=False) assert fee_schedule.service_fees == 10
def test_feecode_find_by_invalid_fee_code(session): """Assert that the feecode can not be found, with invalid code.""" feecode = factory_feecode('EN000X', 100) session.add(feecode) session.commit() b = FeeCode.find_by_code('EN000Y') assert b is None
def test_feecode_find_by_fee_code(session): """Assert that the feecode can be found by code.""" feecode = factory_feecode('EN000X', 100) session.add(feecode) session.commit() b = FeeCode.find_by_fee_code('EN000X') assert b is not None
def calculate_service_fees(fee_schedule_model: FeeScheduleModel, account_fee: AccountFeeModel, **kwargs): """Calculate service_fees fees.""" current_app.logger.debug('<calculate_service_fees') user: UserContext = kwargs['user'] service_fees: float = 0 # TODO for system accounts with role EXCLUDE_SERVICE_FEES, do not charge service fees for now. # Handle it properly later if not user.is_staff() and \ not (user.is_system() and Role.EXCLUDE_SERVICE_FEES.value in user.roles) \ and fee_schedule_model.fee.amount > 0 and fee_schedule_model.service_fee: service_fee = (account_fee.service_fee if account_fee else None) or fee_schedule_model.service_fee if service_fee: service_fees = FeeCodeModel.find_by_code( service_fee.code).amount return service_fees
def create_linked_data(filing_type_code: str, corp_type_code: str, fee_code: str, priority_fee: str = None, future_effective_fee: str = None): """Return a valid fee schedule object, creates the related objects first.""" corp_type = CorpType(code=corp_type_code, description='TEST') corp_type.save() fee_code_master = FeeCode(code=fee_code, amount=100) fee_code_master.save() if priority_fee: priority_fee_code = FeeCode(code=priority_fee, amount=10) priority_fee_code.save() if future_effective_fee: future_effective_fee_code = FeeCode(code=future_effective_fee, amount=20) future_effective_fee_code.save() filing_type = FilingType(code=filing_type_code, description='TEST') filing_type.save()
def factory_feecode(fee_code: str, amount: int): """Return a valid FeeCode object.""" return FeeCode(code=fee_code, amount=amount)