public static CashReceiptDto GenerateCashReceipt(CashReceiptGenerationParameters parameters)
        {
            CashReceiptDto cashReceipt = new CashReceiptDto
            {
                procDate = parameters.EntryDate.AddDays(5),
                entryDate = parameters.EntryDate,
                note = "note_1",
                total = 50,
                detailCollection = new[] { "det_1", "det_2" },
                customFields = new UserDefinedFieldValueDto[]
                {
                    new UserDefinedFieldValueDto
                    {
                        userDefinedFieldId = parameters.UserDefinedFields[0].id,
                        value = "field_1"
                    },
                    new UserDefinedFieldValueDto
                    {
                        userDefinedFieldId = parameters.UserDefinedFields[1].id,
                        value = "field_2"
                    }
                }
            };

            if (parameters.CustomerId.HasValue)
            {
                cashReceipt.customerId = parameters.CustomerId.Value;
                cashReceipt.discount = 10;
            }
            else
            {
                cashReceipt.acEntries = new AcEntryDto[]
                {
                    new AcEntryDto
                    {
                        accountCode = parameters.AnalysisCategories[0].accountCode,
                        analysisCategoryId = parameters.AnalysisCategories[0].id,
                        value = 30m
                    },
                    new AcEntryDto
                    {
                        accountCode = parameters.AnalysisCategories[1].accountCode,
                        analysisCategoryId = parameters.AnalysisCategories[1].id,
                        value = 20m
                    }
                };
            }

            return cashReceipt;
        }
        /// <summary>
        /// Initializes delegate which used for multiple Sales Invoices creation in batch sample.
        /// </summary>
        protected Func<int, CashReceiptDto> GetCashReceiptGeneratorForBatchCreation()
        {
            CustomerDto[] customers = ApiClientProvider.Default.Customers.GetPage().Items;

            CategoryTypeDto cashReceiptsCategoryType = ApiClientProvider.Default.CategoryTypes.CashReceipts;
            AnalysisCategoryDto[] analysisCategories = ApiClientProvider.Default.AnalysisCategories.GetPageByCategoryType(cashReceiptsCategoryType.id).Items;
            UserDefinedFieldDto[] userDefinedFields = ApiClientProvider.Default.UserDefinedFields.GetPageByCategoryType(cashReceiptsCategoryType.id).Items;

            return index =>
            {
                bool withCustomer = (index % 2 == 0); // True if index is even.
                CashReceiptGenerationParameters parameters = new CashReceiptGenerationParameters
                {
                    EntryDate = CashReceiptEntryDate,
                    CustomerId = withCustomer ? customers[index % customers.Length].id : (long?)null,
                    AnalysisCategories = withCustomer ? null : analysisCategories,
                    UserDefinedFields = userDefinedFields
                };
                return SampleDtoGenerator.GenerateCashReceipt(parameters);
            };
        }