using Hcs.Client;
using Hcs.Client.Api.Payload.Bills;
using Hcs.Client.Api.Registry;
using Hcs.Client.Api.Type;
using Hcs.Service.Async.Bills;
using System;

namespace Hcs.TestApp.Scenario
{
    internal class BillsScenario(UniClient client)
    {
        private readonly UniClient client = client;

        internal void ImportPaymentDocument()
        {
            var paymentInformation = new ImportPaymentDocumentPayload.PaymentInformation()
            {
                bankBIK = "049805609",
                operatingAccountNumber = "40602810276000100228"
            };
            var payload = new ImportPaymentDocumentPayload()
            {
                confirmAmountsCorrect = true,
                month = 8,
                year = 2025,
                paymentInformation = [paymentInformation],
                paymentDocument = [new ImportPaymentDocumentPayload.PaymentDocument()
                {
                    paymentInformation = paymentInformation,
                    accountGuid = "019917a8-6eb6-74cc-99b7-58350127ac50",
                    paymentDocumentNumber = "23900701600162023",
                    chargeInfo =
                    [
                        new ImportPaymentDocumentPayload.MunicipalService()
                        {
                            moneyRecalculation = 0M,
                            moneyDiscount = 0M,
                            houseOverallNeedsNorm = 0M,
                            individualConsumptionNorm = 0.472M,
                            individualConsumptionCurrentValue = 0M,
                            houseOverallNeedsCurrentValue = 0M,
                            houseTotalIndividualConsumption = 19.678M,
                            houseTotalHouseOverallNeeds = 0M,
                            individualConsumptionVolumeDeterminingMethod = MunicipalServiceVolumeDeterminingMethod.Norm,
                            individualConsumptionVolumeValue = 1.006M,
                            municipalServiceIndividualConsumptionPayable = 1862.93M,
                            municipalServiceCommunalConsumptionPayable = 0M,
                            amountOfPaymentMunicipalServiceIndividualConsumption = 1862.93M,
                            amountOfPaymentMunicipalServiceCommunalConsumption = 0M,
                            serviceType = Registry51.Element6_1,
                            rate = 1851.82M,
                            totalPayable = 1862.93M,
                            accountingPeriodTotal = 1862.93M
                        }
                    ],
                    exposeNotWithdraw = true,
                    debtPreviousPeriods = 3271.16M,
                    advanceBllingPeriod = 0M,
                    totalPayableByPDWithDebtAndAdvance = 3043.95M,
                    totalPayableByPD = 3442.24M,
                    paidCash = 3669.45M,
                    dateOfLastReceivedPayment = new DateTime(2025, 8, 30)
                }]
            };

            var result = client.Bills.ImportPaymentDocumentAsync(payload).Result;
            Console.WriteLine("Scenario execution " + (result ? "succeeded" : "failed"));
        }
    }
}
