예제 #1
0
        public void CreateNewFiscalYear(string fiscalYearCode, string fiscalYearName)

        {
            bool isAdmin = AppUsers.GetCurrent().View.IsAdmin.ToBool();

            if (!isAdmin)
            {
                throw new MixERPException(Warnings.AccessIsDenied);
            }

            if (string.IsNullOrWhiteSpace(fiscalYearCode) || string.IsNullOrWhiteSpace(fiscalYearName))
            {
                throw new MixERPException(Labels.AllFieldsRequired);
            }

            string catalog  = AppUsers.GetCurrentUserDB();
            int    officeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            int    userId   = AppUsers.GetCurrent().View.UserId.ToInt();


            DateTime valueDate = DatePersister.GetFrequencyDates(catalog, officeId).Today;
            DateTime eoyDate   = DatePersister.GetFrequencyDates(catalog, officeId).FiscalYearEndDate;

            if (valueDate != eoyDate)
            {
                throw new MixERPException(Warnings.AccessIsDenied);
            }


            Data.DayOperation.EOY.CreateNewFiscalYear(catalog, officeId, userId, fiscalYearCode, fiscalYearName);
        }
예제 #2
0
        private void InitializeDate()
        {
            if (this.officeId.Equals(0))
            {
                return;
            }

            FrequencyDates model = DatePersister.GetFrequencyDates(this.Catalog, this.officeId);

            DateTime date = model.Today;

            switch (this.mode)
            {
            case FrequencyType.MonthStartDate:
                date = model.MonthStartDate;
                break;

            case FrequencyType.MonthEndDate:
                date = model.MonthEndDate;
                break;

            case FrequencyType.QuarterStartDate:
                date = model.QuarterStartDate;
                break;

            case FrequencyType.QuarterEndDate:
                date = model.QuarterEndDate;
                break;

            case FrequencyType.HalfStartDate:
                date = model.FiscalHalfStartDate;
                break;

            case FrequencyType.HalfEndDate:
                date = model.FiscalHalfEndDate;
                break;

            case FrequencyType.FiscalYearStartDate:
                date = model.FiscalYearStartDate;
                break;

            case FrequencyType.FiscalYearEndDate:
                date = model.FiscalYearEndDate;
                break;
            }


            if (this.textBox != null)
            {
                this.textBox.Text = date.ToShortDateString();
            }
        }
예제 #3
0
        public bool Reconcile(string tranCode, int year, int month, int day)
        {
            DateTime bookDate = new DateTime(year, month, day);
            string   catalog  = AppUsers.GetCurrentUserDB();
            int      officeId = AppUsers.GetCurrent().View.OfficeId.ToInt();

            FrequencyDates model = DatePersister.GetFrequencyDates(catalog, officeId);


            if (bookDate > model.FiscalYearEndDate)
            {
                throw new MixERPException(Warnings.InvalidDate);
            }

            return(Transaction.Reconcile(AppUsers.GetCurrentUserDB(), tranCode, bookDate));
        }
