public override void Handle(ArticleGroupEvents.Created message) { ArticleGroupDto dto = this.Load(message.ArticleGroupId); if (dto != null) throw new Exception("Item with the same Id already created!"); dto = new ArticleGroupDto(); dto.ArticleGroupId = message.ArticleGroupId; this.Save(dto); }
private LedgerAccountIndex(ArticleGroupDto articleGroup, string ledgerAccount, int?account, bool manualBookkeep, long?defaultVatId = null, string defaultVatAbbreviation = null) { LedgerAccount = ledgerAccount; IsDeactivated = articleGroup.IsDeactivated; ArticleGroupId = articleGroup.Id; Description = articleGroup.Description; ManualBookkeep = manualBookkeep; DefaultVatId = defaultVatId; DefaultVatAbbreviation = defaultVatAbbreviation; DefaultDeductionPercentage = DefaultVatId.HasValue ? 100m : 0; LedgerAccountIndexType = LedgerAccountIndexTypes.ArticleGroup; AccountNumber = account; AccountNumberRaw = $"{account}"; Id = $"{articleGroup.FiscalSetupId}_{LedgerAccountIndexType}_{articleGroup.Id}_{ledgerAccount}_{defaultVatId}"; FiscalSetupId = articleGroup.FiscalSetupId; }
public async Task <IActionResult> AddArticleGroup(int environmentId, ArticleGroupDto newGroup) { if (!await _authService.IsPermitted(User, environmentId, PermissionFlags.IsOwner | PermissionFlags.EditArticleSettings)) { return(Unauthorized()); } int envOwnerId = await _repo.GetEnvironmentOwnerId(environmentId); var grp = _mapper.Map <ArticleGroup>(newGroup); grp.UserId = envOwnerId; grp = await _repo.CreateArticleGroup(grp); return(CreatedAtRoute(nameof(GetBaseData), new { controller = "Articles", environmentId }, grp)); }
public static IEnumerable <LedgerAccountIndex> CreateFromArticleGroup(ArticleGroupDto articleGroup, long?defaultSalesVat, string defaultSalesVatAbbreviation, long?defaultPurchaseVat, string defaultPurchaseVatAbbreviation) { var indexes = new List <LedgerAccountIndex> { new LedgerAccountIndex(articleGroup, LedgerAccounts.NetTurnover, articleGroup.NettTurnoverVatFreeAccount, true), new LedgerAccountIndex(articleGroup, LedgerAccounts.ProductConsumption, articleGroup.ProductPurchaseVatFreeAccount, true), new LedgerAccountIndex(articleGroup, LedgerAccounts.Stock, articleGroup.StockAccount, false), new LedgerAccountIndex(articleGroup, LedgerAccounts.StockReception, articleGroup.StockReceptionAccount, false), new LedgerAccountIndex(articleGroup, LedgerAccounts.UnpaidStock, articleGroup.UnpaidStockAccount, false), }; if (defaultSalesVat.HasValue) { indexes.Add(new LedgerAccountIndex(articleGroup, LedgerAccounts.NetTurnover, articleGroup.NettTurnoverAccount, true, defaultSalesVat, defaultSalesVatAbbreviation)); } if (defaultPurchaseVat.HasValue) { indexes.Add(new LedgerAccountIndex(articleGroup, LedgerAccounts.ProductConsumption, articleGroup.ProductPurchaseAccount, true, defaultPurchaseVat, defaultPurchaseVatAbbreviation)); } return(indexes); }
public static IEnumerable <LedgerAccountIndex> CreateLedgerSearchIndex(this ArticleGroupDto articleGroup, FiscalSetupDto fiscalSetup) { return(LedgerAccountIndex.CreateFromArticleGroup(articleGroup, fiscalSetup.DefaultSalesVatId, fiscalSetup.DefaultSalesVatAbbreviation, fiscalSetup.DefaultPurchasingVatId, fiscalSetup.DefaultPurchasingVatAbbreviation)); }