public JournalTransactionModel GetNewPostedManualData()
        {
            var COA1 = Task.Run(() => _COADataUtil.GetTestData()).Result;
            JournalTransactionModel TestData = new JournalTransactionModel()
            {
                DocumentNo  = Guid.NewGuid().ToString(),
                Description = "Description",
                Date        = DateTimeOffset.UtcNow,
                ReferenceNo = "aa-aa-aaL-aa",
                Status      = JournalTransactionStatus.Posted,
                Items       = new List <JournalTransactionItemModel>()
                {
                    new JournalTransactionItemModel()
                    {
                        COAId  = COA1.Id,
                        COA    = COA1,
                        Remark = "Remark",
                        Debit  = 10000.00m,
                        Credit = 10000.00m
                    }
                }
            };

            return(TestData);
        }
Exemplo n.º 2
0
        public async Task <int> AutoJournalFromOthersExpenditureProof(OthersExpenditureProofDocumentModel model, List <OthersExpenditureProofDocumentItemModel> items)
        {
            var journalTransactionModel = new JournalTransactionModel()
            {
                Date        = model.Date,
                Description = "Auto Journal Bukti Pengeluaran Bank Lain - Lain",
                ReferenceNo = model.DocumentNo,
                Status      = "POSTED",
                Items       = new List <JournalTransactionItemModel>()
            };

            journalTransactionModel.Items = items.Select(item => new JournalTransactionItemModel()
            {
                COA = new COAModel()
                {
                    Id = item.COAId,
                },
                Debit = item.Debit
            }).ToList();

            var accountBankCOA = await GetAccountBankCOA(model.AccountBankId);

            var creditItem = new JournalTransactionItemModel()
            {
                COA = new COAModel()
                {
                    Code = accountBankCOA
                },
                Credit = items.Sum(item => item.Debit)
            };

            journalTransactionModel.Items.Add(creditItem);

            return(await _journalTransactionService.CreateAsync(journalTransactionModel));
        }
Exemplo n.º 3
0
        public async Task <int> AutoJournalFromOthersExpenditureProof(OthersExpenditureProofDocumentCreateUpdateViewModel viewModel, string documentNo)
        {
            var model = new JournalTransactionModel()
            {
                Date        = viewModel.Date.GetValueOrDefault(),
                Description = "Auto Journal Bukti Pengeluaran Bank Lain - Lain",
                ReferenceNo = documentNo,
                Status      = "POSTED",
                Items       = new List <JournalTransactionItemModel>()
            };

            model.Items = viewModel.Items.Select(item => new JournalTransactionItemModel()
            {
                COA = new COAModel()
                {
                    Id = item.COAId.GetValueOrDefault(),
                },
                Debit = item.Debit.GetValueOrDefault()
            }).ToList();

            var accountBankCOA = await GetAccountBankCOA(viewModel.AccountBankId.GetValueOrDefault());

            var creditItem = new JournalTransactionItemModel()
            {
                COA = new COAModel()
                {
                    Code = accountBankCOA
                },
                Credit = viewModel.Items.Sum(item => item.Debit.GetValueOrDefault())
            };

            model.Items.Add(creditItem);

            return(await _journalTransactionService.CreateAsync(model));
        }
        public async Task <JournalTransactionModel> GetTestPostedGarmentIData()
        {
            JournalTransactionModel model = GetPostedGarmenItData();
            await _Service.CreateAsync(model);

            return(await _Service.ReadByIdAsync(model.Id));
        }
        public void Should_Success_Map_JournalTransaction()
        {
            var mapper = new MapperConfiguration(configuration => configuration.AddProfile <JournalTransactionProfile>()).CreateMapper();
            var model  = new JournalTransactionModel()
            {
                Items = new List <JournalTransactionItemModel>()
                {
                    new JournalTransactionItemModel()
                }
            };
            var vm = mapper.Map <JournalTransactionViewModel>(model);

            Assert.True(true);
        }
