Example #1
0
        public override XPCollection <GeneralJournal> GetActuallyCollectedOfBill(Session session, Guid billId)
        {
            try
            {
                XPCollection <GeneralJournal> ret = null;
                ObjectBO    objectBO = new ObjectBO();
                List <Guid> billIds  = new List <Guid>();
                billIds.Add(billId);

                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session,
                                                     DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SALE_INVOICE);

                var relatedObjectList =
                    objectBO.FindCMSObjectsOfBuiltInCustomField(
                        session,
                        objectTypeCustomField.ObjectTypeCustomFieldId,
                        billIds);

                if (relatedObjectList == null)
                {
                    return(null);
                }

                var relatedObjectIdList = relatedObjectList.Select(r => r.ObjectId);

                XPCollection <ReceiptVouchesTransaction> receiptVouchesTransactions
                    = new XPCollection <ReceiptVouchesTransaction>(session,
                                                                   new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual));

                CriteriaOperator criteria = CriteriaOperator.And(
                    new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_TEMP, BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("Debit", 0, BinaryOperatorType.Greater),
                    new ContainsOperator("GeneralJournalObjects",
                                         new InOperator("ObjectId.ObjectId", relatedObjectIdList)));

                ret = new XPCollection <GeneralJournal>(session,
                                                        receiptVouchesTransactions.SelectMany(r => r.GeneralJournals), criteria);

                //var generalJournalObjects =
                //    receiptVouchesTransactions
                //    .SelectMany(r => r.GeneralJournals)
                //    .SelectMany(r => r.GeneralJournalObjects)
                //    .Where(r => r.GeneralJournalId.RowStatus >= Utility.Constant.ROWSTATUS_TEMP
                //        && relatedObjectIdList.Contains(r.ObjectId.ObjectId));

                //ret = new XPCollection<GeneralJournal>(session,
                //    generalJournalObjects.Select(r => r.GeneralJournalId));

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// Get supplier that allocated for the ReceiptVouchesTransaction
        /// </summary>
        /// <param name="session">DevExpress.Xpo.Session</param>
        /// <param name="transactionId">Id of type ReceiptVouchesTransaction</param>
        /// <returns></returns>
        public Organization GetAllocatedSupplier(Session session, Guid transactionId)
        {
            Organization ret = null;

            try
            {
                ReceiptVouchesTransaction transaction =
                    session.GetObjectByKey <ReceiptVouchesTransaction>(transactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SUPPLIER);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <Organization>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public InventoryCommand GetAllocatedInputInventoryCommandByManualTransaction(Session session, Guid manualBookingTransactionId)
        {
            InventoryCommand ret = null;

            try
            {
                Transaction transaction =
                    session.GetObjectByKey <Transaction>(manualBookingTransactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_INPUT_INVENTORY_COMMAND);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <InventoryCommand>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public NAS.DAL.Invoice.PurchaseInvoice GetAllocatedPurchaseInvoiceByManualTransaction(Session session, Guid manualBookingTransactionId)
        {
            NAS.DAL.Invoice.PurchaseInvoice ret = null;
            try
            {
                Transaction transaction =
                    session.GetObjectByKey <Transaction>(manualBookingTransactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_PURCHASE_INVOICE);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <NAS.DAL.Invoice.PurchaseInvoice>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public NAS.DAL.Invoice.PurchaseInvoice GetAllocatedPurchaseInvoiceByInventoryCommand(Session session, Guid inventoryCommandId)
        {
            NAS.DAL.Invoice.PurchaseInvoice ret = null;
            try
            {
                InventoryCommand command =
                    session.GetObjectByKey <InventoryCommand>(inventoryCommandId);
                InventoryCommandObject commandObject = command.InventoryCommandObjects.First();
                if (commandObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.INVENTORY_IN_PURCHASE_INVOICE);

                ObjectCustomField objectCustomField = commandObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <NAS.DAL.Invoice.PurchaseInvoice>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
0
        public NAS.DAL.Nomenclature.Organization.Organization GetAllocatedCustomerByManualTransaction(Session session, Guid manualBookingTransactionId)
        {
            NAS.DAL.Nomenclature.Organization.Organization ret = null;
            try
            {
                Transaction transaction =
                    session.GetObjectByKey <Transaction>(manualBookingTransactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.First();
                if (transactionObject == null)
                {
                    return(null);
                }
                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session, DefaultObjectTypeCustomFieldEnum.MANUAL_BOOKING_CUSTOMER);

                ObjectCustomField objectCustomField = transactionObject.ObjectId.ObjectCustomFields.Where(
                    r => r.ObjectTypeCustomFieldId.ObjectTypeCustomFieldId ==
                    objectTypeCustomField.ObjectTypeCustomFieldId).FirstOrDefault();
                if (objectCustomField == null)
                {
                    return(null);
                }

                ObjectCustomFieldData objectCustomFieldData =
                    objectCustomField.ObjectCustomFieldDatas.FirstOrDefault();
                if (objectCustomFieldData == null)
                {
                    return(null);
                }

                PredefinitionData predefinitionData =
                    (PredefinitionData)objectCustomFieldData.CustomFieldDataId;

                ret = session.GetObjectByKey <NAS.DAL.Nomenclature.Organization.Organization>(predefinitionData.RefId);

                return(ret);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        private void LinkVoucherWithBill(Session _session, Guid _billId, Vouches voucher)
        {
            ObjectCustomFieldBO objectCustomFieldBO = new ObjectCustomFieldBO();

            ObjectTypeCustomField defaultObjectTypeCustomField =
                ObjectTypeCustomField.GetDefault(_session, DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SALE_INVOICE);

            ObjectCustomField objectCustomField = voucher.VoucherObjects.First().ObjectId.ObjectCustomFields
                                                  .Where(r => r.ObjectTypeCustomFieldId.Equals(defaultObjectTypeCustomField)).First();

            List <Guid> billId = new List <Guid>();

            billId.Add(_billId);

            objectCustomFieldBO.UpdatePredefinitionData(
                objectCustomField.ObjectCustomFieldId,
                billId,
                PredefinitionCustomFieldTypeEnum.SINGLE_CHOICE_LIST_INVOICE_SALE,
                CustomFieldTypeFlag.CUSTOM_FIELD_TYPE_MASTER_READONLY);
        }
Example #8
0
        public override XPCollection <Transaction> GetRelatedTransactionsWithBill(Session session, Guid billId)
        {
            try
            {
                XPCollection <Transaction> ret = null;
                ObjectBO    objectBO           = new ObjectBO();
                List <Guid> billIds            = new List <Guid>();
                billIds.Add(billId);

                ObjectTypeCustomField objectTypeCustomField =
                    ObjectTypeCustomField.GetDefault(session,
                                                     DefaultObjectTypeCustomFieldEnum.RECEIPT_VOUCHER_SALE_INVOICE);

                var relatedObjectList =
                    objectBO.FindCMSObjectsOfBuiltInCustomField(
                        session,
                        objectTypeCustomField.ObjectTypeCustomFieldId,
                        billIds);

                if (relatedObjectList == null)
                {
                    return(null);
                }

                var relatedObjectIdList = relatedObjectList.Select(r => r.ObjectId);

                CriteriaOperator criteria = CriteriaOperator.And(
                    new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual),
                    new ContainsOperator("TransactionObjects",
                                         new InOperator("ObjectId.ObjectId", relatedObjectIdList)));

                ret = new XPCollection <Transaction>(session,
                                                     new XPCollection <ReceiptVouchesTransaction>(session), criteria);

                return(ret);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #9
0
        /// <summary>
        /// Lấy chứng từ phiếu gốc của phiếu xuất/nhập/chuyển kho
        /// </summary>
        /// <param name="uow"></param>
        /// <param name="_InventoryCommandId"></param>
        /// <returns></returns>
        public Bill GetSourceArtifactFromInventoryCommand(
            UnitOfWork uow,
            Guid _InventoryCommandId)
        {
            InventoryCommand command = uow.GetObjectByKey <InventoryCommand>(_InventoryCommandId);

            if (command == null)
            {
                throw new Exception("The InventoryCommand is not exist in system");
            }

            ObjectTypeCustomField ArtifactTypeCustomField = null;
            ObjectCustomField     ArtifactCustomField     = null;
            Bill billArtifact = null;

            if (command.CommandType.Equals(INVENTORY_COMMAND_TYPE.OUT))
            {
                ArtifactTypeCustomField =
                    ObjectTypeCustomField.GetDefault(uow, DefaultObjectTypeCustomFieldEnum.INVENTORY_OUT_SALE_INVOICE);
                try
                {
                    ArtifactCustomField = command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields
                                          .Where(r => r.ObjectTypeCustomFieldId.Equals(ArtifactTypeCustomField)).First();
                }
                catch (Exception)
                {
                    if (ArtifactCustomField == null)
                    {
                        return(null);
                    }
                }
            }
            else if (command.CommandType.Equals(INVENTORY_COMMAND_TYPE.IN))
            {
                ArtifactTypeCustomField =
                    ObjectTypeCustomField.GetDefault(uow, DefaultObjectTypeCustomFieldEnum.INVENTORY_IN_PURCHASE_INVOICE);
                try
                {
                    //ArtifactCustomField = command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields
                    //.Where(r => r.ObjectTypeCustomFieldId.Equals(ArtifactTypeCustomField)).First();

                    foreach (ObjectCustomField cf in command.InventoryCommandObjects.First().ObjectId.ObjectCustomFields)
                    {
                        if (cf.ObjectTypeCustomFieldId.Code != null && cf.ObjectTypeCustomFieldId.Code.Equals(ArtifactTypeCustomField.Code))
                        {
                            ArtifactCustomField = cf;
                        }
                    }
                }
                catch (Exception)
                {
                    if (ArtifactCustomField == null)
                    {
                        return(null);
                    }
                }
            }
            else
            {
                return(null);
            }

            if (ArtifactCustomField != null)
            {
                try
                {
                    billArtifact = uow.GetObjectByKey <Bill>((ArtifactCustomField.ObjectCustomFieldDatas.First().CustomFieldDataId as PredefinitionData).RefId);
                }
                catch (Exception)
                {
                    billArtifact = null;
                }
            }
            return(billArtifact);
        }