Beispiel #1
0
        public static Guid?GetCashAccountFromPaymentMethod(GLJournalEntrysInfo entry, Guid methodID)
        {
            GEPaymentMethodsInfo methodInfo = new GEPaymentMethodsController().GetObjectByID(methodID) as GEPaymentMethodsInfo;

            if (methodInfo == null || String.IsNullOrWhiteSpace(methodInfo.PaymentMethod))
            {
                return(null);
            }

            entry.FK_GEBankAccountID = methodInfo.FK_GEBankAccountID;
            if (methodInfo.PaymentMethod == "CashOnHand")
            {
                return(AccountingProvider.GetAccountID("1111"));
            }
            else if (methodInfo.PaymentMethod == "Advance")
            {
                return(AccountingProvider.GetAccountID("141"));
            }
            else if (methodInfo.PaymentMethod == "CashInBank")
            {
                if (methodInfo.FK_GLAccountID.HasValue)
                {
                    return(methodInfo.FK_GLAccountID.Value);
                }
                return(AccountingProvider.GetAccountID("1121"));
            }

            return(AccountingProvider.GetAccountID("1111"));
        }
Beispiel #2
0
        public static List <GLJournalEntrysInfo> GenerateCloseEntrys(Guid fromAccID, Guid toAccID, bool isIncludeChildren, DateTime?startDate, DateTime?endDate, String strConditionQuery, String strRemark)
        {
            List <GLJournalEntrysInfo> lstResults = new List <GLJournalEntrysInfo>();

            GLAccountsController accCtrl     = new GLAccountsController();
            GLAccountsInfo       fromAccount = accCtrl.GetObjectByID(fromAccID) as GLAccountsInfo;
            GLAccountsInfo       toAccount   = accCtrl.GetObjectByID(toAccID) as GLAccountsInfo;

            if (fromAccount == null || toAccount == null)
            {
                return(lstResults);
            }

            #region Current
            double dbDebitAmt  = AccountingProvider.GetDebitAmount(fromAccID, startDate, endDate, strConditionQuery, false);
            double dbCreditAmt = AccountingProvider.GetCreditAmount(fromAccID, startDate, endDate, strConditionQuery, false);
            double dbDiff      = dbDebitAmt - dbCreditAmt;
            if (dbDiff != 0)
            {
                GLJournalEntrysInfo entry = new GLJournalEntrysInfo();
                entry.Remark    = strRemark + String.Format(@" : TK {0} sang TK {1}", fromAccount.No, toAccount.No);
                entry.EntryType = ABCCommon.ABCConstString.EntryTypePeriodEnding;
                if (dbDiff > 0)
                {
                    entry.AmtTot = dbDiff;
                    entry.FK_GLAccountID_Debit  = toAccID;
                    entry.FK_GLAccountID_Credit = fromAccID;
                }
                else
                {
                    entry.AmtTot = -dbDiff;
                    entry.FK_GLAccountID_Debit  = fromAccID;
                    entry.FK_GLAccountID_Credit = toAccID;
                }
                entry.RaiseAmtTot = entry.AmtTot;
                entry.FK_GLAccountID_RaiseDebit  = entry.FK_GLAccountID_Debit;
                entry.FK_GLAccountID_RaiseCredit = entry.FK_GLAccountID_Credit;

                lstResults.Add(entry);
            }
            #endregion

            if (isIncludeChildren)
            {
                List <BusinessObject> lstChildren = accCtrl.GetListByForeignKey("FK_GLParentAccountID", fromAccount.GLAccountID);
                foreach (GLAccountsInfo child in lstChildren)
                {
                    lstResults.AddRange(GenerateCloseEntrys(child.GLAccountID, toAccID, true, startDate, endDate, strConditionQuery, strRemark));
                }
            }
            return(lstResults);
        }
Beispiel #3
0
        public static GLJournalEntrysInfo GenerateJournalEntry(BusinessObject objItem, Guid iDebitID, Guid iCreditID, double dbAmt, String strDesc)
        {
            GLJournalEntrysInfo entry = new GLJournalEntrysInfo();

            BusinessObjectHelper.CopyObject(objItem, entry, false);
            InvalidateJournalEntry(entry, null);
            entry.Remark = strDesc;

            entry.FK_GLAccountID_Debit      = iDebitID;
            entry.FK_GLAccountID_RaiseDebit = entry.FK_GLAccountID_Debit;

            entry.FK_GLAccountID_Credit      = iCreditID;
            entry.FK_GLAccountID_RaiseCredit = entry.FK_GLAccountID_Credit;

            entry.AmtTot = dbAmt;
            return(entry);
        }