Exemplo n.º 6
0
        public async Task <int> Posting(PostingFormDto form)
        {
            var models = _dbContext.PurchasingMemoTextiles.Where(entity => form.Ids.Contains(entity.Id)).ToList();

            models = models.Select(model =>
            {
                model.SetIsPosted(true);
                EntityExtension.FlagForUpdate(model, _identityService.Username, UserAgent);
                return(model);
            }).ToList();
            _dbContext.SaveChanges();

            foreach (var model in models)
            {
                var items      = _dbContext.PurchasingMemoTextileItems.Where(entity => entity.PurchasingMemoTextileId == model.Id).ToList();
                var memoDetail = _dbContext.PurchasingMemoDetailTextiles.FirstOrDefault(entity => entity.Id == model.MemoDetailId);

                var type = memoDetail.Type == PurchasingMemoType.Disposition ? "Disposisi" : "Non Disposisi";
                var journalTransactionModel = new JournalTransactionModel()
                {
                    Date        = model.MemoDetailDate,
                    Description = $"Memo Pembelian {type}",
                    ReferenceNo = model.MemoDetailDocumentNo,
                    Status      = "POSTED",
                    Items       = new List <JournalTransactionItemModel>()
                };

                foreach (var item in items)
                {
                    journalTransactionModel.Items.Add(new JournalTransactionItemModel()
                    {
                        COA = new Models.MasterCOA.COAModel()
                        {
                            Id   = item.ChartOfAccountId,
                            Code = item.ChartOfAccountCode,
                            Name = item.ChartOfAccountName
                        },
                        COAId  = item.ChartOfAccountId,
                        Credit = (decimal)item.CreditAmount,
                        Debit  = (decimal)item.DebitAmount
                    });
                }

                await _journalTransactionService.CreateAsync(journalTransactionModel);
            }

            return(models.Count);
        }
Exemplo n.º 7
0
        public async Task <int> AutoJournalInklaring(List <int> vbRequestIds)
        {
            var dbContext  = _serviceProvider.GetService <FinanceDbContext>();
            var vbRequests = dbContext.VBRequestDocuments.Where(entity => vbRequestIds.Contains(entity.Id)).ToList();

            foreach (var vbRequest in vbRequests)
            {
                if (vbRequest.IsInklaring && vbRequest.CurrencyCode == "IDR")
                {
                    var modelInklaring = new JournalTransactionModel()
                    {
                        Date        = vbRequest.Date,
                        Description = "Approval VB Inklaring",
                        ReferenceNo = vbRequest.DocumentNo,
                        Status      = "DRAFT",
                        Items       = new List <JournalTransactionItemModel>()
                    };

                    modelInklaring.Items.Add(new JournalTransactionItemModel()
                    {
                        COA = new COAModel()
                        {
                            Code = $"1503.00.0.00"
                        },
                        Debit = vbRequest.Amount
                    });

                    //modelInklaring.Items.Add(new JournalTransactionItemModel()
                    //{
                    //    COA = new COAModel()
                    //    {
                    //        Code = $"9999.00.0.00"
                    //    },
                    //    Credit = vbRequest.Amount
                    //});

                    //if (modelInklaring.Items.Any(element => element.COA.Code.Contains("9999")))
                    //modelInklaring.Status = "DRAFT";

                    await _journalTransactionService.CreateAsync(modelInklaring);
                }
            }
            return(vbRequests.Count);
        }
