Exemplo n.º 1
0
        public dynamic GetInfo(int Id)
        {
            QuantityPricing model = new QuantityPricing();

            try
            {
                model = _quantityPricingService.GetObjectById(Id);
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Id,
                model.ItemTypeId,
                model.Discount,
                model.MinQuantity,
                model.IsInfiniteMaxQuantity,
                model.MaxQuantity,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public dynamic Insert(QuantityPricing model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Create", Core.Constants.Constant.MenuName.QuantityPricing, Core.Constants.Constant.MenuGroupName.Master))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Add record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                model = _quantityPricingService.CreateObject(model, _itemTypeService);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Exemplo n.º 3
0
        public dynamic Delete(QuantityPricing model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Delete", Core.Constants.Constant.MenuName.QuantityPricing, Core.Constants.Constant.MenuGroupName.Master))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Delete Record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _quantityPricingService.GetObjectById(model.Id);
                model = _quantityPricingService.SoftDeleteObject(data);
            }
            catch (Exception ex)
            {
                LOG.Error("Delete Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Exemplo n.º 4
0
 public QuantityPricing VIsValidDiscount(QuantityPricing quantityPricing)
 {
     if (quantityPricing.Discount < 0 || quantityPricing.Discount > 100)
     {
         quantityPricing.Errors.Add("Discount", "Harus diantara 0 sampai 100");
     }
     return(quantityPricing);
 }
Exemplo n.º 5
0
 public QuantityPricing VIsValidMaxQuantity(QuantityPricing quantityPricing)
 {
     if (!quantityPricing.IsInfiniteMaxQuantity && quantityPricing.MaxQuantity < quantityPricing.MinQuantity)
     {
         quantityPricing.Errors.Add("MaxQuantity", "Harus lebih besar atau sama dengan MinQuantity");
     }
     return(quantityPricing);
 }
Exemplo n.º 6
0
 public QuantityPricing VIsValidMinQuantity(QuantityPricing quantityPricing)
 {
     if (quantityPricing.MinQuantity <= 1)
     {
         quantityPricing.Errors.Add("MinQuantity", "Harus lebih besar dari 1");
     }
     return(quantityPricing);
 }
Exemplo n.º 7
0
 public QuantityPricing VHasUniqueCombination(QuantityPricing quantityPricing, IQuantityPricingService _quantityPricingService)
 {
     if (_quantityPricingService.IsQuantityPricingDuplicated(quantityPricing))
     {
         quantityPricing.Errors.Add("Generic", "Kombinasi ItemTypeId, MinQuantity dan MaxQuantity Tidak boleh ada duplikasi");
     }
     return(quantityPricing);
 }
Exemplo n.º 8
0
 public QuantityPricing VSameItemTypeId(QuantityPricing quantityPricing, int oldItemTypeId)
 {
     if (quantityPricing.ItemTypeId != oldItemTypeId)
     {
         quantityPricing.Errors.Add("Generic", "ItemTypeId Tidak boleh beda");
     }
     return(quantityPricing);
 }
Exemplo n.º 9
0
 public QuantityPricing VUpdateObject(QuantityPricing quantityPricing, int oldItemTypeId, IQuantityPricingService _quantityPricingService, IItemTypeService _itemTypeService)
 {
     VSameItemTypeId(quantityPricing, oldItemTypeId);
     if (!isValid(quantityPricing))
     {
         return(quantityPricing);
     }
     return(VCreateObject(quantityPricing, _quantityPricingService, _itemTypeService));
 }
Exemplo n.º 10
0
        public QuantityPricing VIsValidItemType(QuantityPricing quantityPricing, IItemTypeService _itemTypeService)
        {
            ItemType itemType = _itemTypeService.GetObjectById(quantityPricing.ItemTypeId);

            if (itemType == null)
            {
                quantityPricing.Errors.Add("Generic", "ItemTypeId Tidak valid");
            }
            return(quantityPricing);
        }
Exemplo n.º 11
0
 public QuantityPricing UpdateObject(QuantityPricing quantityPricing, int oldItemTypeId, IItemTypeService _itemTypeService)
 {
     if (_validator.ValidUpdateObject(quantityPricing, oldItemTypeId, this, _itemTypeService))
     {
         if (quantityPricing.IsInfiniteMaxQuantity)
         {
             quantityPricing.MaxQuantity = 0;
         }
         quantityPricing = _repository.UpdateObject(quantityPricing);
     }
     return(quantityPricing);
 }
Exemplo n.º 12
0
        public string PrintError(QuantityPricing obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
Exemplo n.º 13
0
 public QuantityPricing CreateObject(QuantityPricing quantityPricing, IItemTypeService _itemTypeService)
 {
     quantityPricing.Errors = new Dictionary <String, String>();
     if (_validator.ValidCreateObject(quantityPricing, this, _itemTypeService))
     {
         if (quantityPricing.IsInfiniteMaxQuantity)
         {
             quantityPricing.MaxQuantity = 0;
         }
         quantityPricing = _repository.CreateObject(quantityPricing);
     }
     return(quantityPricing);
 }
        public CashSalesInvoiceDetail CreateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                                                   IItemService _itemService, IWarehouseItemService _warehouseItemService,
                                                   IQuantityPricingService _quantityPricingService)
        {
            cashSalesInvoiceDetail.Errors = new Dictionary <String, String>();
            if (_validator.ValidCreateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, this, _itemService, _warehouseItemService, _quantityPricingService))
            {
                Item            item            = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);
                QuantityPricing quantityPricing = _quantityPricingService.GetObjectByItemTypeIdAndQuantity(item.ItemTypeId, cashSalesInvoiceDetail.Quantity);
                decimal         price           = item.SellingPrice;
                decimal         discount        = cashSalesInvoiceDetail.Discount;
                if (cashSalesInvoiceDetail.IsManualPriceAssignment)
                {
                    price = cashSalesInvoiceDetail.AssignedPrice;
                }
                else
                {
                    cashSalesInvoiceDetail.AssignedPrice = 0;
                }
                if (quantityPricing != null)
                {
                    if (cashSalesInvoiceDetail.Discount <= 0)
                    {
                        discount = quantityPricing.Discount;
                    }
                    ;
                }
                cashSalesInvoiceDetail.Amount = (price * (100 - discount) / 100) * cashSalesInvoiceDetail.Quantity;
                cashSalesInvoiceDetail.CoGS   = cashSalesInvoiceDetail.Quantity * item.AvgPrice;

                CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
                cashSalesInvoiceDetail.PriceMutationId = item.PriceMutationId;

                cashSalesInvoiceDetail = _repository.CreateObject(cashSalesInvoiceDetail);
                cashSalesInvoice.Total = CalculateTotal(cashSalesInvoice.Id);
                cashSalesInvoice.CoGS  = CalculateCoGS(cashSalesInvoice.Id);
                _cashSalesInvoiceService.GetRepository().Update(cashSalesInvoice);
            }
            return(cashSalesInvoiceDetail);
        }
Exemplo n.º 15
0
 public QuantityPricing VCreateObject(QuantityPricing quantityPricing, IQuantityPricingService _quantityPricingService, IItemTypeService _itemTypeService)
 {
     VIsValidMinQuantity(quantityPricing);
     if (!isValid(quantityPricing))
     {
         return(quantityPricing);
     }
     VIsValidMaxQuantity(quantityPricing);
     if (!isValid(quantityPricing))
     {
         return(quantityPricing);
     }
     VIsValidDiscount(quantityPricing);
     if (!isValid(quantityPricing))
     {
         return(quantityPricing);
     }
     //VHasUniqueCombination(quantityPricing, _quantityPricingService);
     //if (!isValid(quantityPricing)) { return quantityPricing; }
     VIsValidItemType(quantityPricing, _itemTypeService);
     return(quantityPricing);
 }
Exemplo n.º 16
0
        public dynamic Update(QuantityPricing model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.QuantityPricing, Core.Constants.Constant.MenuGroupName.Master))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _quantityPricingService.GetObjectById(model.Id);
                data.Discount              = model.Discount;
                data.MinQuantity           = model.MinQuantity;
                data.IsInfiniteMaxQuantity = model.IsInfiniteMaxQuantity;
                data.MaxQuantity           = model.MaxQuantity;
                model = _quantityPricingService.UpdateObject(data, data.ItemTypeId, _itemTypeService);
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Exemplo n.º 17
0
 public QuantityPricing VDeleteObject(QuantityPricing quantityPricing)
 {
     return(quantityPricing);
 }
Exemplo n.º 18
0
        void cashsalesinvoice_validation()
        {
            it["validates_all_variables"] = () =>
            {
                b.localWarehouse.Errors.Count().should_be(0);
                b.contact.Errors.Count().should_be(0);
                b.contact2.Errors.Count().should_be(0);
                b.contact3.Errors.Count().should_be(0);
                b.blanket1.Errors.Count().should_be(0);
                b.blanket2.Errors.Count().should_be(0);
                b.blanket3.Errors.Count().should_be(0);
                b.cashBank.Errors.Count().should_be(0);
                b.cashBank2.Errors.Count().should_be(0);
                b.csi1.Errors.Count().should_be(0);
                b.csi2.Errors.Count().should_be(0);
                b.csi3.Errors.Count().should_be(1);
                b.csid1.Errors.Count().should_be(0);
                b.csid2.Errors.Count().should_be(0);
                b.csid3.Errors.Count().should_be(0);
            };

            it["validates_confirmed_cashsalesinvoice"] = () =>
            {
                b.csi1.IsConfirmed.should_be_true();
                b.csi2.IsConfirmed.should_be_true();
                b.csi3.IsConfirmed.should_be_true();
            };

            it["validates_paid_cashsalesinvoice"] = () =>
            {
                b.csi1.IsPaid.should_be_true();
                b.csi2.IsPaid.should_be_true();
                b.csi3.IsPaid.should_be_false();

                b.csi1.IsFullPayment.should_be_false();
                b.csi2.IsFullPayment.should_be_true();
                b.csi3.IsFullPayment.should_be_false();

                b._cashSalesInvoiceService.PaidObject(b.csi3, b.csi3.Total - 50000, 50000, b._cashBankService, b._receivableService, b._receiptVoucherService, b._receiptVoucherDetailService, b._contactService, b._cashMutationService, b._cashSalesReturnService,
                                                      b._generalLedgerJournalService, b._accountService, b._closingService);

                b.csi3.IsPaid.should_be_true();
                b.csi3.IsFullPayment.should_be_true();

                Item            item1            = b._itemService.GetObjectById(b.csid1.ItemId);
                QuantityPricing quantityPricing1 = b._quantityPricingService.GetObjectByItemTypeIdAndQuantity(item1.ItemTypeId, b.csid1.Quantity);
                Item            item2            = b._itemService.GetObjectById(b.csid2.ItemId);
                QuantityPricing quantityPricing2 = b._quantityPricingService.GetObjectByItemTypeIdAndQuantity(item2.ItemTypeId, b.csid2.Quantity);

                b.csid1.CoGS.should_be(b.csid1.Quantity * b.blanket1.AvgPrice);                                                   // Quantity=100, AvgPrice=10000
                b.csid1.Amount.should_be(b.csid1.Quantity * (b.blanket1.SellingPrice * (100 - quantityPricing1.Discount) / 100)); // SellingPrice=10000, QuantityPricing discount = 50% for quantity>=51

                b.csid2.CoGS.should_be(b.csid2.Quantity * b.blanket2.AvgPrice);                                                   // Quantity=30, AvgPrice=20000
                b.csid2.Amount.should_be(b.csid2.Quantity * (b.blanket2.SellingPrice * (100 - quantityPricing2.Discount) / 100)); // SellingPrice=20000, QuantityPricing discount = 10% for quantity=20-40, 25% for q=30-50
                b.csid4.Amount.should_be(b.csid4.Quantity * (b.blanket3.SellingPrice * (100 - b.csid4.Discount) / 100));          // SellingPrice=30000, not existed QuantityPricing for Q=10
            };

            it["validates_receivables_and_receiptvouchers"] = () =>
            {
                b._cashSalesInvoiceService.PaidObject(b.csi3, b.csi3.Total - 50000, 50000, b._cashBankService, b._receivableService, b._receiptVoucherService, b._receiptVoucherDetailService, b._contactService, b._cashMutationService, b._cashSalesReturnService,
                                                      b._generalLedgerJournalService, b._accountService, b._closingService);

                Receivable receivable1 = b._receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.CashSalesInvoice, b.csi1.Id);
                Receivable receivable2 = b._receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.CashSalesInvoice, b.csi2.Id);
                Receivable receivable3 = b._receivableService.GetObjectBySource(Core.Constants.Constant.ReceivableSource.CashSalesInvoice, b.csi3.Id);

                IList <ReceiptVoucherDetail> receiptVoucherDetails1 = b._receiptVoucherDetailService.GetObjectsByReceivableId(receivable1.Id);
                IList <ReceiptVoucherDetail> receiptVoucherDetails2 = b._receiptVoucherDetailService.GetObjectsByReceivableId(receivable2.Id);
                IList <ReceiptVoucherDetail> receiptVoucherDetails3 = b._receiptVoucherDetailService.GetObjectsByReceivableId(receivable3.Id);

                foreach (var receiptVoucherDetail in receiptVoucherDetails1)
                {
                    receiptVoucherDetail.IsConfirmed.should_be_true();
                    receivable1.RemainingAmount.should_be(b.csi1.Total - (receiptVoucherDetail.Amount + receivable1.AllowanceAmount));
                }

                foreach (var receiptVoucherDetail in receiptVoucherDetails2)
                {
                    receiptVoucherDetail.IsConfirmed.should_be_true();
                    receivable2.RemainingAmount.should_be(b.csi2.Total - (receiptVoucherDetail.Amount + receivable2.AllowanceAmount));
                }

                foreach (var receiptVoucherDetail in receiptVoucherDetails3)
                {
                    receiptVoucherDetail.IsConfirmed.should_be_true();
                    receivable3.RemainingAmount.should_be(b.csi3.Total - (receiptVoucherDetail.Amount + receivable3.AllowanceAmount));
                }

                receiptVoucherDetails1.Count().should_be(1);
                receiptVoucherDetails2.Count().should_be(1);
                receiptVoucherDetails3.Count().should_be(1);
            };

            context["when_unpaid_cashsalesinvoice"] = () =>
            {
                before = () =>
                {
                    b._cashSalesInvoiceService.PaidObject(b.csi3, b.csi3.Total - 50000, 50000, b._cashBankService, b._receivableService, b._receiptVoucherService, b._receiptVoucherDetailService, b._contactService, b._cashMutationService, b._cashSalesReturnService,
                                                          b._generalLedgerJournalService, b._accountService, b._closingService);
                    b._cashSalesInvoiceService.UnpaidObject(b.csi1, b._receiptVoucherService, b._receiptVoucherDetailService, b._cashBankService, b._receivableService, b._cashMutationService,
                                                            b._cashSalesReturnService, b._generalLedgerJournalService, b._accountService, b._closingService);
                    b._cashSalesInvoiceService.UnpaidObject(b.csi2, b._receiptVoucherService, b._receiptVoucherDetailService, b._cashBankService, b._receivableService, b._cashMutationService,
                                                            b._cashSalesReturnService, b._generalLedgerJournalService, b._accountService, b._closingService);
                    b._cashSalesInvoiceService.UnpaidObject(b.csi3, b._receiptVoucherService, b._receiptVoucherDetailService, b._cashBankService, b._receivableService, b._cashMutationService,
                                                            b._cashSalesReturnService, b._generalLedgerJournalService, b._accountService, b._closingService);
                    b.csi1.Errors.Count().should_not_be(0); // Already have CashSalesReturn
                    b.csi2.Errors.Count().should_be(0);
                    b.csi3.Errors.Count().should_be(0);
                    b.csid1.Errors.Count().should_be(0);
                    b.csid2.Errors.Count().should_be(0);
                    b.csid3.Errors.Count().should_be(0);
                };

                it["validates_unpaid_cashsalesinvoice"] = () =>
                {
                    b.csi1.IsPaid.should_be_true(); // Already have CashSalesReturn
                    b.csi2.IsPaid.should_be_false();
                    b.csi3.IsPaid.should_be_false();

                    b.csi2.IsFullPayment.should_be_false();
                    b.csi3.IsFullPayment.should_be_false();

                    b.csi1.AmountPaid.should_not_be(0);
                    b.csi2.AmountPaid.should_be(0);
                    //b.csi3.AmountPaid.should_be_null();
                };

                context["when_unconfirm_cashsalesinvoice"] = () =>
                {
                    before = () =>
                    {
                        b._cashSalesInvoiceService.UnconfirmObject(b.csi1, b._cashSalesInvoiceDetailService, b._receivableService, b._receiptVoucherDetailService, b._warehouseItemService, b._warehouseService,
                                                                   b._itemService, b._barringService, b._stockMutationService, b._generalLedgerJournalService, b._accountService, b._closingService);
                        b._cashSalesInvoiceService.UnconfirmObject(b.csi2, b._cashSalesInvoiceDetailService, b._receivableService, b._receiptVoucherDetailService, b._warehouseItemService, b._warehouseService,
                                                                   b._itemService, b._barringService, b._stockMutationService, b._generalLedgerJournalService, b._accountService, b._closingService);
                        b._cashSalesInvoiceService.UnconfirmObject(b.csi3, b._cashSalesInvoiceDetailService, b._receivableService, b._receiptVoucherDetailService, b._warehouseItemService, b._warehouseService,
                                                                   b._itemService, b._barringService, b._stockMutationService, b._generalLedgerJournalService, b._accountService, b._closingService);
                        b.csi1.Errors.Count().should_not_be(0);
                        b.csi2.Errors.Count().should_be(0);
                        b.csi3.Errors.Count().should_be(0);
                        b.csid1.Errors.Count().should_be(0);
                        b.csid2.Errors.Count().should_be(0);
                        b.csid3.Errors.Count().should_be(0);
                    };

                    it["validates_unconfirmed_cashsalesinvoice"] = () =>
                    {
                        b.csi1.IsConfirmed.should_be_true();
                        b.csi2.IsConfirmed.should_be_false();
                        b.csi3.IsConfirmed.should_be_false();
                    };
                };
            };

            context["when_creating_cashsalesreturn"] = () =>
            {
                before = () =>
                {
                    b.csr1.Errors.Count().should_be(0);
                    b.csrd1.Errors.Count().should_be(0);
                };

                it["validates_confirmed_cashsalesreturn"] = () =>
                {
                    b.csr1.IsConfirmed.should_be_true();
                };

                it["validates_paid_cashsalesreturn"] = () =>
                {
                    b.csr1.IsPaid.should_be_true();

                    b.csr1.Total.should_be(b.csrd1.Quantity * (b.csid1.Amount / b.csid1.Quantity)); // Item price = 10000
                };

                it["validates_payables_and_paymentvouchers"] = () =>
                {
                    Payable payable1 = b._payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CashSalesReturn, b.csr1.Id);

                    IList <PaymentVoucherDetail> paymentVoucherDetails1 = b._paymentVoucherDetailService.GetObjectsByPayableId(payable1.Id);

                    foreach (var paymentVoucherDetail in paymentVoucherDetails1)
                    {
                        paymentVoucherDetail.IsConfirmed.should_be_true();
                        payable1.RemainingAmount.should_be(b.csr1.Total - (paymentVoucherDetail.Amount + payable1.AllowanceAmount));
                    }

                    paymentVoucherDetails1.Count().should_be(1);
                };

                it["validates_unpaid_cashsalesinvoice_with_cashsalesreturn"] = () =>
                {
                    b._cashSalesInvoiceService.UnpaidObject(b.csi1, b._receiptVoucherService, b._receiptVoucherDetailService, b._cashBankService, b._receivableService, b._cashMutationService,
                                                            b._cashSalesReturnService, b._generalLedgerJournalService, b._accountService, b._closingService);

                    b.csi1.Errors.Count().should_not_be(0);
                };

                context["when_unpaid_cashsalesreturn"] = () =>
                {
                    before = () =>
                    {
                        b._cashSalesReturnService.UnpaidObject(b.csr1, b._paymentVoucherService, b._paymentVoucherDetailService, b._cashBankService, b._payableService, b._cashMutationService,
                                                               b._generalLedgerJournalService, b._accountService, b._closingService);
                        b.csr1.Errors.Count().should_be(0);
                        b.csrd1.Errors.Count().should_be(0);
                    };

                    it["validates_unpaid_cashsalesreturn"] = () =>
                    {
                        b.csr1.IsPaid.should_be_false();
                    };

                    context["when_unconfirm_cashsalesreturn"] = () =>
                    {
                        before = () =>
                        {
                            b._cashSalesReturnService.UnconfirmObject(b.csr1, b._cashSalesReturnDetailService, b._cashSalesInvoiceDetailService, b._payableService,
                                                                      b._paymentVoucherDetailService, b._warehouseItemService, b._warehouseService, b._itemService,
                                                                      b._barringService, b._stockMutationService, b._closingService);

                            b.csr1.Errors.Count().should_be(0);

                            b.csrd1.Errors.Count().should_be(0);
                        };

                        it["validates_unconfirmed_cashsalesreturn"] = () =>
                        {
                            b.csr1.IsConfirmed.should_be_false();
                        };

                        it["validates_delete_cashsalesreturn"] = () =>
                        {
                            b._cashSalesReturnDetailService.SoftDeleteObject(b.csrd1, b._cashSalesReturnService);
                            b._cashSalesReturnService.SoftDeleteObject(b.csr1, b._cashSalesReturnDetailService);
                            b.csrd1.Errors.Count().should_be(0);
                            b.csr1.Errors.Count().should_be(0);
                        };

                        it["validates_unpaid_cashsalesinvoice_after_cashsalesreturn_deleted"] = () =>
                        {
                            b._cashSalesReturnDetailService.SoftDeleteObject(b.csrd1, b._cashSalesReturnService);
                            b._cashSalesReturnService.SoftDeleteObject(b.csr1, b._cashSalesReturnDetailService);
                            b._cashSalesInvoiceService.UnpaidObject(b.csi1, b._receiptVoucherService, b._receiptVoucherDetailService, b._cashBankService, b._receivableService,
                                                                    b._cashMutationService, b._cashSalesReturnService, b._generalLedgerJournalService, b._accountService, b._closingService);

                            b.csi1.Errors.Count().should_be(0);
                        };
                    };
                };
            };
        }