Beispiel #4
0
        public static GLJournalEntrysInfo GenerateJournalEntry(BusinessObject objItem, String strDebitNo, String strCreditNo, double dbAmt, String strDesc)
        {
            GLAccountsController accCtrl = new GLAccountsController();

            GLJournalEntrysInfo entry = new GLJournalEntrysInfo();

            BusinessObjectHelper.CopyObject(objItem, entry, false);
            InvalidateJournalEntry(entry, null);
            entry.Remark = strDesc;

            entry.FK_GLAccountID_Debit      = ABCHelper.DataConverter.ConvertToGuid(accCtrl.GetIDByNo(strDebitNo));
            entry.FK_GLAccountID_RaiseDebit = entry.FK_GLAccountID_Debit;

            entry.FK_GLAccountID_Credit      = ABCHelper.DataConverter.ConvertToGuid(accCtrl.GetIDByNo(strCreditNo));
            entry.FK_GLAccountID_RaiseCredit = entry.FK_GLAccountID_Credit;

            entry.AmtTot = dbAmt;
            return(entry);
        }
Beispiel #5
0
        public static void InvalidateJournalEntry(GLJournalEntrysInfo entry, GLJournalVouchersInfo voucher, BusinessObject objSourceObj)
        {
            BusinessObjectHelper.CopyFKFields(objSourceObj, entry, true);
            BusinessObjectHelper.CopyFKFields(voucher, entry, true);
            BusinessObjectHelper.CopyField(objSourceObj, entry, "JournalDate", false);

            BusinessObjectHelper.CopyField(objSourceObj, entry, "Voucher", false);
            BusinessObjectHelper.CopyField(objSourceObj, entry, "VoucherContent", false);
            BusinessObjectHelper.CopyField(objSourceObj, entry, "VoucherDate", false);

            if (String.IsNullOrWhiteSpace(entry.EntryType))
            {
                entry.EntryType = ABCCommon.ABCConstString.EntryTypeERP;
            }
            entry.RaiseAmtTot = entry.AmtTot;

            entry.FK_GLAccountID_RaiseCredit = entry.FK_GLAccountID_Credit;
            entry.FK_GLAccountID_RaiseDebit  = entry.FK_GLAccountID_Debit;

            InvalidateJournalEntry(entry, voucher);
        }
