예제 #1
0
        // For Order
        public static void ConvertFrom(EntityOrderH entityH, ref EntityBaseH entityBaseH, ObservableCollection<EntityOrderD> entityD, ref ObservableCollection<EntityBaseD> entityBaseD)
        {
            entityBaseD = new ObservableCollection<EntityBaseD>();

            for (int i = 0; i <= entityD.Count - 1; i++)
            {
                EntityBaseD _entityBaseD = new EntityBaseD();

                #region Set Entity Detail

                _entityBaseD.id = entityD[i]._id;
                _entityBaseD.rec_no = entityD[i]._rec_no;
                _entityBaseD.breakdown_id = entityD[i]._breakdown_id;
                _entityBaseD.breakdown_nm = entityD[i]._breakdown_nm;
                _entityBaseD.deliver_division_id = entityD[i]._deliver_division_id;
                _entityBaseD.deliver_division_nm = entityD[i]._deliver_division_nm;
                _entityBaseD.commodity_id = entityD[i]._commodity_id;
                _entityBaseD.commodity_name = entityD[i]._commodity_name;
                _entityBaseD.unit_id = entityD[i]._unit_id;
                _entityBaseD.unit_nm = entityD[i]._unit_nm;
                _entityBaseD.enter_number = entityD[i]._enter_number;
                _entityBaseD.case_number = entityD[i]._case_number;
                _entityBaseD.number = entityD[i]._number;
                _entityBaseD.unit_price = entityD[i]._unit_price;
                _entityBaseD.sales_cost = entityD[i]._sales_cost;
                _entityBaseD.tax = entityD[i]._tax;
                _entityBaseD.no_tax_price = entityD[i]._no_tax_price;
                _entityBaseD.price = entityD[i]._price;
                _entityBaseD.profits = entityD[i]._profits;
                _entityBaseD.profits_percent = entityD[i]._profits_percent;
                _entityBaseD.tax_division_id = entityD[i]._tax_division_id;
                _entityBaseD.tax_division_nm = entityD[i]._tax_division_nm;
                _entityBaseD.tax_percent = entityD[i]._tax_percent;
                _entityBaseD.inventory_management_division_id = entityD[i]._inventory_management_division_id;
                _entityBaseD.inventory_number = entityD[i]._inventory_number;
                _entityBaseD.retail_price_skip_tax = entityD[i]._retail_price_skip_tax;
                _entityBaseD.retail_price_before_tax = entityD[i]._retail_price_before_tax;
                _entityBaseD.sales_unit_price_skip_tax = entityD[i]._sales_unit_price_skip_tax;
                _entityBaseD.sales_unit_price_before_tax = entityD[i]._sales_unit_price_before_tax;
                _entityBaseD.sales_cost_price_skip_tax = entityD[i]._sales_cost_price_skip_tax;
                _entityBaseD.sales_cost_price_before_tax = entityD[i]._sales_cost_price_before_tax;
                _entityBaseD.number_decimal_digit = entityD[i]._number_decimal_digit;
                _entityBaseD.unit_decimal_digit = entityD[i]._unit_decimal_digit;

                #endregion

                entityBaseD.Add(_entityBaseD);
            }

            entityBaseH = new EntityBaseH();

            #region Set Entity Head

            entityBaseH.tax_change_id = entityH._tax_change_id;
            entityBaseH.business_division_id = entityH._business_division_id;
            entityBaseH.price_fraction_proc_id = entityH._price_fraction_proc_id;
            entityBaseH.tax_fraction_proc_id = entityH._tax_fraction_proc_id;
            entityBaseH.unit_kind_id = entityH._unit_kind_id;
            entityBaseH.sum_enter_number = entityH._sum_enter_number;
            entityBaseH.sum_case_number = entityH._sum_case_number;
            entityBaseH.sum_number = entityH._sum_number;
            entityBaseH.sum_unit_price = entityH._sum_unit_price;
            entityBaseH.sum_sales_cost = entityH._sum_sales_cost;
            entityBaseH.sum_tax = entityH._sum_tax;
            entityBaseH.sum_no_tax_price = entityH._sum_no_tax_price;
            entityBaseH.sum_price = entityH._sum_price;
            entityBaseH.sum_profits = entityH._sum_profits;
            entityBaseH.profits_percent = entityH._profits_percent;
            entityBaseH.credit_rate = entityH._credit_rate;

            #endregion
        }
