Example #1
0
        private void CreateBuySellHistory(BuySellDoc buySellDoc)
        {
            BuySellDocHistory buySellDocHistory = BuySellDocHistory.UnBox(BuySellDocHistoryBiz.Factory());

            buySellDocHistory.Init(buySellDoc);
            BuySellDocHistoryBiz.Create(buySellDocHistory);
        }
Example #2
0
 private void deliverymanPaysOwner_Penalty(BuySellDoc bsd, Person systemPerson, PersonPayingPenalty ppp, decimal totalPaymentAmount)
 {
     calculate_Deliveryman_Payment(bsd, ppp, totalPaymentAmount);
     calculateCommissions(bsd, systemPerson, ppp, totalPaymentAmount);
     calculate_Owner_Amount_When_Receiving_Penalty(bsd, systemPerson, ppp, totalPaymentAmount);
     calculate_ExtraCommission(bsd, systemPerson, ppp, totalPaymentAmount);
 }
Example #3
0
 private void calculate_Customer_Payment(BuySellDoc bsd, PersonPayingPenalty ppp, decimal totalPaymentAmount)
 {
     ppp.From.Person = CustomerBiz.GetPersonForPlayer(bsd.CustomerId);
     ppp.From.Person.IsNullThrowException();
     ppp.From.Amount  = totalPaymentAmount;
     ppp.From.Comment = "Customer";
 }
Example #4
0
        /// <summary>
        /// This is the one that returns a list of a sale or purchase documents for a specific state within a date period. This is the one that joins the operations.
        /// We will use this data to get the money amount and counts
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="buySellDocStateEnum"></param>
        /// <param name="buySellDocumentTypeEnum"></param>
        /// <param name="fromDate"></param>
        /// <param name="toDate"></param>
        /// <returns></returns>
        List <BuySellDoc> getBuySellDocs_For(string userId, BuySellDocStateENUM buySellDocStateEnum, BuySellDocumentTypeENUM buySellDocumentTypeEnum, DateTime fromDate, DateTime toDate)
        {
            IQueryable <BuySellDoc> allDocsWithinDate      = FindAll().Where(x => x.MetaData.Created.Date >= fromDate && x.MetaData.Created.Date <= toDate);
            List <BuySellDoc>       allDocsWithinDateDEBUG = allDocsWithinDate.ToList();

            IQueryable <BuySellDoc> allDocsOfDocumentType      = getByDocumentType_For(userId, allDocsWithinDate, buySellDocumentTypeEnum);
            List <BuySellDoc>       allDocsOfDocumentTypeDEBUG = getByDocumentType_For(userId, allDocsWithinDate, buySellDocumentTypeEnum).ToList();

            IQueryable <BuySellDoc> IQueryable_allDocsOfDocState = BuySellDoc.IQuerable_Orders_For(buySellDocStateEnum, allDocsOfDocumentType);

            List <BuySellDoc> allFilteredDocs = IQueryable_allDocsOfDocState.ToList();

            //fill in the Complex Addresses
            if (!allFilteredDocs.IsNullOrEmpty())
            {
                foreach (BuySellDoc buysellDoc in allFilteredDocs)
                {
                    loadAddressShipTo(buysellDoc);
                    loadAddressBillTo(buysellDoc);
                    loadAddressShipFrom(buysellDoc);

                    //this changes the value of the doc.
                    //buysellDoc.BuySellDocumentTypeEnum = buySellDocumentTypeEnum;
                }
            }

            return(allFilteredDocs);
        }
