public static VatReportItem Create(VatReport report, FinancialTransaction transaction, Int64 turnoverCents, Int64 vatInboundCents, Int64 vatOutboundCents) { // Assumes there's a dependency of some sort IHasIdentity foreignObject = transaction.Dependency; FinancialDependencyType dependencyType = (foreignObject != null ? FinancialTransaction.GetFinancialDependencyType(transaction.Dependency) : FinancialDependencyType.Unknown); // The transaction dependency is stored for quick lookup; it duplicates information in the database // to save an expensive query as a mere optimization. int newVatReportItemId = SwarmDb.GetDatabaseForWriting() .CreateVatReportItem(report.Identity, transaction.Identity, foreignObject?.Identity ?? 0, dependencyType, turnoverCents, vatInboundCents, vatOutboundCents); return(FromIdentityAggressive(newVatReportItemId)); }
private static FinancialDependencyType GetDependencyType(IHasIdentity foreignObject) { return(FinancialTransaction.GetFinancialDependencyType(foreignObject)); }