class AccountRecordsShallowCopy: id: int uuid: str iban: str currency_value: Decimal remainder_balance: Decimal bank_date: datetime process_type: int receive_debit: int receive_debit_uuid: str living_space_id: int living_space_uuid: str build_id: int build_uuid: str build_parts_id: int build_parts_uuid: str class BuildDecisionBookPaymentsShallowCopy: def __init__(self): self.id: int self.uuid: str self.payment_plan_time_periods: str self.process_date: datetime self.payment_amount: float self.currency: str self.payment_types_id: int self.payment_types_uu_id: str self.period_time: str self.process_date_y: int self.process_date_m: int self.build_decision_book_item_id: int self.build_decision_book_item_uu_id: str self.build_parts_id: int self.build_parts_uu_id: str self.decision_book_project_id: int self.decision_book_project_uu_id: str self.account_records_id: int self.account_records_uu_id: str @classmethod def convert_row_to_shallow_copy(cls, row: BuildDecisionBookPayments): shallow_copy = cls() shallow_copy.id = row.id shallow_copy.uuid = str(row.uu_id) shallow_copy.ref_id = str(row.ref_id) shallow_copy.payment_plan_time_periods = row.payment_plan_time_periods shallow_copy.process_date = row.process_date shallow_copy.payment_amount = row.payment_amount shallow_copy.currency = row.currency shallow_copy.payment_types_id = row.payment_types_id shallow_copy.payment_types_uu_id = str(row.payment_types_uu_id) shallow_copy.period_time = row.period_time shallow_copy.process_date_y = row.process_date_y shallow_copy.process_date_m = row.process_date_m shallow_copy.build_decision_book_item_id = row.build_decision_book_item_id shallow_copy.build_decision_book_item_uu_id = str(row.build_decision_book_item_uu_id) shallow_copy.build_parts_id = row.build_parts_id shallow_copy.build_parts_uu_id = str(row.build_parts_uu_id) shallow_copy.decision_book_project_id = row.decision_book_project_id shallow_copy.decision_book_project_uu_id = str(row.decision_book_project_uu_id) shallow_copy.account_records_id = row.account_records_id shallow_copy.account_records_uu_id = str(row.account_records_uu_id) return shallow_copy class ApiEnumDropdownShallowCopy: id: int uuid: str enum_class: str key: str value: str def __init__(self, id: int, uuid: str, enum_class: str, key: str, value: str): self.id = id self.uuid = uuid self.enum_class = enum_class self.key = key self.value = value class BuildDuesTypes: def __init__(self): self.debit: ApiEnumDropdownShallowCopy = None self.add_debit: ApiEnumDropdownShallowCopy = None self.renovation: ApiEnumDropdownShallowCopy = None self.lawyer_expence: ApiEnumDropdownShallowCopy = None self.service_fee: ApiEnumDropdownShallowCopy = None self.information: ApiEnumDropdownShallowCopy = None class PaymentsRows: def __init__(self): self.debit: list[BuildDecisionBookPaymentsShallowCopy] = [] self.add_debit: list[BuildDecisionBookPaymentsShallowCopy] = [] self.renovation: list[BuildDecisionBookPaymentsShallowCopy] = [] self.lawyer_expence: list[BuildDecisionBookPaymentsShallowCopy] = [] self.service_fee: list[BuildDecisionBookPaymentsShallowCopy] = [] self.information: list[BuildDecisionBookPaymentsShallowCopy] = [] class PaidRow: def __init__(self, uuid: str, amount: Decimal, closed: bool, left_payment: Decimal | None = None): self.uuid: str = uuid self.amount: Decimal = amount self.closed: bool = closed self.left_payment: Decimal = Decimal(0) if not self.closed: self.left_payment = left_payment if not self.check_transaction_is_valid(): raise ValueError(f"Record uuid: {self.uuid} tries to pay more than its debt in records.") def check_transaction_is_valid(self): with BuildDecisionBookPayments.new_session() as session: BuildDecisionBookPayments.set_session(session) payment_row = BuildDecisionBookPayments.query.filter( BuildDecisionBookPayments.ref_id == self.uuid, cast(BuildDecisionBookPayments.uu_id, String) == cast(BuildDecisionBookPayments.ref_id, String), BuildDecisionBookPayments.account_records_id.is_(None), ).first() if not payment_row: return False already_paid = BuildDecisionBookPayments.query.filter( BuildDecisionBookPayments.ref_id == self.uuid, cast(BuildDecisionBookPayments.uu_id, String) != cast(BuildDecisionBookPayments.ref_id, String), BuildDecisionBookPayments.account_records_id.isnot(None), ).all() already_paid = sum([abs(row.payment_amount) for row in already_paid]) left_amount = abs(payment_row.payment_amount) - abs(already_paid) if left_amount < self.amount: print(f"left_amount: {left_amount}, self.amount: {self.amount}. Record uuid: {self.uuid} tries to pay more than its debt in records.") return False return True def get_dict(self): return { "uuid": self.uuid, "amount": self.amount, "closed": self.closed, "left_payment": self.left_payment, } def __str__(self): return f"{self.uuid} = Paid: {self.amount} Left: {self.left_payment}" class PaymentActions: def __init__(self, initial_money: Decimal): self.initial_money: Decimal = initial_money self.consumed_money: Decimal = Decimal(0) self.remaining_money: Decimal = self.initial_money self.paid_list: list[PaidRow] = [] def is_money_consumed(self): return self.consumed_money == self.initial_money def consume(self, payment_due: Decimal, payment_uuid: str): left_payment = Decimal(0) if self.remaining_money >= payment_due: self.consumed_money += abs(payment_due) self.remaining_money = abs(self.remaining_money) - abs(payment_due) paid_row = PaidRow(payment_uuid, payment_due, True) self.paid_list.append(paid_row) elif self.remaining_money < payment_due: self.consumed_money = self.remaining_money self.remaining_money = Decimal(0) left_payment = abs(payment_due) - abs(self.consumed_money) paid_row = PaidRow(payment_uuid, self.consumed_money, False, left_payment) self.paid_list.append(paid_row) return left_payment def row_iteration_account_records(): shallow_copy_list = [] build_dues_types = BuildDuesTypes() with ApiEnumDropdown.new_session() as session: ApiEnumDropdown.set_session(session) debit_enum_shallow = ApiEnumDropdown.query.filter_by(enum_class="BuildDuesTypes", key="BDT-D").first() # Debit add_debit_enum_shallow = ApiEnumDropdown.query.filter_by(enum_class="BuildDuesTypes", key="BDT-A").first() # Add Debit renovation_enum_shallow = ApiEnumDropdown.query.filter_by(enum_class="BuildDuesTypes", key="BDT-R").first() # Renovation late_payment_enum_shallow = ApiEnumDropdown.query.filter_by(enum_class="BuildDuesTypes", key="BDT-L").first() # Lawyer expence service_fee_enum_shallow = ApiEnumDropdown.query.filter_by(enum_class="BuildDuesTypes", key="BDT-S").first() # Service fee information_enum_shallow = ApiEnumDropdown.query.filter_by(enum_class="BuildDuesTypes", key="BDT-I").first() # Information build_dues_types.debit = ApiEnumDropdownShallowCopy( debit_enum_shallow.id, str(debit_enum_shallow.uu_id), debit_enum_shallow.enum_class, debit_enum_shallow.key, debit_enum_shallow.value ) build_dues_types.add_debit = ApiEnumDropdownShallowCopy( add_debit_enum_shallow.id, str(add_debit_enum_shallow.uu_id), add_debit_enum_shallow.enum_class, add_debit_enum_shallow.key, add_debit_enum_shallow.value ) build_dues_types.renovation = ApiEnumDropdownShallowCopy( renovation_enum_shallow.id, str(renovation_enum_shallow.uu_id), renovation_enum_shallow.enum_class, renovation_enum_shallow.key, renovation_enum_shallow.value ) build_dues_types.lawyer_expence = ApiEnumDropdownShallowCopy( late_payment_enum_shallow.id, str(late_payment_enum_shallow.uu_id), late_payment_enum_shallow.enum_class, late_payment_enum_shallow.key, late_payment_enum_shallow.value ) build_dues_types.service_fee = ApiEnumDropdownShallowCopy( service_fee_enum_shallow.id, str(service_fee_enum_shallow.uu_id), service_fee_enum_shallow.enum_class, service_fee_enum_shallow.key, service_fee_enum_shallow.value ) build_dues_types.information = ApiEnumDropdownShallowCopy( information_enum_shallow.id, str(information_enum_shallow.uu_id), information_enum_shallow.enum_class, information_enum_shallow.key, information_enum_shallow.value ) with AccountRecords.new_session() as session: AccountRecords.set_session(session) account_records: list[AccountRecords] = AccountRecords.query.filter( AccountRecords.approved_record == True, AccountRecords.living_space_id.isnot(None), (AccountRecords.remainder_balance + AccountRecords.currency_value) > 0, cast(AccountRecords.bank_date, Date) > cast("2022-01-01", Date), # AccountRecords.currency_value > 0, ).all() for account_record in account_records: shallow_copy = AccountRecordsShallowCopy() shallow_copy.id = account_record.id shallow_copy.uuid = str(account_record.uu_id) shallow_copy.iban = account_record.iban shallow_copy.currency_value = account_record.currency_value shallow_copy.remainder_balance = account_record.remainder_balance shallow_copy.bank_date = arrow.get(account_record.bank_date).datetime shallow_copy.process_type = account_record.process_type shallow_copy.receive_debit = account_record.receive_debit shallow_copy.receive_debit_uuid = str(account_record.receive_debit_uu_id) shallow_copy.living_space_id = account_record.living_space_id shallow_copy.living_space_uuid = str(account_record.living_space_uu_id) shallow_copy.build_id = account_record.build_id shallow_copy.build_uuid = str(account_record.build_uu_id) shallow_copy.build_parts_id = account_record.build_parts_id shallow_copy.build_parts_uuid = str(account_record.build_parts_uu_id) shallow_copy_list.append(shallow_copy) return shallow_copy_list, build_dues_types def check_payment_stage_debit(account_shallow_copy: AccountRecordsShallowCopy, build_dues_types: BuildDuesTypes, payments_rows: PaymentsRows, payment_actions: PaymentActions): account_records_bank_date = account_shallow_copy.bank_date for payment_row in payments_rows.debit: payment_actions.consume(payment_row.payment_amount, payment_row.uuid) if payment_actions.is_money_consumed(): return return def check_payment_stage_add_debit(account_shallow_copy: AccountRecordsShallowCopy, build_dues_types: BuildDuesTypes, payments_rows: PaymentsRows, payment_actions: PaymentActions): account_records_bank_date = account_shallow_copy.bank_date for payment_row in payments_rows.add_debit: payment_actions.consume(payment_row.payment_amount, payment_row.uuid) if payment_actions.is_money_consumed(): return return def check_payment_stage_renovation(account_shallow_copy: AccountRecordsShallowCopy, build_dues_types: BuildDuesTypes, payments_rows: PaymentsRows, payment_actions: PaymentActions): account_records_bank_date = account_shallow_copy.bank_date for payment_row in payments_rows.renovation: payment_actions.consume(payment_row.payment_amount, payment_row.uuid) if payment_actions.is_money_consumed(): return return def check_payment_stage_lawyer_expence(account_shallow_copy: AccountRecordsShallowCopy, build_dues_types: BuildDuesTypes, payments_rows: PaymentsRows, payment_actions: PaymentActions): account_records_bank_date = account_shallow_copy.bank_date for payment_row in payments_rows.lawyer_expence: payment_actions.consume(payment_row.payment_amount, payment_row.uuid) if payment_actions.is_money_consumed(): return return def check_payment_stage_service_fee(account_shallow_copy: AccountRecordsShallowCopy, build_dues_types: BuildDuesTypes, payments_rows: PaymentsRows, payment_actions: PaymentActions): account_records_bank_date = account_shallow_copy.bank_date for payment_row in payments_rows.service_fee: payment_actions.consume(payment_row.payment_amount, payment_row.uuid) if payment_actions.is_money_consumed(): return return def check_payment_stage_information(account_shallow_copy: AccountRecordsShallowCopy, build_dues_types: BuildDuesTypes, payments_rows: PaymentsRows, payment_actions: PaymentActions): account_records_bank_date = account_shallow_copy.bank_date for payment_row in payments_rows.information: payment_actions.consume(payment_row.payment_amount, payment_row.uuid) if payment_actions.is_money_consumed(): return return def close_account_records(account_shallow_copy: AccountRecordsShallowCopy, payment_actions: PaymentActions, records_to_close: int): if payment_actions.is_money_consumed(): print(f'payment_actions.is_money_consumed() : {payment_actions.is_money_consumed()}') for paid_row in payment_actions.paid_list: print(f'paid_row item : {paid_row.get_dict()}') print(f'payment_actions.consumed_money : {payment_actions.consumed_money}') print(f'payment_actions.initial_money : {payment_actions.initial_money}') print(f'payment_actions.remaining_money : {payment_actions.remaining_money}') with BuildDecisionBookPayments.new_session() as session: BuildDecisionBookPayments.set_session(session) for payment_row in payment_actions.paid_list: print(f'payment_row : {payment_row}') payment_row_book = BuildDecisionBookPayments.query.filter( BuildDecisionBookPayments.uu_id == payment_row.uuid, cast(BuildDecisionBookPayments.ref_id, String) == cast(BuildDecisionBookPayments.uu_id, String), BuildDecisionBookPayments.account_records_id.is_(None), ).first() if not payment_row_book: raise ValueError(f"Payment row not found for uuid: {payment_row.uuid}") new_row = BuildDecisionBookPayments.create( ref_id=str(payment_row_book.uu_id), payment_plan_time_periods=payment_row_book.payment_plan_time_periods, period_time=payment_row_book.period_time, currency=payment_row_book.currency, account_records_id=account_shallow_copy.id, account_records_uu_id=str(account_shallow_copy.uuid), build_parts_id=payment_row_book.build_parts_id, build_parts_uu_id=str(payment_row_book.build_parts_uu_id), payment_amount=abs(payment_row.amount), payment_types_id=payment_row_book.payment_types_id, payment_types_uu_id=str(payment_row_book.payment_types_uu_id), process_date_m=payment_row_book.process_date.month, process_date_y=payment_row_book.process_date.year, process_date=payment_row_book.process_date, build_decision_book_item_id=payment_row_book.build_decision_book_item_id, build_decision_book_item_uu_id=str(payment_row_book.build_decision_book_item_uu_id), decision_book_project_id=payment_row_book.decision_book_project_id, decision_book_project_uu_id=str(payment_row_book.decision_book_project_uu_id), is_confirmed=True, ) new_row.save() account_record = AccountRecords.query.filter_by(id=account_shallow_copy.id).first() account_record.remainder_balance = - abs(account_record.remainder_balance) - abs(payment_actions.consumed_money) account_record.save() records_to_close += 1 return records_to_close, True return records_to_close, False def any_function(shallow_copy_list, build_dues_types): error_records, not_closed_records, records_to_close = 0, 0, 0 shallow_copy_list, build_dues_types = row_iteration_account_records() for index, shallow_copy in enumerate(shallow_copy_list): initial_amount = abs(shallow_copy.currency_value) - abs(shallow_copy.remainder_balance) if initial_amount == 0: # print(f'AC: {shallow_copy.uuid} initial_amount : {initial_amount} must be greater than 0 to spend money on payments') not_closed_records += 1 continue if initial_amount < 0: print(f'AC: {shallow_copy.uuid} initial_amount : {initial_amount} wrong calculation is saved on account records Remainder Balance : {shallow_copy.remainder_balance} Currency Value : {shallow_copy.currency_value}') error_records += 1 continue payment_actions = PaymentActions(initial_amount) # print(f'initial_amount : {initial_amount}') payments_rows = PaymentsRows() with BuildDecisionBookPayments.new_session() as session: BuildDecisionBookPayments.set_session(session) book_payments_query = ( BuildDecisionBookPayments.process_date_m == shallow_copy.bank_date.month, BuildDecisionBookPayments.process_date_y == shallow_copy.bank_date.year, BuildDecisionBookPayments.build_parts_id == shallow_copy.build_parts_id, BuildDecisionBookPayments.account_records_id.is_(None), cast(BuildDecisionBookPayments.ref_id, String) == cast(BuildDecisionBookPayments.uu_id, String), ) query_db = BuildDecisionBookPayments.query.filter( *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.debit.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() payments_rows.debit: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] query_db = BuildDecisionBookPayments.query.filter( *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.add_debit.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() payments_rows.add_debit: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] query_db = BuildDecisionBookPayments.query.filter( *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.renovation.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() payments_rows.renovation: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] query_db = BuildDecisionBookPayments.query.filter( *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.lawyer_expence.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() payments_rows.lawyer_expence: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] query_db = BuildDecisionBookPayments.query.filter( *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.service_fee.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() payments_rows.service_fee: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] query_db = BuildDecisionBookPayments.query.filter( *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.information.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() payments_rows.information: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] if len(payments_rows.debit) > 0: # print(f'{shallow_copy.uuid} debit', len(payments_rows.debit)) records_to_close += 1 if len(payments_rows.add_debit) > 0: # print(f'{shallow_copy.uuid} add_debit', len(payments_rows.add_debit)) records_to_close += 1 if len(payments_rows.renovation) > 0: # print(f'{shallow_copy.uuid} renovation', len(payments_rows.renovation)) records_to_close += 1 if len(payments_rows.lawyer_expence) > 0: # print(f'{shallow_copy.uuid} lawyer_expence', len(payments_rows.lawyer_expence)) records_to_close += 1 if len(payments_rows.service_fee) > 0: # print(f'{shallow_copy.uuid} service_fee', len(payments_rows.service_fee)) records_to_close += 1 if len(payments_rows.information) > 0: # print(f'{shallow_copy.uuid} information', len(payments_rows.information)) records_to_close += 1 # continue check_payment_stage_debit(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) if is_money_consumed: continue check_payment_stage_add_debit(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) if is_money_consumed: continue check_payment_stage_renovation(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) if is_money_consumed: continue check_payment_stage_lawyer_expence(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) if is_money_consumed: continue check_payment_stage_service_fee(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) if is_money_consumed: continue check_payment_stage_information(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) if is_money_consumed: continue # with BuildDecisionBookPayments.new_session() as session: # BuildDecisionBookPayments.set_session(session) # book_payments_query = ( # BuildDecisionBookPayments.process_date_m < shallow_copy.bank_date.month, BuildDecisionBookPayments.process_date_y == shallow_copy.bank_date.year, # BuildDecisionBookPayments.build_parts_id == shallow_copy.build_parts_id, BuildDecisionBookPayments.account_records_id.is_(None), # BuildDecisionBookPayments.ref_id == BuildDecisionBookPayments.uu_id, # ) # query_db = BuildDecisionBookPayments.query.filter( # *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.debit.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() # payments_rows.debit: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] # query_db = BuildDecisionBookPayments.query.filter( # *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.add_debit.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() # payments_rows.add_debit: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] # query_db = BuildDecisionBookPayments.query.filter( # *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.renovation.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() # payments_rows.renovation: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] # query_db = BuildDecisionBookPayments.query.filter( # *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.lawyer_expence.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() # payments_rows.lawyer_expence: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] # query_db = BuildDecisionBookPayments.query.filter( # *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.service_fee.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() # payments_rows.service_fee: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] # query_db = BuildDecisionBookPayments.query.filter( # *book_payments_query, BuildDecisionBookPayments.payment_types_id == build_dues_types.information.id).order_by(BuildDecisionBookPayments.process_date.desc()).all() # payments_rows.information: list[BuildDecisionBookPaymentsShallowCopy] = [BuildDecisionBookPaymentsShallowCopy.convert_row_to_shallow_copy(row) for row in query_db] # check_payment_stage_debit(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) # records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) # if is_money_consumed: # continue # check_payment_stage_add_debit(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) # records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) # if is_money_consumed: # continue # check_payment_stage_renovation(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) # records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) # if is_money_consumed: # continue # check_payment_stage_lawyer_expence(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) # records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) # if is_money_consumed: # continue # check_payment_stage_service_fee(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) # records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) # if is_money_consumed: # continue # check_payment_stage_information(account_shallow_copy=shallow_copy, build_dues_types=build_dues_types, payments_rows=payments_rows, payment_actions=payment_actions) # records_to_close, is_money_consumed = close_account_records(account_shallow_copy=shallow_copy, payment_actions=payment_actions, records_to_close=records_to_close) # if is_money_consumed: # continue """ build_decision_book_item_id, type=null, pos=10 build_parts_id, type=null, pos=12 payment_plan_time_periods, type=null, pos=1 process_date, type=null, pos=2 payment_types_id, type=null, pos=5 account_records_id, type=null, pos=16 """