예제 #4
0
        public bool PostPLAppropriation(string referenceNumber, int costCenterId, string accountNumber,
                                        string statementReference)
        {
            bool isAdmin = AppUsers.GetCurrent().View.IsAdmin.ToBool();

            if (!isAdmin)
            {
                throw new MixERPException(Warnings.AccessIsDenied);
            }

            if (string.IsNullOrWhiteSpace(accountNumber))
            {
                throw new MixERPException(Warnings.InvalidAccount);
            }

            string catalog      = AppUsers.GetCurrentUserDB();
            int    officeId     = AppUsers.GetCurrent().View.OfficeId.ToInt();
            int    userId       = AppUsers.GetCurrent().View.UserId.ToInt();
            long   loginId      = AppUsers.GetCurrent().View.LoginId.ToLong();
            string currencyCode = AppUsers.GetCurrent().View.CurrencyCode;

            DateTime valueDate = DatePersister.GetFrequencyDates(catalog, officeId).Today;
            DateTime eoyDate   = DatePersister.GetFrequencyDates(catalog, officeId).FiscalYearEndDate;

            if (valueDate != eoyDate)
            {
                throw new MixERPException(Warnings.AccessIsDenied);
            }

            DateTime bookDate = valueDate;

            Collection <JournalDetail> details = new Collection <JournalDetail>();

            foreach (var item in this.GetAppropriationData())
            {
                details.Add(new JournalDetail
                {
                    Account             = item.AccountName,
                    AccountNumber       = item.AccountNumber,
                    Credit              = item.Credit,
                    Debit               = item.Debit,
                    CashRepositoryCode  = string.Empty,
                    CurrencyCode        = currencyCode,
                    ExchangeRate        = 1,
                    LocalCurrencyCredit = item.Credit,
                    LocalCurrencyDebit  = item.Debit,
                    StatementReference  = statementReference
                });

                //Reverse side to balance the journal
                decimal debit  = item.Credit;
                decimal credit = item.Debit;


                details.Add(new JournalDetail
                {
                    Account             = string.Empty,
                    AccountNumber       = accountNumber,
                    Credit              = credit,
                    Debit               = debit,
                    CashRepositoryCode  = string.Empty,
                    CurrencyCode        = currencyCode,
                    ExchangeRate        = 1,
                    LocalCurrencyCredit = credit,
                    LocalCurrencyDebit  = debit,
                    StatementReference  = statementReference + " (" + item.AccountName + ")"
                });
            }

            Transaction.Add(catalog, valueDate, bookDate, officeId, userId, loginId, costCenterId,
                            referenceNumber, details, new Collection <Attachment>());

            return(true);
        }
예제 #5
0
        public bool PostIncomeTax(string taxOfficeAccountNumber, string taxExpensesAccountNumber, int costCenterId,
                                  string referenceNumber, string statementReference)
        {
            bool isAdmin = AppUsers.GetCurrent().View.IsAdmin.ToBool();

            if (!isAdmin)
            {
                throw new MixERPException(Warnings.AccessIsDenied);
            }

            if (string.IsNullOrWhiteSpace(taxOfficeAccountNumber) || string.IsNullOrWhiteSpace(taxExpensesAccountNumber))
            {
                throw new MixERPException(Warnings.InvalidAccount);
            }

            string catalog      = AppUsers.GetCurrentUserDB();
            int    officeId     = AppUsers.GetCurrent().View.OfficeId.ToInt();
            int    userId       = AppUsers.GetCurrent().View.UserId.ToInt();
            long   loginId      = AppUsers.GetCurrent().View.LoginId.ToLong();
            string currencyCode = AppUsers.GetCurrent().View.CurrencyCode;

            decimal tax = this.GetEoyProfitSummary().Tax;

            if (tax <= 0)
            {
                return(true);
            }

            DateTime valueDate = DatePersister.GetFrequencyDates(catalog, officeId).Today;
            DateTime eoyDate   = DatePersister.GetFrequencyDates(catalog, officeId).FiscalYearEndDate;

            if (valueDate != eoyDate)
            {
                throw new MixERPException(Warnings.AccessIsDenied);
            }

            DateTime bookDate = valueDate;

            Collection <JournalDetail> details = new Collection <JournalDetail>();

            JournalDetail liability = new JournalDetail
            {
                Account             = string.Empty,
                AccountNumber       = taxOfficeAccountNumber,
                Credit              = tax,
                Debit               = 0,
                CashRepositoryCode  = string.Empty,
                CurrencyCode        = currencyCode,
                ExchangeRate        = 1,
                LocalCurrencyCredit = tax,
                LocalCurrencyDebit  = 0,
                StatementReference  = statementReference
            };

            JournalDetail expenses = new JournalDetail
            {
                Account             = string.Empty,
                AccountNumber       = taxExpensesAccountNumber,
                Credit              = 0,
                Debit               = tax,
                CashRepositoryCode  = string.Empty,
                CurrencyCode        = currencyCode,
                ExchangeRate        = 1,
                LocalCurrencyCredit = 0,
                LocalCurrencyDebit  = tax,
                StatementReference  = statementReference
            };

            details.Add(liability);
            details.Add(expenses);

            Transaction.Add(catalog, valueDate, bookDate, officeId, userId, loginId, costCenterId,
                            referenceNumber, details, new Collection <Attachment>());

            return(true);
        }
