示例#1
0
        private void ImportXml(XDocument bankXml)
        {
            Iso20022Document iso20022Document = new Iso20022Document(bankXml);

            Console.Out.WriteLine($"{iso20022Document.IBAN} : {iso20022Document.TtlNetNtryAmt}");

            List <Indbetaling> existingIndbetalings = Indbetaling.GetIndbetalingOnIban(_dynamicsCrmConnection, iso20022Document.IBAN).ToList();

            Konto konto      = ReadKonto(iso20022Document.IBAN);
            Guid? owner      = konto.owner;
            Guid? campaignId = konto.campaignid;

            if (campaignId == null)
            {
                throw new Exception($"could not find campaign on konto {konto.Id} with iban {konto.iban}");
            }

            foreach (Iso20022Ntry ntry in iso20022Document.Ntries)
            {
                //Console.Out.WriteLine($"{ntry.BankId}: {ntry.ValDt} : {ntry.Amt} {ntry.Ccy} - {ntry.Prtry} - {GetKilde(ntry, 0)} - ({ntry.BkTxCdDomnCd}_{ntry.BkTxCdDomnFmlyCd}_{ntry.BkTxCdDomnFmlySubFmlyCd})");

                Dictionary <string, int> crmIndbetalingCountByBankId  = CreateIndbetalingCountByBankId(existingIndbetalings);
                Dictionary <string, int> fileIndbetalingCountByBankId = new Dictionary <string, int>();

                bool createNewIndbetaling = CalculateCreateNewIndsamling(crmIndbetalingCountByBankId, fileIndbetalingCountByBankId, ntry.BankId);

                if (createNewIndbetaling == false)
                {
                    continue;
                }

                long?new_kkadminmedlemsnr = GetKkadminNr(ntry.BkTxCdPrtryCd);

                Account indsamlingssted = GetIndsamlingssted(new_kkadminmedlemsnr);

                Indbetaling.kildeEnum kilde   = GetKilde(ntry, new_kkadminmedlemsnr);
                Guid?byarbejdeid              = indsamlingssted?.byarbejdeid;
                Guid?indsamlingsstedid        = indsamlingssted?.Id;
                Guid?indsamlingskoordinatorid = indsamlingssted?.indsamlingskoordinatorid;

                CreateIndbetaling(iso20022Document, ntry, konto.Id, campaignId.Value, kilde, byarbejdeid, indsamlingsstedid, indsamlingskoordinatorid, owner.Value);
            }
        }
示例#2
0
        private void CreateIndbetaling(Iso20022Document iso20022Document, Iso20022Ntry ntry, Guid kontoId, Guid campaignId, Indbetaling.kildeEnum kilde, Guid?byarbejdeid, Guid?indsamlingsstedid, Guid?indsamlingskoordinatorid, Guid owner)
        {
            string bankkildekode = $"{ntry.BkTxCdDomnCd} / {ntry.BkTxCdDomnFmlyCd} / {ntry.BkTxCdDomnFmlySubFmlyCd}";

            Indbetaling indbetaling = Indbetaling.CreateAndInsert(_dynamicsCrmConnection, iso20022Document.IBAN, ntry.Amt, ntry.BankId, ntry.Prtry, ntry.ValDt, kontoId, campaignId, kilde, byarbejdeid, indsamlingsstedid, indsamlingskoordinatorid, ntry.BkTxCdPrtryCd, bankkildekode, owner);
        }