//AddInvoicesForAuctions
        //public void AddInvoicesForAuctions(List<Auction> auctions)
        //{
        //  decimal? Insurance = GetVariableCoefficient("InsuranceCoefficient");
        //  Insurance = (Insurance.HasValue) ? Insurance.Value : (decimal)0.4;

        //  //decimal? SalesTaxRate = GetVariableCoefficient("SalesTaxRate");
        //  decimal SalesTaxRate = (decimal)0.08625;//(SalesTaxRate.HasValue) ? SalesTaxRate.Value : (decimal)0.08625;

        //  List<Invoice> invoices = new List<Invoice>(auctions.Count);
        //  Invoice invoice;
        //  Bid winningBid;
        //  foreach (Auction auc in auctions)
        //  {
        //    winningBid = auc.WinningBid as Bid;
        //    if (winningBid == null || (auc.Reserve.HasValue && auc.Reserve.Value > winningBid.Amount) || (winningBid.User.UserType_ID == (byte)Consts.UserTypes.HouseBidder)) continue;
        //    invoice = new Invoice();
        //    invoice.Auction_ID = auc.ID;
        //    invoice.Amount = winningBid.Amount;
        //    invoice.Cost = winningBid.Amount * (1 + auc.Event.BuyerFee.Value / 100);
        //    invoice.Comments = "Regular auction won item";
        //    invoice.DateCreated = DateTime.Now;
        //    invoice.IsPaid = false;
        //    invoice.IsSent = false;
        //    invoice.Quantity = 1;
        //    invoice.Shipping = (auc.Shipping.HasValue) ? auc.Shipping.Value : 0;
        //    invoice.Tax = (winningBid.User.AddressCard_Billing.State.Equals("NY") && String.IsNullOrEmpty(winningBid.User.TaxpayerID)) ? invoice.Amount * SalesTaxRate : 0;
        //    invoice.User_ID = winningBid.User_ID;
        //    invoices.Add(invoice);
        //  }
        //  dataContext.Invoices.InsertAllOnSubmit(invoices);
        //  SubmitChanges();
        //}



        //AddEditPayment
        public bool AddEditPayment(long Payment_Id, byte Method, decimal Amount, DateTime Date, string Note, bool IsCleared, string CDetails, long ID, bool IsAdding, bool IsInvoice)
        {
            Payment payment = (IsAdding) ? new Payment() : dataContext.Payments.SingleOrDefault(P => P.ID == Payment_Id);

            if (payment == null || ID < 1)
            {
                return(false);
            }
            PaymentType pt = dataContext.PaymentTypes.SingleOrDefault(PT => PT.ID == Method);

            payment.PaymentType    = pt;
            payment.Amount         = Amount;
            payment.PaidDate       = Date;
            payment.Notes          = Note;
            payment.IsCleared      = IsCleared;
            payment.ClearedDetails = CDetails;
            if (IsInvoice)
            {
                payment.UserInvoices_ID = ID;
                UserInvoice ui = dataContext.UserInvoices.SingleOrDefault(UI => UI.ID == ID);
                payment.User_ID = (ui != null) ? ui.User_ID : 0;
            }
            else
            {
                payment.Consignments_ID = ID;
                Consignment ui = dataContext.Consignments.SingleOrDefault(UI => UI.ID == ID);
                payment.User_ID = (ui != null) ? ui.User_ID : 0;
            }
            payment.PostDate = DateTime.Now;
            if (IsAdding)
            {
                dataContext.Payments.InsertOnSubmit(payment);
            }
            return(SubmitChanges());
        }
Exemplo n.º 2
0
        //GetUserInvoice
        public UserInvoice GetUserInvoice(long userinvoice_id)
        {
            DataCacheObject dco = new DataCacheObject(DataCacheType.ACTIVITY, DataCacheRegions.INVOICES, "GETUSERINVOICE",
                                                      new object[] { userinvoice_id }, CachingExpirationTime.Hours_01);
            UserInvoice ui = CacheRepository.Get(dco) as UserInvoice;

            if (ui != null)
            {
                return(ui);
            }
            ui = dataContext.spSelect_UserInvoices(userinvoice_id).FirstOrDefault();
            if (ui != null)
            {
                dco.Data = ui;
                CacheRepository.Add(dco);
            }
            return(ui);
        }
        //UpdatePayment
        public JsonExecuteResult UpdatePayment(long payment_id, byte method, decimal amount, DateTime date, string note, bool iscleared, string cdetails, long id, bool isadding, bool isinvoice)
        {
            try
            {
                Payment payment = (isadding) ? new Payment() : dataContext.Payments.SingleOrDefault(P => P.ID == payment_id);

                if (payment == null || id < 1)
                {
                    throw new Exception(isinvoice ? "The buyer invoice doesn't exist" : "The consignor statement doesn't exist");
                }
                PaymentType pt = dataContext.PaymentTypes.SingleOrDefault(PT => PT.ID == method);
                payment.PaymentType    = pt;
                payment.Amount         = amount;
                payment.PaidDate       = date;
                payment.Notes          = note;
                payment.IsCleared      = iscleared;
                payment.ClearedDetails = cdetails;
                if (isinvoice)
                {
                    payment.UserInvoices_ID = id;
                    UserInvoice ui = dataContext.UserInvoices.SingleOrDefault(UI => UI.ID == id);
                    payment.User_ID = (ui != null) ? ui.User_ID : 0;
                }
                else
                {
                    payment.Consignments_ID = id;
                    Consignment ui = dataContext.Consignments.SingleOrDefault(UI => UI.ID == id);
                    payment.User_ID = (ui != null) ? ui.User_ID : 0;
                }
                payment.PostDate = DateTime.Now;
                if (isadding)
                {
                    dataContext.Payments.InsertOnSubmit(payment);
                }
                GeneralRepository.SubmitChanges(dataContext);
            }
            catch (Exception ex)
            {
                return(new JsonExecuteResult(JsonExecuteResultTypes.ERROR, ex.Message));
            }
            return(new JsonExecuteResult(JsonExecuteResultTypes.SUCCESS));
        }