Exemplo n.º 8
0
        public async Task <int> AutoJournalVBNonPOClearence(List <int> vbRealizationIds, AccountBankViewModel bank)
        {
            var dbContext = _serviceProvider.GetService <FinanceDbContext>();

            var vbRealizations         = dbContext.VBRealizationDocuments.Where(entity => vbRealizationIds.Contains(entity.Id)).ToList();
            var vbRequestIds           = vbRealizations.Select(element => element.VBRequestDocumentId).ToList();
            var vbRequests             = dbContext.VBRequestDocuments.Where(entity => vbRequestIds.Contains(entity.Id)).ToList();
            var vbRealizationItems     = dbContext.VBRealizationDocumentExpenditureItems.Where(entity => vbRealizationIds.Contains(entity.VBRealizationDocumentId)).ToList();
            var vbRealizationUnitCosts = dbContext.VBRealizationDocumentUnitCostsItems.Where(entity => vbRealizationIds.Contains(entity.VBRealizationDocumentId) && entity.IsSelected).ToList();

            var units = await _masterCOAService.GetCOAUnits();

            var divisions = await _masterCOAService.GetCOADivisions();

            foreach (var vbRealization in vbRealizations)
            {
                var bankDocumentNo = DocumentNoGenerator(bank);

                var coaUnit = "00";
                var unit    = units.FirstOrDefault(element => vbRealization.SuppliantUnitId == element.Id);
                if (unit != null)
                {
                    coaUnit = unit.COACode;
                }

                var coaDivision = "0";
                var division    = divisions.FirstOrDefault(element => vbRealization.SuppliantDivisionId == element.Id);
                if (division != null)
                {
                    coaDivision = division.COACode;
                }


                //var vbRequest = vbRequests.FirstOrDefault(element => element.Id == vbRealization.VBRequestDocumentId);
                var selectedVbRealizationItems     = vbRealizationItems.Where(entity => entity.VBRealizationDocumentId == vbRealization.Id).ToList();
                var selectedVbRealizationUnitCosts = vbRealizationUnitCosts.Where(entity => entity.VBRealizationDocumentId == vbRealization.Id).ToList();
                if (vbRealization.IsInklaring)
                {
                    var vbRequest = vbRequests.FirstOrDefault(element => element.Id == vbRealization.VBRequestDocumentId);
                    if (vbRealization.CurrencyCode == "IDR")
                    {
                        var modelInklaring = new JournalTransactionModel()
                        {
                            Date        = vbRealization.Date,
                            Description = "Clearance VB Inklaring",
                            ReferenceNo = bankDocumentNo,
                            Status      = "DRAFT",
                            Items       = new List <JournalTransactionItemModel>()
                        };

                        foreach (var vbRealizationUnitCost in selectedVbRealizationUnitCosts)
                        {
                            var costCOADivision = "0";
                            var costDivision    = divisions.FirstOrDefault(element => element.Id == vbRealizationUnitCost.DivisionId);
                            if (costDivision != null && !string.IsNullOrWhiteSpace(costDivision.COACode))
                            {
                                costCOADivision = costDivision.COACode;
                            }

                            var costCOAUnit = "00";
                            var costUnit    = units.FirstOrDefault(element => element.Id == vbRealizationUnitCost.UnitId);
                            if (costUnit != null && !string.IsNullOrWhiteSpace(costUnit.COACode))
                            {
                                costCOAUnit = costUnit.COACode;
                            }

                            modelInklaring.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1804.00.{costCOADivision}.{costCOAUnit}"
                                },
                                Debit = vbRealizationUnitCost.Amount
                            });

                            modelInklaring.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1503.00.{costCOADivision}.{costCOAUnit}"
                                },
                                Credit = vbRealizationUnitCost.Amount
                            });
                        }

                        var sumPPn = selectedVbRealizationItems.Sum(element => element.PPnAmount);
                        var sumPPh = selectedVbRealizationItems.Sum(element => element.PPhAmount);


                        if (sumPPn > 0)
                        {
                            modelInklaring.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1509.00.{coaDivision}.{coaUnit}"
                                },
                                Debit = sumPPn
                            });
                        }

                        if (sumPPh > 0)
                        {
                            modelInklaring.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"3330.00.{coaDivision}.{coaUnit}"
                                },
                                Credit = sumPPh
                            });
                        }

                        await _journalTransactionService.CreateAsync(modelInklaring);

                        if (vbRequest != null)
                        {
                            var difference = vbRequest.Amount - vbRealization.Amount;
                            if (difference > 0)
                            {
                                var modelDifference = new JournalTransactionModel()
                                {
                                    Date        = vbRequest.Date,
                                    Description = "Clearence VB Inklaring",
                                    ReferenceNo = bankDocumentNo,
                                    Status      = "POSTED",
                                    Items       = new List <JournalTransactionItemModel>()
                                };

                                modelDifference.Items.Add(new JournalTransactionItemModel()
                                {
                                    COA = new COAModel()
                                    {
                                        Code = bank.AccountCOA
                                    },
                                    Debit = difference
                                });

                                modelDifference.Items.Add(new JournalTransactionItemModel()
                                {
                                    COA = new COAModel()
                                    {
                                        Code = $"1503.00.{coaDivision}.{coaUnit}"
                                    },
                                    Credit = difference
                                });

                                await _journalTransactionService.CreateAsync(modelDifference);
                            }
                        }
                    }
                }
                else
                {
                    var model = new JournalTransactionModel()
                    {
                        Date        = vbRealization.Date,
                        Description = "Clearance VB",
                        ReferenceNo = bankDocumentNo,
                        Status      = "DRAFT",
                        Items       = new List <JournalTransactionItemModel>()
                    };

                    //model.Items.Add(new JournalTransactionItemModel()
                    //{
                    //    COA = new COAModel()
                    //    {
                    //        Code = $"9999.00.0.00"
                    //    },
                    //    Debit = vbRealization.Amount
                    //});

                    if (vbRealization.CurrencyCode == "IDR")
                    {
                        foreach (var vbRealizationUnitCost in selectedVbRealizationUnitCosts)
                        {
                            var costCOADivision = "0";
                            var costDivision    = divisions.FirstOrDefault(element => element.Id == vbRealizationUnitCost.DivisionId);
                            if (costDivision != null && !string.IsNullOrWhiteSpace(costDivision.COACode))
                            {
                                costCOADivision = costDivision.COACode;
                            }

                            var costCOAUnit = "00";
                            var costUnit    = units.FirstOrDefault(element => element.Id == vbRealizationUnitCost.UnitId);
                            if (costUnit != null && !string.IsNullOrWhiteSpace(costUnit.COACode))
                            {
                                costCOAUnit = costUnit.COACode;
                            }

                            model.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1011.00.{costCOADivision}.{costCOAUnit}"
                                },
                                Credit = vbRealizationUnitCost.Amount
                            });
                        }

                        var sumPPn = selectedVbRealizationUnitCosts.Sum(element =>
                        {
                            var result = (decimal)0;

                            if (element.UseVat)
                            {
                                result = element.Amount * (decimal)0.1;
                            }

                            return(result);
                        });

                        var sumPPh = selectedVbRealizationUnitCosts.Sum(element =>
                        {
                            var result = (decimal)0;

                            if (element.UseIncomeTax)
                            {
                                result = element.Amount * ((decimal)element.IncomeTaxRate / 100);
                            }

                            return(result);
                        });

                        if (sumPPn > 0)
                        {
                            model.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1509.00.{coaDivision}.{coaUnit}"
                                },
                                Debit = sumPPn
                            });
                        }

                        if (sumPPh > 0)
                        {
                            model.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"3330.00.{coaDivision}.{coaUnit}"
                                },
                                Credit = sumPPh
                            });
                        }
                    }
                    else
                    {
                        model.Items.Add(new JournalTransactionItemModel()
                        {
                            COA = new COAModel()
                            {
                                Code = $"1012.00.{coaDivision}.{coaUnit}"
                            },
                            Credit = vbRealization.Amount
                        });
                    }

                    //if (model.Items.Any(element => element.COA.Code.Contains("9999")))
                    //    model.Status = "DRAFT";

                    await _journalTransactionService.CreateAsync(model);
                }

                #region old auto journal
                //else
                //{
                //    var model = new JournalTransactionModel()
                //    {
                //        Date = vbRealization.Date,
                //        Description = "Clearance VB",
                //        ReferenceNo = vbRealization.DocumentNo,
                //        Status = "DRAFT",
                //        Items = new List<JournalTransactionItemModel>()
                //    };

                //    //model.Items.Add(new JournalTransactionItemModel()
                //    //{
                //    //    COA = new COAModel()
                //    //    {
                //    //        Code = $"9999.00.0.00"
                //    //    },
                //    //    Debit = vbRealization.Amount
                //    //});

                //    if (vbRealization.CurrencyCode == "IDR")
                //    {
                //        model.Items.Add(new JournalTransactionItemModel()
                //        {
                //            COA = new COAModel()
                //            {
                //                Code = $"1011.00.{coaDivision}.{coaUnit}"
                //            },
                //            Credit = vbRealization.Amount
                //        });
                //    }
                //    else
                //    {
                //        model.Items.Add(new JournalTransactionItemModel()
                //        {
                //            COA = new COAModel()
                //            {
                //                Code = $"1012.00.{coaDivision}.{coaUnit}"
                //            },
                //            Credit = vbRealization.Amount
                //        });
                //    }

                //    //if (model.Items.Any(element => element.COA.Code.Contains("9999")))
                //    //    model.Status = "DRAFT";

                //    await _journalTransactionService.CreateAsync(model);

                //}
                #endregion
            }

            return(vbRealizations.Count);
        }