예제 #6
0
        private void RegisterJavascript()
        {
            string script = JSUtility.GetVar("culture", CultureManager.GetCurrent().Name);

            script += JSUtility.GetVar("language", CultureManager.GetCurrent().TwoLetterISOLanguageName);

            script += JSUtility.GetVar("jqueryUIi18nPath", this.Page.ResolveUrl("~/Scripts/jquery-ui/i18n"));

            script += JSUtility.GetVar("today", string.Format(CultureManager.GetCurrent(), CultureManager.GetCurrent().DateTimeFormat.ShortDatePattern, DateTime.Now));
            script += JSUtility.GetVar("now", DateTime.Now.ToString(CultureManager.GetCurrent()));
            script += JSUtility.GetVar("date", DateTime.Now.ToString(CultureInfo.InvariantCulture));

            script += JSUtility.GetVar("reportTemplatePath", PageUtility.ResolveUrl(DbConfig.GetScrudParameter(AppUsers.GetCurrentUserDB(), "TemplatePath")));
            script += JSUtility.GetVar("reportExportTemplatePath", PageUtility.ResolveUrl(DbConfig.GetScrudParameter(AppUsers.GetCurrentUserDB(), "ExportTemplatePath")));
            script += JSUtility.GetVar("reportHeaderPath", PageUtility.ResolveUrl(DbConfig.GetScrudParameter(AppUsers.GetCurrentUserDB(), "HeaderPath")));

            script += JSUtility.GetVar("userId", AppUsers.GetCurrent().View.UserId);
            script += JSUtility.GetVar("user", AppUsers.GetCurrent().View.UserName);
            script += JSUtility.GetVar("officeCode", AppUsers.GetCurrent().View.OfficeCode);
            script += JSUtility.GetVar("office", AppUsers.GetCurrent().View.OfficeName);

            script += JSUtility.GetVar("applicationDates", JsonConvert.SerializeObject(DatePersister.GetFrequencyDates(AppUsers.GetCurrentUserDB(), AppUsers.GetCurrent().View.OfficeId.ToInt())), false);
            script += JSUtility.GetVar("metaView", JsonConvert.SerializeObject(AppUsers.GetCurrent().View), false);
            script += JSUtility.GetVar("overridePath", this.OverridePath);

            script += JSUtility.GetVar("shortDateFormat", CultureManager.GetShortDateFormat());
            script += JSUtility.GetVar("longDateFormat", CultureManager.GetLongDateFormat());

            script += JSUtility.GetVar("thousandSeparator", CultureManager.GetThousandSeparator());
            script += JSUtility.GetVar("decimalSeparator", CultureManager.GetDecimalSeparator());
            script += JSUtility.GetVar("currencyDecimalPlaces", CultureManager.GetCurrencyDecimalPlaces());
            script += JSUtility.GetVar("currencySymbol", CultureManager.GetCurrencySymbol());


            script += JSUtility.GetVar("today", DateTime.Now.ToShortDateString());

            script += JSUtility.GetVar("shortDateFormat", CultureManager.GetShortDateFormat());
            script += JSUtility.GetVar("thousandSeparator", CultureManager.GetThousandSeparator());
            script += JSUtility.GetVar("decimalSeparator", CultureManager.GetDecimalSeparator());
            script += JSUtility.GetVar("currencyDecimalPlaces", CultureManager.GetCurrencyDecimalPlaces());
            script += JSUtility.GetVar("baseCurrencyCode", AppUsers.GetCurrent().View.CurrencyCode);


            script += JSUtility.GetVar("catalog", AppUsers.GetCurrentUserDB());

            script += JSUtility.GetVar("update", this.Update());

            script += JSUtility.GetVar("firstStepsPending", this.Context.Session["FirstStepsPending"]);

            script += JSUtility.GetVar("datepickerFormat", jQueryUI.GetDatePickerFormat());
            script += JSUtility.GetVar("datepickerShowWeekNumber", jQueryUI.ShowWeekNumber());
            script += JSUtility.GetVar("datepickerWeekStartDay", jQueryUI.GetWeekStartDay());
            script += JSUtility.GetVar("datepickerNumberOfMonths", jQueryUI.GetNumberOfMonths());


            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "MixERPMasterPage", script, true);
        }