예제 #2
0
        private static void _CalcSumDetail(ref EntityBaseH entityBaseH, ref ObservableCollection<EntityBaseD> entityBaseD)
        { 
            double price = 0;

            // 初期化
            entityBaseH.sum_enter_number = 0;
            entityBaseH.sum_case_number = 0;
            entityBaseH.sum_number = 0;
            entityBaseH.sum_unit_price = 0;
            entityBaseH.sum_sales_cost = 0;
            entityBaseH.sum_price = 0;
            entityBaseH.sum_tax = 0;
            entityBaseH.sum_no_tax_price = 0;
            entityBaseH.sum_profits = 0;
            entityBaseH.profits_percent = 0;

            for (int i = 0; i <= entityBaseD.Count - 1; i++)
            {
                // 納品区分が取消以外
                if (entityBaseD[i].deliver_division_id != 4)
                {
                    entityBaseH.sum_enter_number += entityBaseD[i].enter_number;
                    entityBaseH.sum_case_number += entityBaseD[i].case_number;
                    entityBaseH.sum_number += entityBaseD[i].number;
                    entityBaseH.sum_unit_price += entityBaseD[i].unit_price;
                    entityBaseH.sum_sales_cost += entityBaseD[i].sales_cost;
                    entityBaseH.sum_price += entityBaseD[i].price;
                    entityBaseH.sum_tax += entityBaseD[i].tax;
                    entityBaseH.sum_no_tax_price += entityBaseD[i].no_tax_price;
                    entityBaseH.sum_profits += entityBaseD[i].profits;

                    // 課税区分(外税/伝票単位, 内税/伝票単位)
                    if (entityBaseH.tax_change_id == 1 || entityBaseH.tax_change_id == 4)
                    {
                        // 課税対象
                        if (entityBaseD[i].tax_division_id == 1)
                        {
                            price += entityBaseD[i].price;
                        }
                    }
                }
            }

            // 課税区分(外税/伝票単位, 内税/伝票単位)
            if (entityBaseH.tax_change_id == 1 || entityBaseH.tax_change_id == 4)
            {
                entityBaseH.sum_tax = ExMath.zCalcTax(price, entityBaseH.tax_change_id, 0, entityBaseH.tax_fraction_proc_id);

                if (entityBaseH.tax_change_id == 1)
                {
                    // 外税
                    entityBaseH.sum_no_tax_price = entityBaseH.sum_price;
                }
                else
                {
                    // 内税
                    entityBaseH.sum_no_tax_price = entityBaseH.sum_price - entityBaseH.sum_tax;
                }
            }

            if (entityBaseH.sum_no_tax_price != 0 && entityBaseH.sum_profits != 0)
            {
                entityBaseH.profits_percent = ExMath.zFloor((entityBaseH.sum_profits / entityBaseH.sum_no_tax_price) * 100, 0);
            }
        }