Example #5
0
 private void customerPaysDeliveryman_Penalty(BuySellDoc bsd, Person systemPerson, PersonPayingPenalty ppp, decimal totalPaymentAmount)
 {
     calculate_Customer_Payment(bsd, ppp, totalPaymentAmount);
     calculateCommissions(bsd, systemPerson, ppp, totalPaymentAmount);
     calculate_Penalty_When_Deliveryman_Is_Receiving(bsd, ppp, totalPaymentAmount);
     calculate_ExtraCommission(bsd, systemPerson, ppp, totalPaymentAmount);
 }
        //use calculate_Commissions

        private void set_OwnersSalesMan_Commission(BuySellDoc bsd)
        {
            if (bsd.OwnerSalesmanId.IsNullOrWhiteSpace())
            {
                bsd.OwnerSalesmanCommission = new PaymentsComplex();
                return;
            }

            bsd.OwnerSalesmanCommission.Percent = BuySellDoc.Get_OwnerSalesman_Commission_Percent();
            //bsd.OwnerSalesmanCommission.Percent = SalesCommissionClass.CommissionPct_OwnerSalesman;
            decimal commissionPct = bsd.OwnerSalesmanCommission.Percent;


            if (commissionPct == 0)
            {
                return;
            }

            if (bsd.Total_Product_Payment_For_Invoice.Total == 0)
            {
                return;
            }

            bsd.OwnerSalesmanCommission.Amount_Refundable    = commissionPct * bsd.Total_Product_Payment_For_Invoice.Amount_Refundable / 100;
            bsd.OwnerSalesmanCommission.Amount_NonRefundable = commissionPct * bsd.Total_Product_Payment_For_Invoice.Amount_NonRefundable / 100;
        }
        private void set_Super_Super_OwnersSalesMan_Commission(BuySellDoc bsd)
        {
            //check to see if Super Owner Salesman Exists
            if (bsd.OwnerSalesmanId.IsNullOrWhiteSpace())
            {
                bsd.SuperSuperOwnerSalesmanCommission = new PaymentsComplex();
                return;
            }

            //check to see if Super Owner Salesman Exists
            if (bsd.SuperOwnerSalesmanId.IsNull())
            {
                bsd.SuperSuperOwnerSalesmanCommission = new PaymentsComplex();
                return;
            }

            if (bsd.SuperSuperOwnerSalesmanId.IsNull())
            {
                bsd.SuperSuperOwnerSalesmanCommission = new PaymentsComplex();
                return;
            }


            decimal commissionPct = BuySellDoc.Get_OwnerSuperSuperSalesman_Commission_Percent();

            bsd.SuperSuperOwnerSalesmanCommission.Percent = commissionPct;

            if (bsd.Total_Product_Refundable * commissionPct == 0)
            {
                return;
            }

            bsd.SuperSuperOwnerSalesmanCommission.Amount_Refundable    = commissionPct * bsd.Total_Product_Payment_For_Invoice.Amount_Refundable / 100;
            bsd.SuperSuperOwnerSalesmanCommission.Amount_NonRefundable = commissionPct * bsd.Total_Product_Payment_For_Invoice.Amount_NonRefundable / 100;
        }
 private void reset_OwnersCommissionAndFields(BuySellDoc bsd)
 {
     bsd.OwnerSalesmanCommission           = new PaymentsComplex();
     bsd.SuperOwnerSalesmanCommission      = new PaymentsComplex();
     bsd.SuperSuperOwnerSalesmanCommission = new PaymentsComplex();
     //bsd.Total_Charged_To_Owner = new PaymentsComplex();
 }
        private void reset_DeliverymansCommissionAndFields(BuySellDoc bsd)
        {
            if (!bsd.FreightOfferTrxAcceptedId.IsNullOrWhiteSpace())
            {
                FreightOfferTrx freightOfferTrx = FreightOfferTrxBiz.Find(bsd.FreightOfferTrxAcceptedId);
                freightOfferTrx.IsNullThrowException();
                //freightOfferTrx.OfferAcceptedByDeliveryman = new BoolDateAndByComplex();
                freightOfferTrx.OfferAcceptedByOwner = new BoolDateAndByComplex();
                FreightOfferTrxBiz.Update(freightOfferTrx);

                bsd.FreightOfferTrxAcceptedId = null;
                bsd.FreightOfferTrxAccepted   = null;
            }

            bsd.DeliverymanSalesman           = null;
            bsd.DeliverymanSalesmanId         = null;
            bsd.DeliverymanSalesmanCommission = new PaymentsComplex();

            bsd.SuperDeliverymanSalesmanId         = null;
            bsd.SuperDeliverymanSalesman           = null;
            bsd.SuperDeliverymanSalesmanCommission = new PaymentsComplex();

            bsd.SuperSuperDeliverymanSalesmanId         = null;
            bsd.SuperSuperDeliverymanSalesman           = null;
            bsd.SuperSuperDeliverymanSalesmanCommission = new PaymentsComplex();

            //bsd.Total_Charged_To_Deliveryman = new PaymentsComplex();
            bsd.Total_Delivery_Payment_For_Invoice = new PaymentsComplex();

            bsd.CourierAcceptedByBuyerAndSeller = new BoolDateAndByComplex();
            bsd.CourierComingToPickUp           = new BoolDateAndByComplex();
        }
        private void set_CustomersSalesMan_Commission(BuySellDoc bsd)
        {
            if (bsd.CustomerSalesmanId.IsNullOrWhiteSpace())
            {
                bsd.CustomerSalesmanCommission = new PaymentsComplex();
                return;
            }

            bsd.CustomerSalesmanCommission.Percent = BuySellDoc.Get_CustomerSalesman_Commission_Percent();
            decimal commissionPct = bsd.CustomerSalesmanCommission.Percent;

            if (commissionPct == 0)
            {
                return;
            }

            if (bsd.Total_Product_Payment_For_Invoice.Total == 0)
            {
                return;
            }

            //bsd.Total_Product_Payment.Amount_Refundable  contains the total commission. So we need to divide by total commission percent
            //and then multiply with commission for customer salesmamn
            bsd.CustomerSalesmanCommission.Amount_Refundable    = commissionPct * bsd.Total_Product_Payment_For_Invoice.Amount_Refundable / 100;
            bsd.CustomerSalesmanCommission.Amount_NonRefundable = commissionPct * bsd.Total_Product_Payment_For_Invoice.Amount_NonRefundable / 100;
        }
