private DbDeleteStatement GetQuery_DeleteQuery(TimeBillingSaleLine _obj)
        {
            DbDeleteStatement clause = DbMgr.CreateDeleteClause();

            clause.DeleteFrom("TimeBillingSaleLines").Criteria.IsEqual("TimeBillingSaleLines", "TimeBillingSaleLineID", _obj.TimeBillingSaleLineID);

            return(clause);
        }
        protected override OpResult _Delete(TimeBillingSaleLine _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.ObjectIsNull, _obj, "TimeBillingSaleLine object cannot be deleted as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_DeleteQuery(_obj));
                return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.ExistsAndDeleted, _obj));
            }

            return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.NotExists, _obj));
        }
コード例 #3
0
        public BOTimeBillingSaleLine(Accountant accountant, Sale _sale, TimeBillingSaleLine _line, BOContext context)
            : base(accountant, _sale, _line, context)
        {
            mObjectID                 = BOType.BOTimeInvoiceingSaleLine;
            mTimeBillingSaleLine      = _line.Clone() as TimeBillingSaleLine;
            mTimeBillingSaleLine.Sale = _sale;

            if (mTimeBillingSaleLine.Sale.IsTaxInclusive == "Y")
            {
                mRate = mTimeBillingSaleLine.TaxInclusiveRate;
            }
            else
            {
                mRate = mTimeBillingSaleLine.TaxExclusiveRate;
            }
        }