예제 #3
0
        // For InOutDelivery
        public static void ConvertTo(EntityBaseH entityBaseH, ref EntityInOutDeliveryH entityH, ObservableCollection<EntityBaseD> entityBaseD, ref ObservableCollection<EntityInOutDeliveryD> entityD)
        {
            for (int i = 0; i <= entityD.Count - 1; i++)
            {
                #region Set Entity

                entityD[i]._id = entityBaseD[i].id;
                entityD[i]._rec_no = entityBaseD[i].rec_no;
                //entityD[i]._breakdown_id = entityBaseD[i].breakdown_id;
                //entityD[i]._breakdown_nm = entityBaseD[i].breakdown_nm;
                //entityD[i]._deliver_division_id = entityBaseD[i].deliver_division_id;
                //entityD[i]._deliver_division_nm = entityBaseD[i].deliver_division_nm;
                entityD[i]._commodity_id = entityBaseD[i].commodity_id;
                entityD[i]._commodity_name = entityBaseD[i].commodity_name;
                entityD[i]._unit_id = entityBaseD[i].unit_id;
                entityD[i]._unit_nm = entityBaseD[i].unit_nm;
                entityD[i]._enter_number = entityBaseD[i].enter_number;
                entityD[i]._case_number = entityBaseD[i].case_number;
                entityD[i]._number = entityBaseD[i].number;
                //entityD[i]._order_number = entityBaseD[i].order_number;
                //entityD[i]._order_stay_number = entityBaseD[i].order_stay_number;
                //entityD[i]._unit_price = entityBaseD[i].unit_price;
                //entityD[i]._sales_cost = entityBaseD[i].sales_cost;
                //entityD[i]._tax = entityBaseD[i].tax;
                //entityD[i]._no_tax_price = entityBaseD[i].no_tax_price;
                //entityD[i]._price = entityBaseD[i].price;
                //entityD[i]._profits = entityBaseD[i].profits;
                //entityD[i]._profits_percent = entityBaseD[i].profits_percent;
                //entityD[i]._tax_division_id = entityBaseD[i].tax_division_id;
                //entityD[i]._tax_division_nm = entityBaseD[i].tax_division_nm;
                //entityD[i]._tax_percent = entityBaseD[i].tax_percent;
                entityD[i]._inventory_management_division_id = entityBaseD[i].inventory_management_division_id;
                entityD[i]._inventory_number = entityBaseD[i].inventory_number;
                //entityD[i]._retail_price_skip_tax = entityBaseD[i].retail_price_skip_tax;
                //entityD[i]._retail_price_before_tax = entityBaseD[i].retail_price_before_tax;
                //entityD[i]._sales_unit_price_skip_tax = entityBaseD[i].sales_unit_price_skip_tax;
                //entityD[i]._sales_unit_price_before_tax = entityBaseD[i].sales_unit_price_before_tax;
                //entityD[i]._sales_cost_price_skip_tax = entityBaseD[i].sales_cost_price_skip_tax;
                //entityD[i]._sales_cost_price_before_tax = entityBaseD[i].sales_cost_price_before_tax;
                entityD[i]._number_decimal_digit = entityBaseD[i].number_decimal_digit;
                //entityD[i]._unit_decimal_digit = entityBaseD[i].unit_decimal_digit;

                #endregion
            }

            #region Set Entity Head

            //entityH._tax_change_id = entityBaseH.tax_change_id;
            //entityH._business_division_id = entityBaseH.business_division_id;
            //entityH._price_fraction_proc_id = entityBaseH.price_fraction_proc_id;
            //entityH._tax_fraction_proc_id = entityBaseH.tax_fraction_proc_id;
            //entityH._unit_kind_id = entityBaseH.unit_kind_id;
            entityH._sum_enter_number = entityBaseH.sum_enter_number;
            entityH._sum_case_number = entityBaseH.sum_case_number;
            entityH._sum_number = entityBaseH.sum_number;
            //entityH._sum_unit_price = entityBaseH.sum_unit_price;
            //entityH._sum_sales_cost = entityBaseH.sum_sales_cost;
            //entityH._sum_tax = entityBaseH.sum_tax;
            //entityH._sum_no_tax_price = entityBaseH.sum_no_tax_price;
            //entityH._sum_price = entityBaseH.sum_price;
            //entityH._sum_profits = entityBaseH.sum_profits;
            //entityH._profits_percent = entityBaseH.profits_percent;
            //entityH._credit_rate = entityBaseH.credit_rate;

            #endregion

        }