Example #11
0
        //**********************************************************************************************************
        // Commission for Sales
        //**********************************************************************************************************



        private void order_Canceled(BuySellDoc bsd)
        {
            if (bsd.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.Cancel)
            {
                if (bsd.BuySellDocStateEnum == BuySellDocStateENUM.Delivered)
                {
                    if (bsd.ShopId.IsNullOrWhiteSpace())
                    {
                        bsd.BuySellDocStateEnum = BuySellDocStateENUM.Problem;
                        bsd.Problem.SetToTodaysDate(UserName, UserId);
                    }
                    else
                    {
                        ifShopPurchaseThenDeleteShopAndMarkReject(bsd);
                    }
                }
                else
                {
                    clearAllStatus(bsd);
                    bsd.BuySellDocStateEnum = BuySellDocStateENUM.RequestUnconfirmed;

                    //reset_Commissions_And_Fields(bsd);
                }
            }
        }
Example #12
0
        public BuySellDoc GetDeliveryOrder(string buySellId)
        {
            buySellId.IsNullOrWhiteSpaceThrowArgumentException();
            BuySellDoc buySellDoc = BuySellDocBiz.FindAll().FirstOrDefault(x => x.Id == buySellId);

            return(buySellDoc);
        }
        private void set_Super_DeliverymansSalesMan_Commission(BuySellDoc bsd)
        {
            if (bsd.DeliverymanSalesmanId.IsNullOrWhiteSpace())
            {
                bsd.SuperDeliverymanSalesmanCommission = new PaymentsComplex();
                return;
            }

            //check to see if Super Deliveryman Salesman Exists
            if (bsd.SuperDeliverymanSalesmanId.IsNull())
            {
                bsd.SuperDeliverymanSalesmanCommission = new PaymentsComplex();
                return;
            }

            //reset if ownerSalesmanId is null


            decimal commissionPct = bsd.Get_DeliverymanSuperSalesman_Commission_Percent();

            bsd.SuperDeliverymanSalesmanCommission.Percent = commissionPct;
            if (bsd.Total_Product_Refundable * commissionPct == 0)
            {
                return;
            }

            bsd.SuperDeliverymanSalesmanCommission.Amount_Refundable = commissionPct * bsd.Total_Delivery_Payment_For_Invoice.Amount_Refundable / 100;
        }
Example #14
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            UserId.IsNullOrWhiteSpaceThrowException("User is not logged in");
            BuySellDoc bsd = BuySellDoc.UnBox(parm.Entity);


            fixDocumentNumber(bsd);
            fixName(parm);
            fixCustomer(bsd);
            fixSeller(bsd);

            fixCustomerSalesman(bsd);
            fix_Super_Customer_Salesman(bsd);
            fix_Super_Super_Customer_Salesman(bsd);

            fixOwnerSalesman(bsd);
            fix_Super_Owner_Salesman(bsd);
            fix_Super_Super_Owner_Salesman(bsd);


            fixDeliverymanSalesman(bsd);
            fix_Super_Deliveryman_Salesman(bsd);
            fix_Super_Super_Deliveryman_Salesman(bsd);

            fixAddresses(bsd);
            fixVehicalType(bsd);
            fixFreight(bsd);
            fixDate(bsd);
            fixFreightOfferTrxId(bsd);
            fix_Update_BuySellDocStateModifierEnum_InBuySell(parm, bsd);
            fix_MenuManager(bsd, parm);

            fix_OptedOutOfSystem(bsd);
            base.Fix(parm);
        }
