Exemplo n.º 1
0
        public SuiRecordLoan(string date, string account, string account2, string price, string memo, SuiRecordReference reference, SuiRecordType recordType) : base(date, price, memo.Substring(memo.IndexOf(':') + 1), recordType)
        {
            APAccount = reference.Accounts["A-P"];
            ARAccount = reference.Accounts["A-R"];

            if (account.StartsWith(">>") && !account2.StartsWith(">>")) // IN
            {
                InAccount = reference.Accounts[account2];
                InPrice   = price;

                Loaner    = reference.Loaners.GetOfficialName(account.Substring(2));
                DebtId    = reference.Loaners[account.Substring(2)];
                Direction = SuiRecordLoanDirection.In;
            }

            else if (!account.StartsWith(">>") && account2.StartsWith(">>")) // OUT
            {
                OutAccount = reference.Accounts[account];
                OutPrice   = price;

                Loaner    = reference.Loaners.GetOfficialName(account2.Substring(2));
                DebtId    = reference.Loaners[account2.Substring(2)];
                Direction = SuiRecordLoanDirection.Out;
            }

            Price2 = price;
            if (!memo.Contains(":"))
            {
                throw new ArgumentOutOfRangeException("Loan record tag is not found");
            }
            Tag = memo.Substring(0, memo.IndexOf(':'));
        }
Exemplo n.º 2
0
        public SuiRecordLoan CombineLoan(SuiRecordLoan loan)
        {
            if (Direction == SuiRecordLoanDirection.None)
            {
                throw new Exception();
            }

            if (Direction == SuiRecordLoanDirection.Out && loan.Direction == SuiRecordLoanDirection.In)
            {
                if (DebtId == loan.DebtId && Tag == loan.Tag)
                {
                    Direction      = SuiRecordLoanDirection.OutIn;
                    loan.Direction = SuiRecordLoanDirection.None;

                    InPrice   = loan.InPrice;
                    InAccount = loan.InAccount;
                }
            }

            if (Direction == SuiRecordLoanDirection.In && loan.Direction == SuiRecordLoanDirection.Out)
            {
                if (DebtId == loan.DebtId && Tag == loan.Tag)
                {
                    Direction      = SuiRecordLoanDirection.InOut;
                    loan.Direction = SuiRecordLoanDirection.None;

                    OutPrice   = loan.OutPrice;
                    OutAccount = loan.OutAccount;
                }
            }

            return(this);
        }