Exemple #1
0
        public void Run(IHR1Context db, AccountingEntity accountingEntity)
        {
            var amtInput = new JournalTemplateInput()
            {
                AppTenantID   = accountingEntity.AppTenantID,
                Name          = "Salary",
                UserInputType = db.UserInputTypes.First(x => x.Code == "CURRENCY")
            };

            var template = new JournalTemplate();

            template.AppTenantID = accountingEntity.AppTenantID;
            template.JournalType = db.JournalTypes.First(x => x.Code == "PAYSTUB");
            template.Name        = "Salary";
            template.OriginKey   = "EmploymentContract";
            template.UserInputs.Add(amtInput);


            var templateTxn = new JournalTemplateTxn();

            templateTxn.AppTenantID    = accountingEntity.AppTenantID;
            templateTxn.AmountInput    = amtInput;
            templateTxn.Description    = "Salary";
            templateTxn.JournalTxnType = template.JournalType.JournalTxnTypes.First(x => x.IsCode == "AMT");

            template.JournalTemplateTxns.Add(templateTxn);

            accountingEntity.JournalTemplates.Add(template);
        }
Exemple #2
0
        private JournalTemplate CreateExpenseTemplate(AccountingEntity entity, IDbContext dataContext, LedgerAccount payableAcct, LedgerAccount expenseAcct)
        {
            var template = new JournalTemplate();

            template.AppTenantID = entity.AppTenantID;
            template.JournalType = dataContext.Set <JournalType>().Single(x => x.Code == "SEXP");
            template.OriginKey   = "ProviderAccount";
            template.Name        = "Service Expense";

            JournalTemplateInput refInput = new JournalTemplateInput();

            refInput.Name          = "Reference";
            refInput.AppTenantID   = entity.AppTenantID;
            refInput.Description   = "";
            refInput.UserInputType = dataContext.Set <UserInputType>().Single(x => x.Code == "TEXT");
            template.UserInputs.Add(refInput);

            JournalTemplateInput amtInput = new JournalTemplateInput();

            amtInput.Name          = "Amount";
            amtInput.AppTenantID   = entity.AppTenantID;
            amtInput.Description   = "";
            amtInput.UserInputType = dataContext.Set <UserInputType>().Single(x => x.Code == "CURRENCY");
            template.UserInputs.Add(amtInput);

            //template.ReferenceInput = refInput;

            JournalTemplateTxn mainTxn = new JournalTemplateTxn();

            mainTxn.AppTenantID         = entity.AppTenantID;
            mainTxn.AmountInput         = amtInput;
            mainTxn.Description         = "Service Expense";
            mainTxn.PrimaryFactorSource = "INPUT";
            mainTxn.IncludeInTotal      = true;
            mainTxn.JournalTxnType      = template.JournalType.JournalTxnTypes.Single(x => x.PrimaryFactorCode == "AMT" && x.SecondaryFactorCode == null);
            mainTxn.Postings.Add(new JournalTemplateTxnPosting()
            {
                AppTenantID = entity.AppTenantID, AddBaseAmount = true, LedgerAccount = payableAcct, PostType = "C"
            });
            mainTxn.Postings.Add(new JournalTemplateTxnPosting()
            {
                AppTenantID = entity.AppTenantID, AddBaseAmount = true, LedgerAccount = expenseAcct, PostType = "D"
            });
            template.JournalTemplateTxns.Add(mainTxn);


            JournalTemplateTxn splitTxn = new JournalTemplateTxn();

            splitTxn.AppTenantID           = entity.AppTenantID;
            splitTxn.AmountInput           = amtInput;
            splitTxn.Description           = "Split";
            splitTxn.SecondaryFactorSource = "INPUT";
            splitTxn.IncludeInTotal        = false;
            splitTxn.JournalTxnType        = template.JournalType.JournalTxnTypes.Single(x => x.PrimaryFactorCode == "PART" && x.SecondaryFactorCode == "AMT");
            template.JournalTemplateTxns.Add(splitTxn);

            dataContext.Set <JournalTemplate>().Add(template);
            return(template);
        }
Exemple #3
0
        public int AddUpdate(JournalTemplate Template, string SessionUserId)
        {
            if (Template == null || string.IsNullOrEmpty(SessionUserId))
            {
                return(0);
            }

            return(_templateRepository.AddUpdate(Template, SessionUserId));
        }
Exemple #4
0
 public int AddUpdate(JournalTemplate Template, string SessionUserId)
 {
     using (var connection = new SqlConnection(base.ConnectionString))
     {
         return(Task.FromResult(connection.ExecuteScalar <int>("spJournalTemplateAddUpdate",
                                                               new
         {
             @JOURNALTEMPLATEID = Template.TemplateId,
             @NAME = Template.Name,
             @TEMPLATEURI = Template.TemplateUri,
             @ISPREMIUM = Template.IsPremium,
             @PRICE = Template.Price,
             @SESSIONUSERID = SessionUserId
         },
                                                               null,
                                                               null,
                                                               CommandType.StoredProcedure)).Result);
     }
 }
Exemple #5
0
 public void OnChangeJournalTemplate(JournalTemplate entity, UpdateOperations operations)
 {
     InterceptChange(entity, operations);
 }