Example #15
0
 private void fixDocumentNumber(BuySellDoc buySellDoc)
 {
     if (buySellDoc.DocumentNumber == 0)
     {
         buySellDoc.DocumentNumber = GetNextDocNumber();
     }
 }
Example #16
0
 private void fix_MenuManager(BuySellDoc buySellDoc, ControllerCreateEditParameter parm)
 {
     if (buySellDoc.MenuManager.IsNull())
     {
         buySellDoc.MenuManager = new MenuManager(null, null, null, MenuENUM.IndexDefault, BreadCrumbManager, null, UserId, parm.ReturnUrl, UserName);
     }
 }
Example #17
0
 private void fixFreightOfferTrxId(BuySellDoc buySellDoc)
 {
     if (buySellDoc.FreightOfferTrxAcceptedId.IsNullOrWhiteSpace())
     {
         buySellDoc.FreightOfferTrxAcceptedId = null;
     }
 }
Example #18
0
        public BuySellDoc GetOpenSaleWithSameCustomerAndSeller(string customerId, string ownerProductChildId, ProductChild productChild)
        {
            customerId.IsNullThrowExceptionArgument("customerId");
            ownerProductChildId.IsNullThrowExceptionArgument("ownerProductChildId");
            productChild.IsNullThrowExceptionArgument("productChild");

            BuySellDoc buysSellDoc = FindAll().FirstOrDefault(x =>
                                                              x.CustomerId == customerId &&
                                                              x.OwnerId == ownerProductChildId &&
                                                              x.BuySellDocStateEnum == BuySellDocStateENUM.RequestUnconfirmed);

            //make sure the product addresses are also the same.
            if (buysSellDoc.IsNull())
            {
                return(buysSellDoc);
            }

            if (productChild.ShipFromAddress.IsNull())
            {
                productChild.ShipFromAddressId.IsNullOrWhiteSpaceThrowException();

                productChild.ShipFromAddress = AddressBiz.Find(productChild.ShipFromAddressId);
                productChild.ShipFromAddress.IsNullThrowException();
            }
            productChild.ShipFromAddressComplex = productChild.ShipFromAddress.ToAddressComplex();

            if (buysSellDoc.AddressShipFromComplex.Equals(productChild.ShipFromAddressComplex))
            {
                return(buysSellDoc);
            }

            return(null);
        }
Example #19
0
        decimal maxPossibleLiabilityToDeliverParcel(BuySellDoc bsd, FreightOfferTrx frtTrx)
        {
            bsd.IsNullThrowException();
            decimal ttlLiability = frtTrx.OfferAmount + bsd.InsuranceRequired;

            return(ttlLiability);
        }
Example #20
0
 private void throwExceptionIfVehicalTypeNotAdded(BuySellDoc buySellDoc)
 {
     if (buySellDoc.VehicalTypeOfferedId.IsNullOrWhiteSpace())
     {
         throw new Exception("No Vehical type added. Please add one");
     }
 }
Example #21
0
 private static void Buyer_Selects_Courier_For_Shipment(BuySellDoc buySellDoc)
 {
     if (buySellDoc.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.Accept)
     {
         buySellDoc.BuySellDocStateEnum = BuySellDocStateENUM.CourierAcceptedByBuyerAndSeller;
     }
 }
Example #22
0
 private void check_BillFrom_Address_Is_filled(BuySellDoc buySellDoc)
 {
     if (buySellDoc.AddressShipFromComplex.ErrorCheck())
     {
         throw new Exception("** In Bill From Address ** " + buySellDoc.AddressShipFromComplex.Error);
     }
 }
Example #23
0
 private void check_ShipTo_Address_Is_filled(BuySellDoc buySellDoc)
 {
     if (buySellDoc.AddressShipToComplex.ErrorCheck())
     {
         throw new Exception("** In Ship To Address ** " + buySellDoc.AddressShipToComplex.Error);
     }
 }