예제 #4
0
        private static void _CalcDetail(int i, ref EntityBaseH entityBaseH, ref ObservableCollection<EntityBaseD> entityBaseD)
        {
            if (DataDetail.IsCalcPrice == true)
            {
                // 金額
                entityBaseD[i].price = ExMath.zCalcPrice((entityBaseD[i].number * entityBaseD[i].unit_price), entityBaseH.price_fraction_proc_id, 0);
            }

            // 消費税計算
            if (entityBaseD[i].tax_division_id == 1)
            {
                // 課税
                switch (entityBaseH.tax_change_id)
                {
                    // 外税/明細単位, 内税/明細単位
                    case 2:
                    case 5:
                        entityBaseD[i].tax = ExMath.zCalcTax(entityBaseD[i].price, entityBaseH.tax_change_id, 0, entityBaseH.tax_fraction_proc_id);
                        break;
                    default:
                        entityBaseD[i].tax = 0;
                        break;
                }
            }
            else
            {
                // 非課税
                entityBaseD[i].tax = 0;
            }

            // 税抜金額
            if (entityBaseH.tax_change_id == 5)
            {
                // 内税/明細単位
                entityBaseD[i].no_tax_price = entityBaseD[i].price - entityBaseD[i].tax;
            }
            else
            {
                // 内税/明細単位以外
                entityBaseD[i].no_tax_price = entityBaseD[i].price;
            }

            // 粗利
            double _profits = entityBaseD[i].no_tax_price - (entityBaseD[i].number * entityBaseD[i].sales_cost);
            entityBaseD[i].profits = ExMath.zCalcPrice(_profits, entityBaseH.price_fraction_proc_id, 0);

            // 粗利率
            entityBaseD[i].profits_percent = ExMath.zFloor((entityBaseD[i].profits / entityBaseD[i].no_tax_price) * 100, 0);

            IsCalcPrice = true;
        }
