Exemplo n.º 1
0
        static void sendNotification(PersonDto pPerson,
                                     CustomerAcctPaymentDto pCustomerAcctPayment,
                                     CustomerAcctRow_Base pCustomerAcctRow,
                                     PartnerDto pPartner,
                                     ContactInfoDto pContactInfo)
        {
            try {
                var _subject = "Balance Adjustment, [Partner]> " + pPartner.Name + " [Acct]> " + pCustomerAcctRow.Name;
                var _body    = "Server Time>      " + pCustomerAcctPayment.DateTime.ToString("yyyy-MM-dd HH:mm:ss");
                _body += Environment.NewLine;
                _body += "Adjust Amount>    " + pCustomerAcctPayment.Amount.ToString("c");
                _body += Environment.NewLine;
                _body += "Previous Balance> " + pCustomerAcctPayment.PreviousAmount.ToString("c");
                _body += Environment.NewLine;
                _body += "Current Balance>  " + decimal.Add(pCustomerAcctPayment.PreviousAmount, pCustomerAcctPayment.Amount).ToString("c");
                _body += Environment.NewLine;
                _body += "Comments>  " + pCustomerAcctPayment.Comments;

                Email.SetForSending(Path.Combine(Configuration.Instance.Folders.EmailFolder, Guid.NewGuid().ToString("N")),
                                    Configuration.Instance.Email.ClientFrom,
                                    Configuration.Instance.Email.ClientTo,
                                    string.Empty,
                                    pContactInfo.Email,
                                    Configuration.Instance.Email.ClientEmailServer,
                                    Configuration.Instance.Email.ClientEmailPassword,
                                    _subject,
                                    _body);
                TimokLogger.Instance.LogRbr(LogSeverity.Status, "CustomerAcctController.sendNotification", string.Format("Adjusted by:      {0}\r\n{1} {2}", pPerson.Name, _subject, _body));
            }
            catch (Exception _ex) {
                TimokLogger.Instance.LogRbr(LogSeverity.Critical, "CustomerAcctController.sendNotification", string.Format("Exception sending notification\r\n{0}", _ex));
            }
        }
Exemplo n.º 2
0
        static CustomerAcctPaymentRow mapToCustomerAcctPaymentRow(CustomerAcctPaymentDto pCustomerAcctPayment)
        {
            var _customerAcctPaymentRow = new CustomerAcctPaymentRow
            {
                Date_time                    = pCustomerAcctPayment.DateTime,
                Customer_acct_id             = pCustomerAcctPayment.CustomerAcctId,
                Previous_amount              = pCustomerAcctPayment.PreviousAmount,
                Payment_amount               = pCustomerAcctPayment.Amount,
                Comments                     = pCustomerAcctPayment.Comments,
                Balance_adjustment_reason_id = pCustomerAcctPayment.BalanceAdjustmentReasonId,
                Person_id                    = pCustomerAcctPayment.PersonId
            };

            return(_customerAcctPaymentRow);
        }
Exemplo n.º 3
0
        internal static void Credit(Rbr_Db pDb, CustomerAcctPaymentDto pCustomerAcctPayment)
        {
            if (!pDb.CustomerAcctCollection.Credit(pCustomerAcctPayment.CustomerAcctId, pCustomerAcctPayment.Amount))
            {
                throw new ApplicationException("Failed to Credit Customer Account; customerAcctId: " + pCustomerAcctPayment.CustomerAcctId);
            }
            pDb.CustomerAcctPaymentCollection.Insert(mapToCustomerAcctPaymentRow(pCustomerAcctPayment));

            if (!pDb.CustomerAcctCollection.AdjustWarningAmount(pCustomerAcctPayment.CustomerAcctId, pCustomerAcctPayment.WarningLevel))
            {
                throw new ApplicationException("Failed to Set Warning Amount for Customer Account; customerAcctId: " + pCustomerAcctPayment.CustomerAcctId);
            }

            //pDb.AddChangedObject(new CustomerAcctKey(TxType.Delete, pCustomerAcctPayment.CustomerAcctId));
        }
Exemplo n.º 4
0
        static CustomerAcctPaymentDto mapToCustomerAcctPayment(CustomerAcctPaymentRow_Base pCustomerAcctPaymentRow, string pCustomerAcctName, PersonDto pPerson, BalanceAdjustmentReasonDto pBalanceAdjustmentReason)
        {
            var _customerAcctPayment = new CustomerAcctPaymentDto
            {
                DateTime                = pCustomerAcctPaymentRow.Date_time,
                CustomerAcctId          = pCustomerAcctPaymentRow.Customer_acct_id,
                CustomerAcctName        = pCustomerAcctName,
                PreviousAmount          = pCustomerAcctPaymentRow.Previous_amount,
                Amount                  = pCustomerAcctPaymentRow.Payment_amount,
                Comments                = pCustomerAcctPaymentRow.Comments,
                BalanceAdjustmentReason = pBalanceAdjustmentReason,
                Person                  = pPerson
            };

            return(_customerAcctPayment);
        }
Exemplo n.º 5
0
        public static void Credit(PersonDto pPerson, CustomerAcctPaymentDto pCustomerAcctPayment)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pPerson, pCustomerAcctPayment)) {
                    pCustomerAcctPayment.DateTime = DateTime.Now;
                    //NOTE: make sure we got prev amnt
                    CustomerAcctRow _customerAcctRow = CustomerAcctManager.Get(_db, pCustomerAcctPayment.CustomerAcctId);
                    pCustomerAcctPayment.PreviousAmount = _customerAcctRow.Current_amount;
                    pCustomerAcctPayment.Person         = pPerson;
                    CustomerAcctManager.Credit(_db, pCustomerAcctPayment);
                    _tx.Commit();

                    PartnerDto     _partner     = PartnerManager.Get(_db, _customerAcctRow.Partner_id);
                    ContactInfoDto _contactInfo = ContactInfoManager.Get(_db, _partner.ContactInfo.ContactInfoId);
                    sendNotification(pPerson, pCustomerAcctPayment, _customerAcctRow, _partner, _contactInfo);
                }
            }
        }