Example #24
0
        /// <summary>
        /// this only fires once user has accepted to move on
        /// </summary>
        /// <param name="buySellDoc"></param>
        private void update_Customer_Person_Bill_To_Default_Address_If_empty(BuySellDoc buySellDoc)
        {
            buySellDoc.IsNullThrowException();
            buySellDoc.CustomerId.IsNullOrWhiteSpaceThrowException();
            buySellDoc.AddressBillToId.IsNullOrWhiteSpaceThrowException();
            Person customerPerson = CustomerBiz.GetPersonForPlayer(buySellDoc.CustomerId);

            customerPerson.IsNullThrowException();

            if (customerPerson.DefaultBillAddressId.IsNullOrEmpty())
            {
                customerPerson.DefaultBillAddressId = buySellDoc.AddressBillToId;
                PersonBiz.Update(customerPerson);
            }

            //Now update the Customer Default Address if required.
            //get the customer.
            Customer customer = buySellDoc.Customer;

            if (customer.IsNull())
            {
                buySellDoc.CustomerId.IsNullOrWhiteSpaceThrowException();
                customer = CustomerBiz.Find(buySellDoc.CustomerId);
                customer.IsNullThrowException();

                if (customer.DefaultBillAddressId.IsNullOrWhiteSpace())
                {
                    customer.DefaultBillAddressId = customerPerson.DefaultBillAddressId;
                    CustomerBiz.Update(customer);
                }
            }
        }
        /// use calculate_Commissions
        private void set_DeliverymansSalesMan_Commission(BuySellDoc bsd)
        {
            if (bsd.DeliverymanSalesmanId.IsNullOrWhiteSpace())
            {
                bsd.DeliverymanSalesmanCommission = new PaymentsComplex();
                return;
            }

            decimal commissionPct = bsd.Get_DeliverymanSalesman_Commission_Percent();

            bsd.DeliverymanSalesmanCommission.Percent = bsd.DeliverymanSalesmanCommission.Percent;

            if (commissionPct == 0)
            {
                return;
            }

            if (bsd.Total_Delivery_Payment_For_Invoice.Total == 0)
            {
                return;
            }


            bsd.DeliverymanSalesmanCommission.Amount_Refundable    = commissionPct * bsd.Total_Delivery_Payment_For_Invoice.Amount_Refundable / 100;
            bsd.DeliverymanSalesmanCommission.Amount_NonRefundable = commissionPct * bsd.Total_Delivery_Payment_For_Invoice.Amount_NonRefundable / 100;
        }
Example #26
0
        private void fix_Super_Super_Deliveryman_Salesman(BuySellDoc bsd)
        {
            if (bsd.DeliverymanSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }

            if (bsd.DeliverymanSalesman.IsNull())
            {
                throw new Exception("Deliveryman Salesman is null.");
            }


            if (bsd.DeliverymanSalesman.ParentSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }

            if (bsd.DeliverymanSalesman.ParentSalesman.IsNull())
            {
                throw new Exception("Deliveryman Salesman Parent is null.");
            }

            if (bsd.DeliverymanSalesman.ParentSalesman.ParentSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }

            bsd.DeliverymanSalesman.ParentSalesman.ParentSalesman = SalesmanBiz.Find(bsd.DeliverymanSalesman.ParentSalesman.ParentSalesmanId);
            bsd.DeliverymanSalesman.ParentSalesman.ParentSalesman.IsNullThrowException();
        }
Example #27
0
        private BuySellDoc getBuySellDoc(FreightOfferTrx freightOfferAcceptedTrx)
        {
            freightOfferAcceptedTrx.BuySellDocId.IsNullOrWhiteSpaceThrowException();
            BuySellDoc buyselldoc = Find(freightOfferAcceptedTrx.BuySellDocId);

            return(buyselldoc);
        }
Example #28
0
 private void seller_Has_Completed_Preparing_Parcel_For_Shipment(BuySellDoc bsd)
 {
     if (bsd.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.Accept)
     {
         bsd.BuySellDocStateEnum = BuySellDocStateENUM.ReadyForPickup;
         bsd.ReadyForPickup.SetToTodaysDate(UserName, UserId);
     }
 }
Example #29
0
 private void seller_Selects_Deliveryman_For_Shipment(BuySellDoc bsd)
 {
     if (bsd.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.Accept)
     {
         bsd.BuySellDocStateEnum = BuySellDocStateENUM.CourierAcceptedByBuyerAndSeller;
         bsd.CourierAcceptedByBuyerAndSeller.SetToTodaysDate(UserName, UserId);
     }
 }
Example #30
0
 private void order_Rejected(BuySellDoc buySellDoc)
 {
     if (buySellDoc.BuySellDocStateModifierEnum == BuySellDocStateModifierENUM.Reject)
     {
         buySellDoc.BuySellDocStateEnum = BuySellDocStateENUM.Rejected;
         if_Reject_reset_Commissions_And_Fields(buySellDoc);
     }
 }