예제 #5
0
        private static void _SetCommodityToDetail(int i, ref EntityBaseH entityBaseH, ref ObservableCollection<EntityBaseD> entityBaseD, svcMstData.EntityMstData _mst, eKbn kbn)
        {
            // 初期化
            entityBaseD[i].commodity_name = "";       // 商品名
            entityBaseD[i].unit_id = 0;               // 単位ID
            entityBaseD[i].enter_number = 0;          // 入数
            entityBaseD[i].case_number = 1;           // ケース数
            entityBaseD[i].number = 0;                // 数量
            entityBaseD[i].tax_division_id = 0;       // 税区分
            entityBaseD[i].tax_division_nm = "";      // 税区分名
            entityBaseD[i].tax_percent = 0;           // 税率
            entityBaseD[i].unit_price = 0;            // 売上単価
            entityBaseD[i].sales_cost = 0;            // 売上原価
            entityBaseD[i].price = 0;                 // 金額
            entityBaseD[i].tax = 0;                   // 消費税
            entityBaseD[i].no_tax_price = 0;          // 税抜金額
            entityBaseD[i].profits = 0;               // 粗利
            entityBaseD[i].profits_percent = 0;       // 粗利率
            entityBaseD[i].inventory_number = 0;      // 現在庫

            if (_mst == null)
            {
                return;
            }
            else
            {
                if (_mst.id == "")
                {
                    SetInitCombo(ref _mst);
                    entityBaseD[i].case_number = 0;        // ケース数
                }
            }

            entityBaseD[i].commodity_name = _mst.name;                        // 商品名
            entityBaseD[i].enter_number = ExCast.zCInt(_mst.attribute2);      // 入数

            // 数量(単価)小数桁
            entityBaseD[i].number_decimal_digit = ExCast.zCInt(_mst.attribute3);
            entityBaseD[i].unit_decimal_digit = ExCast.zCInt(_mst.attribute4);

            // 単位ID
            entityBaseD[i].unit_id = ExCast.zCInt(_mst.attribute1);
            entityBaseD[i].unit_nm = MeiNameList.GetName(MeiNameList.geNameKbn.UNIT_ID, entityBaseD[i].unit_id);

            // 税区分
            entityBaseD[i].tax_division_id = ExCast.zCInt(_mst.attribute5);
            entityBaseD[i].tax_division_nm = MeiNameList.GetName(MeiNameList.geNameKbn.TAX_DIVISION_ID, entityBaseD[i].tax_division_id);

            // 税区分が課税で内訳が消費税の場合
            if (entityBaseD[i].tax_division_id == 1 && entityBaseD[i].breakdown_id == 5)
            {
                entityBaseD[i].tax_division_nm = "非課税";
                entityBaseD[i].tax_division_id = MeiNameList.GetID(MeiNameList.geNameKbn.TAX_DIVISION_ID, ExCast.zCStr(entityBaseD[i].tax_division_nm));
            }

            entityBaseD[i].tax_percent = 5;

            int _credit_rate = entityBaseH.credit_rate;
            if (_credit_rate == 0) _credit_rate = 100;

            // 上代税込
            entityBaseD[i].retail_price_before_tax = ExMath.zFloor(ExCast.zCDbl(_mst.attribute10) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
            // 売上単価税込
            entityBaseD[i].sales_unit_price_before_tax = ExMath.zFloor(ExCast.zCDbl(_mst.attribute12) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
            // 売上原価税込
            entityBaseD[i].sales_cost_price_before_tax = ExMath.zFloor(ExCast.zCDbl(_mst.attribute14) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
            // 仕入単価税込
            entityBaseD[i].purchase_unit_price_before_tax = ExMath.zFloor(ExCast.zCDbl(_mst.attribute16) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
            // 上代税抜
            entityBaseD[i].retail_price_skip_tax = ExMath.zFloor(ExCast.zCDbl(_mst.attribute9) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
            // 売上単価税抜
            entityBaseD[i].sales_unit_price_skip_tax = ExMath.zFloor(ExCast.zCDbl(_mst.attribute11) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
            // 売上原価税抜
            entityBaseD[i].sales_cost_price_skip_tax = ExMath.zFloor(ExCast.zCDbl(_mst.attribute13) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
            // 仕入単価税抜
            entityBaseD[i].purchase_unit_price_skip_tax = ExMath.zFloor(ExCast.zCDbl(_mst.attribute15) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);

            // 在庫
            entityBaseD[i].inventory_management_division_id = ExCast.zCInt(_mst.attribute6);
            entityBaseD[i].inventory_number = ExCast.zCDbl(_mst.attribute8);

            // 単価設定
            // 税転換が内税で明細課税有りの場合
            if ((entityBaseH.tax_change_id == 4 || entityBaseH.tax_change_id == 5 || entityBaseH.tax_change_id == 6) && entityBaseD[i].tax_division_id == 1)
            {
                switch (entityBaseH.unit_kind_id)
                {
                    case 1:     // 上代税込
                        entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].retail_price_before_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                        break;
                    case 2:     // 売上単価税込
                        switch (kbn)
                        {
                            case eKbn.Purchase:
                                entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].purchase_unit_price_before_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                                break;
                            default:
                                entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].sales_unit_price_before_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                                break;
                        }
                        break;
                    case 3:     // 売上原価税込
                        entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].sales_cost_price_before_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                        break;
                    default:
                        switch (kbn)
                        {
                            case eKbn.Purchase:
                                entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].purchase_unit_price_before_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                                break;
                            default:
                                entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].sales_unit_price_before_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                                break;
                        }
                        break;
                }
                // 売上原価税込
                entityBaseD[i].sales_cost = entityBaseD[i].sales_cost_price_before_tax;
            }
            else
            {
                switch (entityBaseH.unit_kind_id)
                {
                    case 1:     // 上代税抜
                        entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].retail_price_skip_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                        break;
                    case 2:     // 売上単価税抜
                        switch (kbn)
                        {
                            case eKbn.Purchase:
                                entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].purchase_unit_price_skip_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                                break;
                            default:
                                entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].sales_unit_price_skip_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                                break;
                        }
                        break;
                    case 3:     // 売上原価税抜
                        entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].sales_cost_price_skip_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                        break;
                    default:
                        switch (kbn)
                        {
                            case eKbn.Purchase:
                                entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].purchase_unit_price_skip_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                                break;
                            default:
                                entityBaseD[i].unit_price = ExMath.zFloor(ExCast.zCDbl(entityBaseD[i].sales_unit_price_skip_tax) * _credit_rate / 100, entityBaseD[i].unit_decimal_digit);
                                break;
                        }
                        break;
                }
                // 売上原価税抜
                entityBaseD[i].sales_cost = entityBaseD[i].sales_cost_price_skip_tax;
            }

            // 返品時
            if (entityBaseD[i].breakdown_id == 6)
            {
                CalRedcDetail(entityBaseD[i]);
            }
        }