Exemplo n.º 19
0
 public bool ValidUpdateObject(QuantityPricing quantityPricing, int oldItemTypeId, IQuantityPricingService _quantityPricingService, IItemTypeService _itemTypeService)
 {
     quantityPricing.Errors.Clear();
     VUpdateObject(quantityPricing, oldItemTypeId, _quantityPricingService, _itemTypeService);
     return(isValid(quantityPricing));
 }
Exemplo n.º 20
0
 public bool ValidDeleteObject(QuantityPricing quantityPricing)
 {
     quantityPricing.Errors.Clear();
     VDeleteObject(quantityPricing);
     return(isValid(quantityPricing));
 }
Exemplo n.º 21
0
        public bool isValid(QuantityPricing obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
Exemplo n.º 22
0
        public void PopulateMasterData()
        {
            localWarehouse = new Warehouse()
            {
                Name        = "Sentral Solusi Data",
                Description = "Kali Besar Jakarta",
                Code        = "LCL"
            };
            localWarehouse = _warehouseService.CreateObject(localWarehouse, _warehouseItemService, _itemService);

            Pcs = new UoM()
            {
                Name = "Pcs"
            };
            _uomService.CreateObject(Pcs);

            Boxes = new UoM()
            {
                Name = "Boxes"
            };
            _uomService.CreateObject(Boxes);

            Tubs = new UoM()
            {
                Name = "Tubs"
            };
            _uomService.CreateObject(Tubs);

            blanket1 = new Item()
            {
                ItemTypeId   = _itemTypeService.GetObjectByName("Blanket").Id,
                Name         = "Blanket1",
                Category     = "Blanket",
                Sku          = "BLK1",
                UoMId        = Pcs.Id,
                SellingPrice = 10000,
                AvgPrice     = 10000,
            };

            blanket1 = _itemService.CreateObject(blanket1, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);

            blanket2 = new Item()
            {
                ItemTypeId   = _itemTypeService.GetObjectByName("Blanket").Id,
                Name         = "Blanket2",
                Category     = "Blanket",
                Sku          = "BLK2",
                UoMId        = Pcs.Id,
                SellingPrice = 20000,
                AvgPrice     = 20000
            };

            blanket2 = _itemService.CreateObject(blanket2, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);

            blanket3 = new Item()
            {
                ItemTypeId   = _itemTypeService.GetObjectByName("Blanket").Id,
                Name         = "Blanket3",
                Category     = "Blanket",
                Sku          = "BLK3",
                UoMId        = Pcs.Id,
                SellingPrice = 30000,
                AvgPrice     = 30000
            };

            blanket3 = _itemService.CreateObject(blanket3, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);

            qp1 = new QuantityPricing()
            {
                ItemTypeId            = _itemTypeService.GetObjectByName("Blanket").Id,
                Discount              = 10,
                MinQuantity           = 20,
                MaxQuantity           = 40,
                IsInfiniteMaxQuantity = false
            };
            _quantityPricingService.CreateObject(qp1, _itemTypeService);

            qp2 = new QuantityPricing()
            {
                ItemTypeId            = _itemTypeService.GetObjectByName("Blanket").Id,
                Discount              = 25,
                MinQuantity           = 30,
                MaxQuantity           = 50,
                IsInfiniteMaxQuantity = false
            };
            _quantityPricingService.CreateObject(qp2, _itemTypeService);

            qp3 = new QuantityPricing()
            {
                ItemTypeId            = _itemTypeService.GetObjectByName("Blanket").Id,
                Discount              = 50,
                MinQuantity           = 51,
                IsInfiniteMaxQuantity = true
            };
            _quantityPricingService.CreateObject(qp3, _itemTypeService);

            contact = new Contact()
            {
                Name         = "President of Indonesia",
                Address      = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat",
                ContactNo    = "021 3863777",
                PIC          = "Mr. President",
                PICContactNo = "021 3863777",
                Email        = "*****@*****.**"
            };
            _contactService.CreateObject(contact, _contactGroupService);

            contact2 = new Contact()
            {
                Name         = "Wakil President of Indonesia",
                Address      = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat",
                ContactNo    = "021 3863777",
                PIC          = "Mr. Wakil President",
                PICContactNo = "021 3863777",
                Email        = "*****@*****.**"
            };
            _contactService.CreateObject(contact2, _contactGroupService);

            contact3 = new Contact()
            {
                Name           = "Roma Irama",
                Address        = "Istana Negara Jl. Veteran No.20 Jakarta Pusat",
                ContactNo      = "021 5551234",
                PIC            = "Mr. King",
                PICContactNo   = "021 5551234",
                Email          = "*****@*****.**",
                ContactGroupId = group2.Id,
            };
            _contactService.CreateObject(contact3, _contactGroupService);

            cashBank = new CashBank()
            {
                Name        = "Kontan",
                Description = "Bayar kontan",
                IsBank      = false
            };
            _cashBankService.CreateObject(cashBank, _accountService);

            cashBank2 = new CashBank()
            {
                Name        = "Rekening BRI",
                Description = "Untuk cashflow",
                IsBank      = true
            };
            _cashBankService.CreateObject(cashBank2, _accountService);

            cashBankAdjustment = new CashBankAdjustment()
            {
                CashBankId     = cashBank.Id,
                Amount         = 1000000000,
                AdjustmentDate = DateTime.Today,
            };
            _cashBankAdjustmentService.CreateObject(cashBankAdjustment, _cashBankService);

            cashBankAdjustment2 = new CashBankAdjustment()
            {
                CashBankId     = cashBank2.Id,
                Amount         = 1000000000,
                AdjustmentDate = DateTime.Today,
            };
            _cashBankAdjustmentService.CreateObject(cashBankAdjustment2, _cashBankService);

            _cashBankAdjustmentService.ConfirmObject(cashBankAdjustment, DateTime.Now, _cashMutationService, _cashBankService,
                                                     _generalLedgerJournalService, _accountService, _closingService);
            _cashBankAdjustmentService.ConfirmObject(cashBankAdjustment2, DateTime.Now, _cashMutationService, _cashBankService,
                                                     _generalLedgerJournalService, _accountService, _closingService);

            StockAdjustment sa = new StockAdjustment()
            {
                AdjustmentDate = DateTime.Now,
                Code           = "SA001",
                WarehouseId    = localWarehouse.Id
            };

            _stockAdjustmentService.CreateObject(sa, _warehouseService);

            StockAdjustmentDetail sad1 = new StockAdjustmentDetail()
            {
                StockAdjustmentId = sa.Id,
                ItemId            = blanket1.Id,
                Quantity          = 100000,
                Code  = "SAD001",
                Price = 50000
            };

            _stockAdjustmentDetailService.CreateObject(sad1, _stockAdjustmentService, _itemService, _warehouseItemService);

            StockAdjustmentDetail sad2 = new StockAdjustmentDetail()
            {
                StockAdjustmentId = sa.Id,
                ItemId            = blanket2.Id,
                Quantity          = 100000,
                Code  = "SAD002",
                Price = 50000
            };

            _stockAdjustmentDetailService.CreateObject(sad2, _stockAdjustmentService, _itemService, _warehouseItemService);

            StockAdjustmentDetail sad3 = new StockAdjustmentDetail()
            {
                StockAdjustmentId = sa.Id,
                ItemId            = blanket3.Id,
                Quantity          = 100000,
                Code  = "SAD003",
                Price = 50000
            };

            _stockAdjustmentDetailService.CreateObject(sad3, _stockAdjustmentService, _itemService, _warehouseItemService);

            _stockAdjustmentService.ConfirmObject(sa, DateTime.Today, _stockAdjustmentDetailService, _stockMutationService, _itemService, _barringService,
                                                  _warehouseItemService, _generalLedgerJournalService, _accountService, _closingService);
        }
Exemplo n.º 23
0
        public bool IsQuantityPricingDuplicated(QuantityPricing quantityPricing)
        {
            IQueryable <QuantityPricing> quantityPricings = _repository.FindAll(x => x.ItemTypeId == quantityPricing.ItemTypeId && x.MinQuantity == quantityPricing.MinQuantity && x.MaxQuantity == quantityPricing.MaxQuantity && !x.IsDeleted && x.Id != quantityPricing.Id);

            return(quantityPricings.Count() > 0 ? true : false);
        }
Exemplo n.º 24
0
 public QuantityPricing SoftDeleteObject(QuantityPricing quantityPricing)
 {
     return(quantityPricing = _validator.ValidDeleteObject(quantityPricing) ?
                              _repository.SoftDeleteObject(quantityPricing) : quantityPricing);
 }
Exemplo n.º 25
0
 public bool ValidCreateObject(QuantityPricing quantityPricing, IQuantityPricingService _quantityPricingService, IItemTypeService _itemTypeService)
 {
     VCreateObject(quantityPricing, _quantityPricingService, _itemTypeService);
     return(isValid(quantityPricing));
 }