Exemplo n.º 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;
            }
        }
Exemplo n.º 2
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;
            }
        }