Ejemplo n.º 1
0
        //public void CreateReceiveReceipt(string payedAmount, string payType, string issueDate, string bankName, Guid customerID, EntityDbHelper dbHelper)
        //{
        //    // Create ReceiveReceipt
        //    var financialYearID = new FinancialYearBL().GetUserActiveFinancialYearID();
        //    var financialGroupID = dbHelper.FetchMultiple("cmn.FinancialGroup", "IsDefault = 1", null, null, null, null).Entities[0].GetFieldValue<Guid>("ID");
        //    var lastReceiptNumber = cmn.Instance.GetFieldMaxIntValue("ReceiptNumber", "rp_ReceiveReceipts", string.Format("FinancialYear = '{0}'", financialYearID));

        //    var receiveReceipt = dbHelper.CreateNewEntity("rp.ReceiveReceipt");
        //    receiveReceipt.SetFieldValue("FinancialYear", financialYearID);
        //    receiveReceipt.SetFieldValue("FinancialGroup", financialGroupID);
        //    receiveReceipt.SetFieldValue("Payer", customerID);
        //    receiveReceipt.SetFieldValue("ReceiptDate", issueDate);
        //    receiveReceipt.SetFieldValue("TotalAmount", payedAmount);
        //    receiveReceipt.SetFieldValue("Description", "رسید دریافت از طریق وب سرویس ترازنگار");
        //    receiveReceipt.SetFieldValue("ReceiptNumber", lastReceiptNumber + 1);

        //    dbHelper.ApplyChanges(receiveReceipt);

        //    // Create ReceiveReceiptItems

        //    var receiveReceiptItem = dbHelper.CreateNewEntity("rp.ReceiveReceiptItem");
        //    receiveReceiptItem.SetFieldValue("ReceiveReceipt", receiveReceipt.GetFieldValue<Guid>("ID"));

        //    var receiveType = dbHelper.FetchSingle("rp.ReceiveType", string.Format("Name = '{0}'", payType), null);

        //    if (payType == "Havale")
        //    {
        //        if (receiveType != null)
        //        {
        //            var receiveTypeID = receiveType.GetFieldValue<Guid>("ID");
        //            receiveReceiptItem.SetFieldValue("ReceiveType", receiveTypeID);

        //            var financialOpKind = dbHelper.FetchSingle("sacc.FinancialOpKind", "Name = 'VarizBeSaderat'", null);
        //            if (financialOpKind != null)
        //            {
        //                var financialOpKindID = financialOpKind.GetFieldValue<Guid>("ID");
        //                receiveReceiptItem.SetFieldValue("FinancialOpKind", financialOpKindID);

        //                var naghdeDaryafti = dbHelper.CreateNewEntity("rp.NaghdeDaryafti");
        //                receiveReceiptItem.SetFieldValue("FinancialItem_Naghd", naghdeDaryafti.GetFieldValue<Guid>("ID"));

        //                var cash = dbHelper.FetchMultiple("sacc.Cash", null, null, null, null, null);
        //                naghdeDaryafti.SetFieldValue("Payer", customerID);
        //                naghdeDaryafti.SetFieldValue("Amount", payedAmount);
        //                naghdeDaryafti.SetFieldValue("Cash", cash.Entities[0].GetFieldValue<Guid>("ID"));

        //                naghdeDaryafti.SetFieldValue("Description", "دریافت نقدی از طریق وب سرویس");

        //                dbHelper.ApplyChanges(naghdeDaryafti);
        //                dbHelper.ApplyChanges(receiveReceiptItem);
        //            }
        //        }
        //    }
        //    else if (payType == "Naghd")
        //    {
        //        if (receiveType != null)
        //        {
        //            var receiveTypeID = receiveType.GetFieldValue<Guid>("ID");
        //            receiveReceiptItem.SetFieldValue("ReceiveType", receiveTypeID);

        //            var financialOpKind = dbHelper.FetchSingle("sacc.FinancialOpKind", "Name = 'DaryaftNaghdi'", null);
        //            if (financialOpKind != null)
        //            {
        //                var financialOpKindID = financialOpKind.GetFieldValue<Guid>("ID");
        //                receiveReceiptItem.SetFieldValue("FinancialOpKind", financialOpKindID);

        //                var naghdeDaryafti = dbHelper.CreateNewEntity("rp.NaghdeDaryafti");
        //                receiveReceiptItem.SetFieldValue("FinancialItem_Naghd", naghdeDaryafti.GetFieldValue<Guid>("ID"));

        //                var cash = dbHelper.FetchMultiple("sacc.Cash", null, null, null, null, null);
        //                naghdeDaryafti.SetFieldValue("Payer", customerID);
        //                naghdeDaryafti.SetFieldValue("Amount", payedAmount);
        //                naghdeDaryafti.SetFieldValue("Cash", cash.Entities[0].GetFieldValue<Guid>("ID"));

        //                naghdeDaryafti.SetFieldValue("Description", "دریافت نقدی از طریق وب سرویس");

        //                dbHelper.ApplyChanges(naghdeDaryafti);
        //                dbHelper.ApplyChanges(receiveReceiptItem);
        //            }
        //        }
        //    }



        //}

        public void CreateAccDoc(Entity accDocEntity, decimal payedAmount, string issueDate, EntityDbHelper dbHelper)
        {
            var balanceStatusID = OptionSetHelper.GetOptionSetItemID("acc.BalanceStatus", "Balance");
            var docStatusID     = OptionSetHelper.GetOptionSetItemID("acc.DocStatus", "NotChecked");

            var docKindID        = new DocKindBL().GetDocKindID("ComposeDoc");
            var financialYearID  = new FinancialYearBL().GetUserActiveFinancialYearID();
            var financialGroupID = dbHelper.FetchMultiple("cmn.FinancialGroup", "IsDefault = 1", null, null, null, null).Entities[0].GetFieldValue <Guid>("ID");

            accDocEntity.SetFieldValue("IssueDate", issueDate);
            accDocEntity.SetFieldValue("FinancialYear", financialYearID);
            accDocEntity.SetFieldValue("FinancialGroup", financialGroupID);
            accDocEntity.SetFieldValue("DocKind", docKindID);
            accDocEntity.SetFieldValue("IsAutoGenerated", false);
            accDocEntity.SetFieldValue("BalanceStatus", balanceStatusID);
            accDocEntity.SetFieldValue("DocStatus", docStatusID);
            accDocEntity.SetFieldValue("RemainingAmount", payedAmount);
            accDocEntity.SetFieldValue("IsActive", 1);
            accDocEntity.SetFieldValue("Description", "سند تولید شده از طریق وب سرویس");
            dbHelper.ApplyChanges(accDocEntity);
        }
Ejemplo n.º 2
0
        public Guid?GetTodayAccDoc(string docKindName, Guid financialDocTypeID, DateTime issueDate, Guid organizationUnitID)
        {
            var dbHelper = CoreComponent.Instance.MainDbHelper;

            var docKindID = new DocKindBL().GetDocKindID(docKindName);

            var accDocs = dbHelper.FetchMultiple("acc.accDoc",
                                                 string.Format("FinancialYear = '{0}' and DocKind = '{1}' and FinancialDocType = '{2}' and IssueDate = '{3}' and OrganizationUnit = '{4}'",
                                                               new FinancialYearBL().GetUserActiveFinancialYearID(), docKindID, financialDocTypeID, issueDate.ToString().Split(' ')[0], organizationUnitID),
                                                 "DocNo", null, null, null).Entities;

            if (accDocs.Count > 1)
            {
                throw new AfwException("بیش از یک سند حسابداری برای این عملیات در روز جاری ثبت شده است.");
            }
            else if (accDocs.Count == 0)
            {
                return(null);
            }
            else
            {
                return(accDocs[0].GetFieldValue <Guid?>("ID"));
            }
        }