'$include "..\WC_Subs\WC_Subs.WCC" ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// const Program_Name = "BBS_Loan" const Copyright = Program_Name + " (C) 1995 David W. Croft" const Loan_Max_Total = 100 declare sub Ask_For_Funds declare function Mail_Payment_Receipt ( \ UserRec as UserRecord, \ byval Payment as integer ) \ as boolean declare sub Repay_Loan sub Ask_For_Funds ////////////////////////////////////////////////////////////////////// dim Loan_Max as integer dim Loan as integer dim Loan_Str as string ////////////////////////////////////////////////////////////////////// if User_Is_Sysop then cls ? Copyright ? if InputYesNo ( "SysOp, would you like to run maintenance?" \ + " (y/N): ", FALSE ) then Repay_Loan end if elseif UserSec.Name <> "FULLUSER" then ? "Once you send in a check, you will be upgraded to FULLUSER." ? "As a FULLUSER, you will be able to borrow money for your" ? "account balance." WaitEnter exit sub end if cls color ( 10 ) ? Copyright ? ? "You may take a short-term loan if you are planning to mail in a check" ? "today or tomorrow for $5.00 or more." ? ? "The loan will automatically be re-paid from your account balance" ? "when your check is cashed and transferred to your account balance." ? ? "You will then be eligible to borrow up to the maximum loan amount," ? Dollars_Str ( Loan_Max_Total ); ", again." ? ? "Do you want to mail in a check and take a short-term loan?"; if not InputYesNo ( " (y/N): ", FALSE ) then exit sub end if ? ? "The following display will provide the information you need" ? "to mail in a check to increase your account balance." ? ? "If your checkbook and an envelope are not currently available," ? "please print the following screen or write it down." ? WaitEnter if not DisplayFile ( "BBS_Loan.BBS" ) then ? "Please contact your SysOp for the address." end if ? "You owe $"; ? Trim ( FormatNumber ( User.NetmailBalance / 100, "###.##" ) ); ? "." Loan_Max = Loan_Max_Total - User.NetmailBalance if Loan_Max <= 0 then ? "Your credit is maxed out." WaitEnter exit sub end if ? "You may borrow up to $"; ? Trim ( FormatNumber ( Loan_Max / 100, "###.##" ) ); ? "." ? Loan = InputNumber ( "How much would you like to borrow (in cents)? ", \ 0, Loan_Max ) if Loan > 0 then User.SubscriptionBalance = User.SubscriptionBalance + Loan User.NetmailBalance = User.NetmailBalance + Loan Loan_Str = Program_Name + ": $" \ + Trim ( FormatNumber ( Loan / 100, "###.##" ) ) \ + " borrowed by [" \ + FormatNumber ( User.UserID, "@####" ) \ + "] " + User.Name ActivityLog ( Loan_Str ) ? "Done." else ? "No funds transferred." end if WaitEnter end sub function Mail_Payment_Receipt ( \ UserRec as UserRecord, \ byval Payment as integer ) \ as boolean ////////////////////////////////////////////////////////////////////// dim MsgHeader as MessageHeader dim Message as string ////////////////////////////////////////////////////////////////////// MsgHeader.From = MakeWild.SysopName MsgHeader.FromTitle = Program_Name MsgHeader.To = UserRec.Name MsgHeader.ToID = UserRec.UserID MsgHeader.Subject = "Repayment of loan" // Make message private. FlagSet ( MsgHeader.Flags, 1 ) Message = "Automatic repayment of $" \ + Trim ( FormatNumber ( Payment / 100, "###.##" ) ) Mail_Payment_Receipt = AddMessage ( MsgHeader, Message ) end function sub Repay_Loan ////////////////////////////////////////////////////////////////////// dim Payment as integer dim UserRec as UserRecord dim User_Str as string dim Loans_Total as long ////////////////////////////////////////////////////////////////////// if not GetFirstUser ( UserRec, 5 ) then ActivityLog ( Program_Name + ": could not find first user." ) exit sub end if Loans_Total = 0 do if UserRec.UserID = User.UserID then Loans_Total = Loans_Total + User.NetmailBalance if User.NetmailBalance <= User.SubscriptionBalance then Payment = User.NetmailBalance else Payment = User.SubscriptionBalance end if else Loans_Total = Loans_Total + UserRec.NetmailBalance if UserRec.NetmailBalance <= UserRec.SubscriptionBalance then Payment = UserRec.NetmailBalance else Payment = UserRec.SubscriptionBalance end if end if if Payment > 0 then UserRec.SubscriptionBalance = \ UserRec.SubscriptionBalance - Payment UserRec.NetmailBalance = \ UserRec.NetmailBalance - Payment User_Str = "[" + FormatNumber ( UserRec.UserID, "@####" ) + "]" \ + " " + Pad ( UserRec.Name, 25 ) if User.UserID <> UserRec.UserID then if UpdateUser ( UserRec ) then ActivityLog ( Program_Name \ + ": $" \ + Trim ( FormatNumber ( Payment / 100, "###.##" ) ) \ + " " + User_Str + " automatic repayment" ) if not Mail_Payment_Receipt ( UserRec, Payment ) then ActivityLog ( Program_Name \ + ": unable to mail payment receipt for " + User_Str ) end if else ActivityLog ( Program_Name \ + ": unable to update user record for " + User_Str ) end if else User.SubscriptionBalance = User.SubscriptionBalance - Payment User.NetmailBalance = User.NetmailBalance - Payment ActivityLog ( Program_Name \ + ": $" \ + Trim ( FormatNumber ( Payment / 100, "###.##" ) ) \ + " " + User_Str + " automatic repayment" ) if not Mail_Payment_Receipt ( UserRec, Payment ) then ActivityLog ( Program_Name \ + ": unable to mail payment receipt for " + User_Str ) end if end if end if ? "."; loop while GetNextUser ( UserRec, 5 ) ActivityLog ( Program_Name + ": total loaned out $" \ + Trim ( FormatNumber ( Loans_Total / 100, "###.##" ) ) ) ? end sub ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// if not EventRunning then Ask_For_Funds else Repay_Loan end if