コード例 #4
0
        private void StoreLines(Sale _obj)
        {
            IList <SaleLine> lines = _obj.SaleLines;

            foreach (SaleLine line in lines)
            {
                RepositoryMgr.SaleLineMgr.Store(line);
                int?purchase_id      = line.SaleID;
                int?purchase_line_id = line.SaleLineID;
                if (line is ItemSaleLine)
                {
                    ItemSaleLine _line = line as ItemSaleLine;
                    _line.SaleID         = purchase_id;
                    _line.ItemSaleLineID = purchase_line_id;
                    RepositoryMgr.ItemSaleLineMgr.Store(_line);
                }
                else if (line is MiscSaleLine)
                {
                    MiscSaleLine _line = line as MiscSaleLine;
                    _line.SaleID         = purchase_id;
                    _line.MiscSaleLineID = purchase_line_id;
                    RepositoryMgr.MiscSaleLineMgr.Store(_line);
                }
                else if (line is ProfessionalSaleLine)
                {
                    ProfessionalSaleLine _line = line as ProfessionalSaleLine;
                    _line.SaleID = purchase_id;
                    _line.ProfessionalSaleLineID = purchase_line_id;
                    RepositoryMgr.ProfessionalSaleLineMgr.Store(_line);
                }
                else if (line is ServiceSaleLine)
                {
                    ServiceSaleLine _line = line as ServiceSaleLine;
                    _line.SaleID            = purchase_id;
                    _line.ServiceSaleLineID = purchase_line_id;
                    RepositoryMgr.ServiceSaleLineMgr.Store(_line);
                }
                else if (line is TimeBillingSaleLine)
                {
                    TimeBillingSaleLine _line = line as TimeBillingSaleLine;
                    _line.SaleID = purchase_id;
                    _line.TimeBillingSaleLineID = purchase_line_id;
                    RepositoryMgr.TimeBillingSaleLineMgr.Store(_line);
                }
            }
        }
        protected override OpResult _Store(TimeBillingSaleLine _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "TimeBillingSaleLine object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            if (_obj.TimeBillingSaleLineID == null)
            {
                _obj.TimeBillingSaleLineID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;
            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
コード例 #6
0
        private Dictionary <string, DbFieldEntry> GetQueryMap_StoreTimeBillingSaleLines(Sale _sale, TimeBillingSaleLine _line)
        {
            bool is_header = (_line == null);
            Dictionary <string, DbFieldEntry> query_map = new Dictionary <string, DbFieldEntry>();

            bool multi_currency_support = _sale.RepositoryMgr.CurrencyMgr.SupportMultiCurrency;

            #region Populate Sale Information
            query_map.Add("FirstName", DbMgr.CreateStringFieldEntry(is_header && _sale.Customer != null ? _sale.Customer.FirstName : ""));
            query_map.Add("CoLastName", DbMgr.CreateStringFieldEntry(is_header && _sale.Customer != null ? _sale.Customer.LastName : ""));
            query_map.Add("CardID", DbMgr.CreateStringFieldEntry(is_header && _sale.Customer != null ? _sale.Customer.CardIdentification : ""));
            query_map.Add("InvoiceNumber", DbMgr.CreateStringFieldEntry(is_header ? _sale.InvoiceNumber : ""));
            query_map.Add("Memo", DbMgr.CreateStringFieldEntry(is_header ? _sale.Memo : ""));
            query_map.Add("AddressLine1", DbMgr.CreateStringFieldEntry(is_header ? _sale.ShipToAddressLine1 : ""));
            query_map.Add("AddressLine2", DbMgr.CreateStringFieldEntry(is_header ? _sale.ShipToAddressLine2 : ""));
            query_map.Add("AddressLine3", DbMgr.CreateStringFieldEntry(is_header ? _sale.ShipToAddressLine3 : ""));
            query_map.Add("AddressLine4", DbMgr.CreateStringFieldEntry(is_header ? _sale.ShipToAddressLine4 : ""));
            query_map.Add("ShipVia", DbMgr.CreateStringFieldEntry(is_header && _sale.ShippingMethod != null ? _sale.ShippingMethod.Method : ""));
            query_map.Add("FreightAmount", DbMgr.CreateDoubleFieldEntry(is_header ? _sale.TaxExclusiveFreight : 0));
            query_map.Add("FreightTaxCode", DbMgr.CreateStringFieldEntry(is_header && _sale.FreightTaxCode != null ? _sale.FreightTaxCode.Code : ""));
            query_map.Add("Inclusive", DbMgr.CreateStringFieldEntry(is_header && _sale.IsTaxInclusive == "Y" ? "1" : ""));
            query_map.Add("SaleDate", _sale.InvoiceDate != null && is_header ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_sale.InvoiceDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("DeliveryStatus", DbMgr.CreateStringFieldEntry(is_header & _sale.InvoiceDelivery != null ? _sale.InvoiceDelivery.InvoiceDeliveryID : ""));
            query_map.Add("PromisedDate", is_header && _sale.PromisedDate != null ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_sale.PromisedDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("Comment", DbMgr.CreateStringFieldEntry(is_header && _sale.Comment != null ? _sale.Comment : ""));
            query_map.Add("SalespersonLastName", DbMgr.CreateStringFieldEntry(is_header && _sale.SalesPerson != null ? _sale.SalesPerson.LastName : ""));
            query_map.Add("SalespersonFirstName", DbMgr.CreateStringFieldEntry(is_header && _sale.SalesPerson != null ? _sale.SalesPerson.FirstName : ""));

            string sale_status_text = "";
            Status sale_status      = _sale.InvoiceStatus;
            if (is_header && sale_status != null)
            {
                if (sale_status.Type == Status.StatusType.Quote)
                {
                    sale_status_text = "Q";
                }
                else if (sale_status.Type == Status.StatusType.Order)
                {
                    sale_status_text = "O";
                }
                else if (sale_status.Type == Status.StatusType.Open)
                {
                    sale_status_text = "I";
                }
            }
            query_map.Add("SaleStatus", DbMgr.CreateStringFieldEntry(sale_status_text));

            if (_sale.InvoiceStatus.Type == Accounting.Core.Definitions.Status.StatusType.Order ||
                _sale.InvoiceStatus.Type == Accounting.Core.Definitions.Status.StatusType.Open
                )
            {
                //sqlArray.Add("AmountPaid", DbMgr.CreateDoubleFieldEntry(_obj.AmountPaid));
            }
            if (multi_currency_support)
            {
                query_map.Add("CurrencyCode", DbMgr.CreateStringFieldEntry(is_header && RepositoryMgr.IsMultiUserVersion && _sale.Currency != null ? _sale.Currency.CurrencyCode : ""));
                query_map.Add("ExchangeRate", DbMgr.CreateDoubleFieldEntry(is_header && RepositoryMgr.IsMultiUserVersion ? _sale.TransactionExchangeRate : 0));
            }
            query_map.Add("PaymentIsDue", DbMgr.CreateIntFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.PaymentIsDue : 0));
            query_map.Add("DiscountDays", DbMgr.CreateIntFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.DiscountDays : 0));
            query_map.Add("BalanceDueDays", DbMgr.CreateIntFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.BalanceDueDays : 0));
            query_map.Add("PercentDiscount", DbMgr.CreateDoubleFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.EarlyPaymentDiscountPercent : 0));
            query_map.Add("PercentMonthlyCharge", DbMgr.CreateDoubleFieldEntry(is_header && _sale.Terms != null ? _sale.Terms.LatePaymentChargePercent : 0));
            query_map.Add("ReferralSource", DbMgr.CreateStringFieldEntry(is_header && _sale.ReferralSource != null ? _sale.ReferralSource.Description : ""));
            #endregion

            #region Populate Line Information
            query_map.Add("ActivityID", !is_header && _line.Activity != null ? (DbFieldEntry)DbMgr.CreateStringFieldEntry(_line.Activity.ActivityName) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("Description", DbMgr.CreateStringFieldEntry(!is_header ? _line.Description : ""));
            query_map.Add("ExTaxAmount", DbMgr.CreateDoubleFieldEntry(!is_header ? _line.TaxExclusiveAmount : 0));
            query_map.Add("IncTaxAmount", DbMgr.CreateDoubleFieldEntry(!is_header ? _line.TaxInclusiveAmount : 0));
            query_map.Add("Job", DbMgr.CreateStringFieldEntry(!is_header && _line.Job != null ? _line.Job.JobName : ""));
            query_map.Add("TaxCode", DbMgr.CreateStringFieldEntry(!is_header && _line.TaxCode != null ? _line.TaxCode.Code : ""));
            query_map.Add("HoursUnits", !is_header ? (DbFieldEntry)DbMgr.CreateDoubleFieldEntry(_line.HoursUnits) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("Notes", (DbFieldEntry)DbMgr.CreateStringFieldEntry(!is_header ?  _line.Description : ""));
            query_map.Add("DetailDate", !is_header && _line.LineDate != null ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_line.LineDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("Rate", !is_header ? (DbFieldEntry)DbMgr.CreateDoubleFieldEntry(_line.TaxInclusiveRate) : DbMgr.CreateStringFieldEntry(""));
            #endregion
            return(query_map);
        }
 private DbUpdateStatement GetQuery_UpdateQuery(TimeBillingSaleLine _obj)
 {
     return(DbMgr.CreateUpdateClause("TimeBillingSaleLines", GetFields(_obj), "TimeBillingSaleLineID", _obj.TimeBillingSaleLineID));
 }
        private DbInsertStatement GetQuery_InsertQuery(TimeBillingSaleLine _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("TimeBillingSaleLines", fields));
        }