protected virtual void BuildTxn(IDbContext db, TScheduledJournal scheduledJournal, IPartyRole resolvedRole, TJournal journal, TJournalTemplateTxn templateTxn, decimal percentage) { var split = ResolveSubSplit(db, scheduledJournal, resolvedRole, templateTxn); foreach (var item in split) { TJournalTxn txn = new TJournalTxn(); CreateJournalTxn(db, scheduledJournal, templateTxn, percentage, item, txn); journal.JournalTxns.Add(txn); } }
protected virtual IEnumerable <ResolvedSubSplit> ResolveSubSplit(IDbContext db, TScheduledJournal scheduledJournal, IPartyRole resolvedRole, TJournalTemplateTxn templateTxn) { List <ResolvedSubSplit> result = new List <ResolvedSubSplit>(); result.Add(new ResolvedSubSplit() { Role = resolvedRole, Percentage = 1 }); //default return(result); }
protected virtual TJournal BuildJournal(IDbContext db, TScheduledJournal scheduledJournal, IPartyRole resolvedRole, decimal percentage) { TJournal journal = new TJournal(); var template = scheduledJournal.JournalTemplate; journal.AppTenantID = scheduledJournal.AppTenantID; journal.Description = scheduledJournal.Description; journal.JournalType = template.JournalType; journal.AccountingEntity = scheduledJournal.AccountingEntity; //journal.TransactionOrigin = scheduledJournal.TransactionOrigin; //journal.Public = resolvedParty; journal.TxnDate = scheduledJournal.TxnDate.Value.Date; journal.Reference = ResolveReference(db, scheduledJournal); db.Set <TJournal>().Add(journal); foreach (var templateTxn in template.JournalTemplateTxns) { //if (templateTxn.JournalTxnType.IsCode) BuildTxn(db, scheduledJournal, resolvedRole, journal, templateTxn, percentage); } journal.Amount = journal.JournalTxns.Where(x => x.IncludeInTotal).Sum(x => x.Amount); return(journal); }
public BaseJournal BuildJournal(IDbContext db, BaseScheduledJournal scheduledJournal, IPartyRole resolvedRole, decimal percentage) { return(BuildJournal(db, (scheduledJournal as TScheduledJournal), resolvedRole, percentage)); }
protected virtual decimal?ResolveOfFactor(IDbContext db, TScheduledJournal scheduledJournal, IPartyRole resolvedRole, TJournalTemplateTxn templateTxn) { decimal?result = null; switch (templateTxn.JournalTxnType.SecondaryFactorCode) { case null: result = 1; break; case "PERC": case "AMT": switch (templateTxn.SecondaryFactorSource) { case "TEMPLATE": result = templateTxn.Amount; break; case "INPUT": if (templateTxn.AmountInputID.HasValue) { var amountInput = scheduledJournal.UserInputValues.First(x => x.JournalTemplateInputID == templateTxn.AmountInputID); result = Convert.ToDecimal(amountInput.Value); } break; case "CONTEXT": //if (templateTxn.AmountContextParameterID.HasValue) //{ // result = ResolveContextParameter(db, transactionTrigger, templateTxn, resolvedPublic); //} break; } break; case "LEDGER": throw new NotImplementedException(); } //if (templateTxn.InvertPercentage) //{ // result = (1 - result.Value); //} return(result); }
protected override IEnumerable <ResolvedSubSplit> ResolveSubSplit(IDbContext db, ScheduledJournal scheduledJournal, IPartyRole resolvedRole, JournalTemplateTxn templateTxn) { switch (templateTxn.JournalTxnType.PrimaryFactorCode) { case "PART": List <ResolvedSubSplit> result = new List <ResolvedSubSplit>(); var providerAcct = db.Set <ProviderAccount>().Find(scheduledJournal.Contract.ID); foreach (var participant in providerAcct.Participants) { result.Add(new ResolvedSubSplit() { Role = participant.Participant, Percentage = participant.Percentage }); } return(result); default: return(base.ResolveSubSplit(db, scheduledJournal, resolvedRole, templateTxn)); } }
protected override decimal?ResolveIsFactor(IDbContext db, ScheduledJournal scheduledJournal, IPartyRole resolvedRole, JournalTemplateTxn templateTxn) { switch (templateTxn.JournalTxnType.PrimaryFactorCode) { case "PART": return(1); default: return(base.ResolveIsFactor(db, scheduledJournal, resolvedRole, templateTxn)); } }