/// <summary>
        /// 振替元 と 先 が同じ
        /// </summary>
        /// <param name="transfer"></param>
        /// <param name="loginUserId"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        private async Task <ReceiptSectionTransfersResult> TransferSameAmountAsync(ReceiptSectionTransfer transfer, int loginUserId, CancellationToken token)
        {
            var result = new ReceiptSectionTransfersResult();

            result.UpdateReceipts.Add(await updateReceiptQueryProcessor.UpdateReceiptSectionAsync(transfer.DestinationSectionId, loginUserId, transfer.ReceiptId, token));

            if (!string.IsNullOrWhiteSpace(transfer.TransferMemo))
            {
                await addReceiptMemoQueryProcessor.SaveAsync(transfer.ReceiptId, transfer.TransferMemo, token);
            }
            else
            {
                var receiptMemo = await receiptMemoQueryProcessor.GetAsync(transfer.ReceiptId, token);

                if (receiptMemo != null)
                {
                    await deleteReceiptMemoQueryProcessor.DeleteAsync(transfer.ReceiptId, token);
                }
            }
            transfer.DestinationReceiptId = transfer.ReceiptId;
            var transferDB = await receiptSectionTransferQueryProcessor.GetItemByReceiptIdAsync(transfer, token);

            if (transferDB == null)
            {
                var saveItem = new ReceiptSectionTransfer
                {
                    SourceReceiptId      = transfer.ReceiptId,
                    DestinationReceiptId = transfer.ReceiptId,
                    SourceSectionId      = transfer.SourceSectionId,
                    DestinationSectionId = transfer.DestinationSectionId,
                    SourceAmount         = transfer.SourceAmount,
                    DestinationAmount    = transfer.DestinationAmount,
                    UpdateBy             = loginUserId,
                    CreateBy             = loginUserId,
                    PrintFlag            = 0,
                };
                result.ReceiptSectionTransfers.Add(await addReceiptSectionTransferQueryProcessor.SaveAsync(saveItem, token));
            }
            else if (transferDB.SourceSectionId == transfer.DestinationSectionId)
            {
                await deleteReceiptSectionTransferQueryProcessor.DeleteAsync(transferDB, token);
            }
            else
            {
                await updateReceiptSectionTransferQueryProcessor.UpdateDestinationSectionAsync(transfer.DestinationSectionId, loginUserId, transferDB.SourceReceiptId, transferDB.DestinationReceiptId, token);
            }
            return(result);
        }
Пример #2
0
 public async Task <ReceiptMemo> GetAsync(long ReceiptId, CancellationToken token = default(CancellationToken))
 => await receiptMemoQueryProcessor.GetAsync(ReceiptId, token);