Beispiel #6
0
        public static List <GLJournalEntrysInfo> GenerateJournalEntrys(GLBatchEntryConfigsInfo batchConfig)
        {
            List <GLJournalEntrysInfo> lstResults = new List <GLJournalEntrysInfo>();

            GLBatchEntryConfigItemsController itemConfigCtrl = new GLBatchEntryConfigItemsController();
            List <BusinessObject>             lstItemConfigs = itemConfigCtrl.GetListFromDataset(itemConfigCtrl.GetDataSetByForeignKey("FK_GLBatchEntryConfigID", batchConfig.GLBatchEntryConfigID));

            foreach (GLBatchEntryConfigItemsInfo item in lstItemConfigs)
            {
                if (String.IsNullOrWhiteSpace(item.Expression))
                {
                    continue;
                }

                GLJournalEntrysInfo entry = new GLJournalEntrysInfo();
                entry.FK_GLAccountID_Debit  = item.FK_GLAccountID_Debit;
                entry.FK_GLAccountID_Credit = item.FK_GLAccountID_Credit;
                entry.Remark           = item.Remark;
                entry.FK_COCostGroupID = item.FK_COCostGroupID;
                entry.CostType         = item.CostType;
                if (batchConfig.JournalDate.HasValue)
                {
                    entry.JournalDate = batchConfig.JournalDate.Value;
                }
                else if (batchConfig.VoucherDate.HasValue)
                {
                    entry.JournalDate = batchConfig.VoucherDate.Value;
                }
                else
                {
                    entry.JournalDate = new DateTime();
                }

                entry.VoucherDate    = batchConfig.VoucherDate;
                entry.Voucher        = batchConfig.Voucher;
                entry.VoucherContent = batchConfig.VoucherContent;

                #region AmtTot
                String strExpression = item.Expression;
                for (int i = 1; i <= 20; i++)
                {
                    strExpression = strExpression.Replace("{" + i + "}", "[" + i + "]");
                }

                try
                {
                    Expression e = new Expression(strExpression);

                    for (int i = 1; i <= 20; i++)
                    {
                        if (strExpression.Contains("[" + i + "]"))
                        {
                            object objValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(batchConfig, "Param" + i);
                            e.Parameters[i.ToString()] = Convert.ToDouble(objValue);
                        }
                    }

                    object objAmt = e.Evaluate();
                    entry.AmtTot = Math.Round(Convert.ToDouble(objAmt), 3);
                }
                catch (Exception ex)
                {
                    ABCHelper.ABCMessageBox.Show(String.Format("Công thức cho nghiệp vụ '{0}' không đúng !", item.Remark), "Thông báo", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    continue;
                }
                #endregion

                if (entry.AmtTot > 0)
                {
                    lstResults.Add(entry);
                }
            }

            return(lstResults);
        }
Beispiel #7
0
        public static void InvalidateJournalEntry(GLJournalEntrysInfo entry, GLJournalVouchersInfo voucher)
        {
            if (entry == null)
            {
                return;
            }

            if (voucher != null)
            {
                BusinessObjectHelper.CopyFKFields(voucher, entry, true);

                entry.FK_GLJournalVoucherID = voucher.GLJournalVoucherID;
                entry.ApprovalStatus        = voucher.ApprovalStatus;
                entry.JournalDate           = voucher.JournalDate;

                if (String.IsNullOrWhiteSpace(entry.Voucher))
                {
                    entry.Voucher = voucher.Voucher;
                }

                if (String.IsNullOrWhiteSpace(entry.VoucherContent))
                {
                    entry.VoucherContent = voucher.VoucherContent;
                }

                if (entry.VoucherDate.HasValue == false)
                {
                    entry.VoucherDate = voucher.VoucherDate;
                }
            }

            if (entry.EntryType == ABCCommon.ABCConstString.EntryTypeERP)
            {
                if (entry.RaiseAmtTot != entry.AmtTot || entry.FK_GLAccountID_RaiseDebit.HasValue == false || entry.FK_GLAccountID_RaiseDebit.Value != entry.FK_GLAccountID_Debit ||
                    entry.FK_GLAccountID_RaiseCredit.HasValue == false || entry.FK_GLAccountID_RaiseCredit.Value != entry.FK_GLAccountID_Credit)
                {
                    entry.EntryType = ABCCommon.ABCConstString.EntryTypeERPModified;
                }
            }
            if (String.IsNullOrWhiteSpace(entry.EntryType))
            {
                entry.EntryType = ABCCommon.ABCConstString.EntryTypeNormal;
            }

            #region ObjectDesc
            entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_ASFixedAssetID", entry.FK_ASFixedAssetID);
            if (String.IsNullOrWhiteSpace(entry.ObjectDesc))
            {
                entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_HREmployeeID", entry.FK_HREmployeeID);
            }
            if (String.IsNullOrWhiteSpace(entry.ObjectDesc))
            {
                entry.ObjectDesc = BusinessObjectHelper.GetNameValue("MAPartners", entry.FK_MAPartnerID);
            }
            if (String.IsNullOrWhiteSpace(entry.ObjectDesc))
            {
                entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_GECompanyUnitID", entry.FK_GECompanyUnitID);
            }

            if (String.IsNullOrWhiteSpace(entry.ObjectDesc))
            {
                entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_GLMonitorObjectID", entry.FK_GLMonitorObjectID);
            }
            if (String.IsNullOrWhiteSpace(entry.ObjectDesc))
            {
                entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_PMProjectID", entry.FK_PMProjectID);
            }
            if (String.IsNullOrWhiteSpace(entry.ObjectDesc))
            {
                entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_COCostGroupID", entry.FK_COCostGroupID);
            }
            if (String.IsNullOrWhiteSpace(entry.ObjectDesc))
            {
                entry.ObjectDesc = BusinessObjectHelper.GetNameValue("FK_GEBankAccountID", entry.FK_GEBankAccountID);
            }
            #endregion
        }