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

            clause.DeleteFrom("ServiceSaleLines").Criteria.IsEqual("ServiceSaleLines", "ServiceSaleLineID", _obj.ServiceSaleLineID);

            return(clause);
        }
        protected override OpResult _Delete(ServiceSaleLine _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.ObjectIsNull, _obj, "ServiceSaleLine 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, "ServiceSaleLine object cannot be deleted as it does not exist"));;
        }
Exemple #3
0
        public BOServiceSaleLine(Accountant accountant, Sale _sale, ServiceSaleLine _line, BOContext context)
            : base(accountant, _sale, _line, context)
        {
            mObjectID             = BOType.BOServiceSaleLine;
            mServiceSaleLine      = _line.Clone() as ServiceSaleLine;
            mServiceSaleLine.Sale = _sale;

            if (mServiceSaleLine.Sale.IsTaxInclusive == "Y")
            {
                mAmount = mServiceSaleLine.TaxInclusiveAmount;
            }
            else
            {
                mAmount = mServiceSaleLine.TaxExclusiveAmount;
            }
        }
        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(ServiceSaleLine _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "ServiceSaleLine 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.ServiceSaleLineID == null)
            {
                _obj.ServiceSaleLineID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;
            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
Exemple #6
0
        private Dictionary <string, DbFieldEntry> GetQueryMap_StoreServiceSaleLines(Sale _sale, ServiceSaleLine _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("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("ShippingDate", 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 : ""));
            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("FreightExTaxAmount", DbMgr.CreateDoubleFieldEntry(is_header ? _sale.TaxExclusiveFreight : 0));
            query_map.Add("FreightIncTaxAmount", DbMgr.CreateDoubleFieldEntry(is_header ? _sale.TaxInclusiveFreight : 0));
            query_map.Add("FreightTaxCode", DbMgr.CreateStringFieldEntry(is_header && _sale.FreightTaxCode != null ? _sale.FreightTaxCode.Code : ""));
            #endregion

            #region Populate Line Information
            query_map.Add("AccountNumber", !is_header ? GetAccountNumber(_line.Account) : 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 : ""));
            #endregion

            return(query_map);
        }
 private DbUpdateStatement GetQuery_UpdateQuery(ServiceSaleLine _obj)
 {
     return(DbMgr.CreateUpdateClause("ServiceSaleLines", GetFields(_obj), "ServiceSaleLineID", _obj.ServiceSaleLineID));
 }
        private DbInsertStatement GetQuery_InsertQuery(ServiceSaleLine _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

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