示例#1
0
        public async Task <IActionResult> GetTaxRatesByCodeView(long TaxRatesByCodeId)
        {
            TaxRatesByCodeModule invMod = new TaxRatesByCodeModule();

            TaxRatesByCodeView view = await invMod.TaxRatesByCode.Query().GetViewById(TaxRatesByCodeId);

            return(Ok(view));
        }
示例#2
0
        public async Task <IActionResult> DeleteTaxRatesByCode([FromBody] TaxRatesByCodeView view)
        {
            TaxRatesByCodeModule invMod         = new TaxRatesByCodeModule();
            TaxRatesByCode       TaxRatesByCode = await invMod.TaxRatesByCode.Query().MapToEntity(view);

            invMod.TaxRatesByCode.DeleteTaxRatesByCode(TaxRatesByCode).Apply();

            return(Ok(view));
        }
示例#3
0
        public async Task <IActionResult> UpdateTaxRatesByCode([FromBody] TaxRatesByCodeView view)
        {
            TaxRatesByCodeModule invMod = new TaxRatesByCodeModule();

            TaxRatesByCode TaxRatesByCode = await invMod.TaxRatesByCode.Query().MapToEntity(view);


            invMod.TaxRatesByCode.UpdateTaxRatesByCode(TaxRatesByCode).Apply();

            TaxRatesByCodeView retView = await invMod.TaxRatesByCode.Query().GetViewById(TaxRatesByCode.TaxRatesByCodeId);


            return(Ok(retView));
        }
示例#4
0
        public async Task <IActionResult> AddTaxRatesByCode([FromBody] TaxRatesByCodeView view)
        {
            TaxRatesByCodeModule invMod = new TaxRatesByCodeModule();

            NextNumber nnTaxRatesByCode = await invMod.TaxRatesByCode.Query().GetNextNumber();

            view.TaxRatesByCodeNumber = nnTaxRatesByCode.NextNumberValue;

            TaxRatesByCode TaxRatesByCode = await invMod.TaxRatesByCode.Query().MapToEntity(view);

            invMod.TaxRatesByCode.AddTaxRatesByCode(TaxRatesByCode).Apply();

            TaxRatesByCodeView newView = await invMod.TaxRatesByCode.Query().GetViewByNumber(view.TaxRatesByCodeNumber);

            return(Ok(newView));
        }
示例#5
0
        public async Task TestAddUpdatDeleteComment()
        {
            TaxRatesByCodeModule TaxRatesByCodeMod = new TaxRatesByCodeModule();

            TaxRatesByCodeView view = new TaxRatesByCodeView()
            {
                TaxCode = "StateTaxUT",
                TaxRate = 4.85M,
                State   = "UT"
            };
            NextNumber nnNextNumber = await TaxRatesByCodeMod.TaxRatesByCode.Query().GetNextNumber();

            view.TaxRatesByCodeNumber = nnNextNumber.NextNumberValue;

            TaxRatesByCode taxRatesByCode = await TaxRatesByCodeMod.TaxRatesByCode.Query().MapToEntity(view);

            TaxRatesByCodeMod.TaxRatesByCode.AddTaxRatesByCode(taxRatesByCode).Apply();

            TaxRatesByCode newTaxRatesByCode = await TaxRatesByCodeMod.TaxRatesByCode.Query().GetEntityByNumber(view.TaxRatesByCodeNumber);

            Assert.NotNull(newTaxRatesByCode);

            newTaxRatesByCode.TaxRate = 4.86M;

            TaxRatesByCodeMod.TaxRatesByCode.UpdateTaxRatesByCode(newTaxRatesByCode).Apply();

            TaxRatesByCodeView updateView = await TaxRatesByCodeMod.TaxRatesByCode.Query().GetViewById(newTaxRatesByCode.TaxRatesByCodeId);

            string taxRatesByCodeString = updateView.TaxRate.ToString();

            Assert.NotSame(taxRatesByCodeString, "4.86");

            TaxRatesByCodeView lookupByCode = await TaxRatesByCodeMod.TaxRatesByCode.Query().GetViewByTaxCode(TypeofTaxRatesByCode.StateTaxUT.ToString());

            Assert.NotNull(lookupByCode);

            TaxRatesByCodeMod.TaxRatesByCode.DeleteTaxRatesByCode(newTaxRatesByCode).Apply();
            TaxRatesByCode lookupTaxRatesByCode = await TaxRatesByCodeMod.TaxRatesByCode.Query().GetEntityById(view.TaxRatesByCodeId);

            Assert.Null(lookupTaxRatesByCode);
        }
示例#6
0
        public async Task <bool> CreateBySalesOrder(ShipmentView shipmentCreation)
        {
            try
            {
                Shipment newShipment = await Shipment.Query().GetShipmentBySalesOrder(shipmentCreation);

                List <ShipmentDetail> newShipmentDetails = await ShipmentDetail.Query().GetShipmentDetailBySalesOrder(shipmentCreation);


                newShipment = await Shipment.Query().CalculatedAmountsByDetails(newShipment, newShipmentDetails);

                TaxRatesByCodeView lookupTaxesByCode = await TaxRatesByCode.Query().GetViewByTaxCode(TypeofTaxRatesByCode.StateTaxUT.ToString());

                newShipment.Tax = newShipment.Amount * lookupTaxesByCode.TaxRate;

                //TODO Calculate the codCost, duty, shipping cost
                //decimal shippingCost = await ShipmentsMod.Shipments.Query().CalculateShippingCost(newShipments);
                //decimal codCost=await ShipmentsMod.Shipments.Query().CalculateCodCost(newShipments);
                //decimal duty=await ShipmentsMod.Shipments.Query().CalculateDuty(newShipments);

                Shipment.AddShipment(newShipment).Apply();

                Shipment lookupShipment = await Shipment.Query().GetEntityByNumber(newShipment.ShipmentNumber);

                newShipmentDetails.ForEach(m => m.ShipmentId = lookupShipment.ShipmentId);
                ShipmentDetail.AddShipmentDetails(newShipmentDetails).Apply();

                IList <ShipmentDetail> updateShipmentDetails = await ShipmentDetail.Query().GetEntitiesByShipmentId(lookupShipment.ShipmentId);

                SalesOrderDetail.UpdateSalesOrderDetailByShipmentsDetail(newShipmentDetails).Apply();

                SalesOrder.UpdateSalesOrderAmountByShipmentsDetail(newShipment, newShipmentDetails.Sum(e => e.Amount)).Apply();

                return(true);
            }
            catch (Exception ex) { throw new Exception("CreateBySalesOrder", ex); }
        }