コード例 #1
0
ファイル: EOY.asmx.cs プロジェクト: hoanien/mixerp
        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;
        }
コード例 #2
0
ファイル: JournalVoucher.asmx.cs プロジェクト: roczj/mixerp
        private static Collection<JournalDetail> GetJournalDetailCollection(string json)
        {
            Collection<JournalDetail> details = new Collection<JournalDetail>();
            var jss = new JavaScriptSerializer();

            dynamic result = jss.Deserialize<dynamic>(json);

            foreach (var item in result)
            {
                JournalDetail detail = new JournalDetail();
                detail.StatementReference = item[0];
                detail.AccountNumber = item[1];
                detail.Account = item[2];
                detail.CashRepositoryCode = item[3];
                detail.CurrencyCode = item[4];
                detail.Debit = Conversion.TryCastDecimal(item[5]);
                detail.Credit = Conversion.TryCastDecimal(item[6]);
                detail.ExchangeRate = Conversion.TryCastDecimal(item[7]);
                detail.LocalCurrencyDebit = Conversion.TryCastDecimal(item[8]);
                detail.LocalCurrencyCredit = Conversion.TryCastDecimal(item[9]);
                details.Add(detail);
            }

            return details;
        }