Exemplo n.º 9
0
        public async Task <int> AutoJournalVBNonPOClearence(List <int> vbRealizationIds)
        {
            var dbContext = _serviceProvider.GetService <FinanceDbContext>();

            var vbRealizations = dbContext.VBRealizationDocuments.Where(entity => vbRealizationIds.Contains(entity.Id)).ToList();
            var vbRequestIds   = vbRealizations.Select(element => element.VBRequestDocumentId).ToList();
            var vbRequests     = dbContext.VBRequestDocuments.Where(entity => vbRequestIds.Contains(entity.Id)).ToList();

            foreach (var vbRealization in vbRealizations)
            {
                if (vbRealization.VBRequestDocumentId > 0)
                {
                    var vbRequest = vbRequests.FirstOrDefault(element => element.Id == vbRealization.VBRequestDocumentId);
                    if (vbRequest.IsInklaring)
                    {
                        if (vbRequest.CurrencyCode == "IDR")
                        {
                            var modelInklaring = new JournalTransactionModel()
                            {
                                Date        = vbRealization.Date,
                                Description = "Clearance VB Inklaring",
                                ReferenceNo = vbRealization.DocumentNo,
                                Status      = "POSTED",
                                Items       = new List <JournalTransactionItemModel>()
                            };

                            modelInklaring.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1804.00.0.00"
                                },
                                Debit = vbRealization.Amount
                            });

                            modelInklaring.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1503.00.0.00"
                                },
                                Credit = vbRealization.Amount
                            });

                            if (modelInklaring.Items.Any(element => element.COA.Code.Contains("9999")))
                            {
                                modelInklaring.Status = "DRAFT";
                            }

                            await _journalTransactionService.CreateAsync(modelInklaring);
                        }
                    }
                    else
                    {
                        var model = new JournalTransactionModel()
                        {
                            Date        = vbRealization.Date,
                            Description = "Clearance VB",
                            ReferenceNo = vbRealization.DocumentNo,
                            Status      = "DRAFT",
                            Items       = new List <JournalTransactionItemModel>()
                        };

                        //model.Items.Add(new JournalTransactionItemModel()
                        //{
                        //    COA = new COAModel()
                        //    {
                        //        Code = $"9999.00.0.00"
                        //    },
                        //    Debit = vbRealization.Amount
                        //});

                        if (vbRealization.CurrencyCode == "IDR")
                        {
                            model.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1011.00.0.00"
                                },
                                Credit = vbRealization.Amount
                            });
                        }
                        else
                        {
                            model.Items.Add(new JournalTransactionItemModel()
                            {
                                COA = new COAModel()
                                {
                                    Code = $"1012.00.0.00"
                                },
                                Credit = vbRealization.Amount
                            });
                        }

                        //if (model.Items.Any(element => element.COA.Code.Contains("9999")))
                        //    model.Status = "DRAFT";

                        await _journalTransactionService.CreateAsync(model);
                    }
                }
                else
                {
                    var model = new JournalTransactionModel()
                    {
                        Date        = vbRealization.Date,
                        Description = "Clearance VB",
                        ReferenceNo = vbRealization.DocumentNo,
                        Status      = "DRAFT",
                        Items       = new List <JournalTransactionItemModel>()
                    };

                    //model.Items.Add(new JournalTransactionItemModel()
                    //{
                    //    COA = new COAModel()
                    //    {
                    //        Code = $"9999.00.0.00"
                    //    },
                    //    Debit = vbRealization.Amount
                    //});

                    if (vbRealization.CurrencyCode == "IDR")
                    {
                        model.Items.Add(new JournalTransactionItemModel()
                        {
                            COA = new COAModel()
                            {
                                Code = $"1011.00.0.00"
                            },
                            Credit = vbRealization.Amount
                        });
                    }
                    else
                    {
                        model.Items.Add(new JournalTransactionItemModel()
                        {
                            COA = new COAModel()
                            {
                                Code = $"1012.00.0.00"
                            },
                            Credit = vbRealization.Amount
                        });
                    }

                    //if (model.Items.Any(element => element.COA.Code.Contains("9999")))
                    //    model.Status = "DRAFT";

                    await _journalTransactionService.CreateAsync(model);
                }
            }

            return(vbRealizations.Count);
        }
