示例#1
0
        private DbDeleteStatement GetQuery_DeleteQuery(ProfessionalPurchaseLine _obj)
        {
            DbDeleteStatement clause = DbMgr.CreateDeleteClause();

            clause.DeleteFrom("ProfessionalPurchaseLines").Criteria.IsEqual("ProfessionalPurchaseLines", "ProfessionalPurchaseLineID", _obj.ProfessionalPurchaseLineID);

            return(clause);
        }
示例#2
0
        protected override OpResult _Delete(ProfessionalPurchaseLine _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyDeleteAction(OpResult.ResultStatus.ObjectIsNull, _obj, "ProfessionalPurchaseLine, 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 BOProfessionalPurchaseLine(Accountant accountant, Purchase _purchase, ProfessionalPurchaseLine _line, BOContext context)
            : base(accountant, _purchase, _line, context)
        {
            mObjectID           = BOType.BOProfessionalPurchaseLine;
            mDataProxy          = _line.Clone() as ProfessionalPurchaseLine;
            mDataProxy.Purchase = _purchase;

            if (mDataProxy.Purchase.IsTaxInclusive == "Y")
            {
                mAmount = mDataProxy.TaxInclusiveAmount;
            }
            else
            {
                mAmount = mDataProxy.TaxExclusiveAmount;
            }
        }
        private void StoreLines(Purchase _obj)
        {
            IList <PurchaseLine> lines = _obj.PurchaseLines;

            foreach (PurchaseLine line in lines)
            {
                RepositoryMgr.PurchaseLineMgr.Store(line);
                int?purchase_id      = line.PurchaseID;
                int?purchase_line_id = line.PurchaseLineID;
                if (line is ItemPurchaseLine)
                {
                    ItemPurchaseLine _line = line as ItemPurchaseLine;
                    _line.PurchaseID         = purchase_id;
                    _line.ItemPurchaseLineID = purchase_line_id;
                    RepositoryMgr.ItemPurchaseLineMgr.Store(_line);
                }
                else if (line is MiscPurchaseLine)
                {
                    MiscPurchaseLine _line = line as MiscPurchaseLine;
                    _line.PurchaseID         = purchase_id;
                    _line.MiscPurchaseLineID = purchase_line_id;
                    RepositoryMgr.MiscPurchaseLineMgr.Store(_line);
                }
                else if (line is ProfessionalPurchaseLine)
                {
                    ProfessionalPurchaseLine _line = line as ProfessionalPurchaseLine;
                    _line.PurchaseID = purchase_id;
                    _line.ProfessionalPurchaseLineID = purchase_line_id;
                    RepositoryMgr.ProfessionalPurchaseLineMgr.Store(_line);
                }
                else if (line is ServicePurchaseLine)
                {
                    ServicePurchaseLine _line = line as ServicePurchaseLine;
                    _line.PurchaseID            = purchase_id;
                    _line.ServicePurchaseLineID = purchase_line_id;
                    RepositoryMgr.ServicePurchaseLineMgr.Store(_line);
                }
                else if (line is TimeBillingPurchaseLine)
                {
                    TimeBillingPurchaseLine _line = line as TimeBillingPurchaseLine;
                    _line.PurchaseID = purchase_id;
                    _line.TimeBillingPurchaseLineID = purchase_line_id;
                    RepositoryMgr.TimeBillingPurchaseLineMgr.Store(_line);
                }
            }
        }
示例#5
0
        protected override OpResult _Store(ProfessionalPurchaseLine _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "ProfessionalPurchaseLine 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.ProfessionalPurchaseLineID == null)
            {
                _obj.ProfessionalPurchaseLineID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;
            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
示例#6
0
        private Dictionary <string, DbFieldEntry> GetQueryMap_StoreProfessionalPurchaseLines(Purchase _purchase, ProfessionalPurchaseLine _line)
        {
            bool is_header = (_line == null);
            Dictionary <string, DbFieldEntry> query_map = new Dictionary <string, DbFieldEntry>();

            bool multi_currency_support = _purchase.RepositoryMgr.CurrencyMgr.SupportMultiCurrency;

            #region Populate Purchase Information
            query_map.Add("FirstName", DbMgr.CreateStringFieldEntry(is_header && _purchase.Supplier != null ? _purchase.Supplier.FirstName : ""));
            query_map.Add("CoLastName", DbMgr.CreateStringFieldEntry(is_header && _purchase.Supplier != null ? _purchase.Supplier.LastName : ""));
            query_map.Add("CardID", DbMgr.CreateStringFieldEntry(is_header && _purchase.Supplier != null ? _purchase.Supplier.CardIdentification : ""));
            query_map.Add("PurchaseNumber", DbMgr.CreateStringFieldEntry(is_header ? _purchase.PurchaseNumber : ""));
            query_map.Add("Memo", DbMgr.CreateStringFieldEntry(is_header ? _purchase.Memo : ""));
            query_map.Add("Inclusive", DbMgr.CreateStringFieldEntry(is_header && _purchase.IsTaxInclusive == "Y" ? "1" : ""));
            query_map.Add("PurchaseDate", _purchase.PurchaseDate != null && is_header ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_purchase.PurchaseDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("DeliveryStatus", DbMgr.CreateStringFieldEntry(is_header & _purchase.InvoiceDelivery != null ? _purchase.InvoiceDelivery.InvoiceDeliveryID : ""));
            query_map.Add("PromisedDate", is_header && _purchase.PromisedDate != null ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_purchase.PromisedDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            query_map.Add("Comment", DbMgr.CreateStringFieldEntry(is_header && _purchase.Comment != null ? _purchase.Comment : ""));

            string purchase_status_text = "";
            Status purchase_status      = _purchase.PurchaseStatus;
            if (is_header && purchase_status != null)
            {
                if (purchase_status.Type == Status.StatusType.Quote)
                {
                    purchase_status_text = "Q";
                }
                else if (purchase_status.Type == Status.StatusType.Order)
                {
                    purchase_status_text = "O";
                }
                else if (purchase_status.Type == Status.StatusType.Open)
                {
                    purchase_status_text = "B";
                }
            }
            query_map.Add("PurchaseStatus", DbMgr.CreateStringFieldEntry(purchase_status_text));

            if (_purchase.PurchaseStatus.Type == Accounting.Core.Definitions.Status.StatusType.Order ||
                _purchase.PurchaseStatus.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 && _purchase.Currency != null ? _purchase.Currency.CurrencyCode : ""));
                query_map.Add("ExchangeRate", DbMgr.CreateDoubleFieldEntry(is_header && RepositoryMgr.IsMultiUserVersion ? _purchase.TransactionExchangeRate : 0));
            }
            query_map.Add("PaymentIsDue", DbMgr.CreateIntFieldEntry(is_header && _purchase.Terms != null ? _purchase.Terms.PaymentIsDue : 0));
            query_map.Add("DiscountDays", DbMgr.CreateIntFieldEntry(is_header && _purchase.Terms != null ? _purchase.Terms.DiscountDays : 0));
            query_map.Add("BalanceDueDays", DbMgr.CreateIntFieldEntry(is_header && _purchase.Terms != null ? _purchase.Terms.BalanceDueDays : 0));
            query_map.Add("PercentDiscount", DbMgr.CreateDoubleFieldEntry(is_header && _purchase.Terms != null ? _purchase.Terms.EarlyPaymentDiscountPercent : 0));
            //query_map.Add("PercentMonthlyCharge", DbMgr.CreateDoubleFieldEntry(is_header && _purchase.Terms != null ? _purchase.Terms.LatePaymentChargePercent : 0));
            #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 : ""));
            query_map.Add("DetailDate", !is_header && _line.LineDate != null ? (DbFieldEntry)DbMgr.CreateDateTimeFieldEntry(_line.LineDate) : (DbFieldEntry)DbMgr.CreateStringFieldEntry(""));
            #endregion

            return(query_map);
        }
示例#7
0
 private DbUpdateStatement GetQuery_UpdateQuery(ProfessionalPurchaseLine _obj)
 {
     return(DbMgr.CreateUpdateClause("ProfessionalPurchaseLines", GetFields(_obj), "ProfessionalPurchaseLineID", _obj.ProfessionalPurchaseLineID));
 }
示例#8
0
        private DbInsertStatement GetQuery_InsertQuery(ProfessionalPurchaseLine _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

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