Exemplo n.º 10
0
        public async Task <int> AutoJournalInklaring(List <int> vbRequestIds, AccountBankViewModel bank)
        {
            var dbContext  = _serviceProvider.GetService <FinanceDbContext>();
            var vbRequests = dbContext.VBRequestDocuments.Where(entity => vbRequestIds.Contains(entity.Id)).ToList();

            var units = await _masterCOAService.GetCOAUnits();

            var divisions = await _masterCOAService.GetCOAUnits();

            foreach (var vbRequest in vbRequests)
            {
                var bankDocumentNo = DocumentNoGenerator(bank);

                var coaUnit = "00";
                var unit    = units.FirstOrDefault(element => vbRequest.SuppliantUnitId == element.Id);
                if (unit != null)
                {
                    coaUnit = unit.COACode;
                }

                var coaDivision = "0";
                var division    = divisions.FirstOrDefault(element => vbRequest.SuppliantDivisionId == element.Id);
                if (division != null)
                {
                    coaDivision = division.COACode;
                }

                if (vbRequest.IsInklaring && vbRequest.CurrencyCode == "IDR")
                {
                    var modelInklaring = new JournalTransactionModel()
                    {
                        Date        = vbRequest.Date,
                        Description = "Approval VB Inklaring",
                        ReferenceNo = bankDocumentNo,
                        Status      = "DRAFT",
                        Items       = new List <JournalTransactionItemModel>()
                    };

                    modelInklaring.Items.Add(new JournalTransactionItemModel()
                    {
                        COA = new COAModel()
                        {
                            Code = $"1503.00.{coaDivision}.{coaUnit}"
                        },
                        Debit = vbRequest.Amount
                    });

                    modelInklaring.Items.Add(new JournalTransactionItemModel()
                    {
                        COA = new COAModel()
                        {
                            Code = bank.AccountCOA
                        },
                        Credit = vbRequest.Amount
                    });

                    //modelInklaring.Items.Add(new JournalTransactionItemModel()
                    //{
                    //    COA = new COAModel()
                    //    {
                    //        Code = $"9999.00.0.00"
                    //    },
                    //    Credit = vbRequest.Amount
                    //});

                    //if (modelInklaring.Items.Any(element => element.COA.Code.Contains("9999")))
                    //modelInklaring.Status = "DRAFT";

                    await _journalTransactionService.CreateAsync(modelInklaring);
                }
            }
            return(vbRequests.Count);
        }
 public Task <int> CreateAsync(JournalTransactionModel model)
 {
     return(Task.FromResult(1));
 }
 public Task <int> UpdateAsync(int id, JournalTransactionModel model)
 {
     return(Task.FromResult(1));
 }