ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using HotelPms.Share.Data;
using HotelPms.Share.Util;
using Google.Protobuf.WellKnownTypes;
using customTypes;
using System.Data.Common;
using HotelPms.Share.IO;
using System.Reflection;
using HotelPms.Data.Common;
 
namespace HotelPms.Data.UseInfo;
 
/// ****************************** Description *******************************
/// ◇システム名称
///  ホテルPMS
/// ◇概要
///  
/// ◇履歴
///  2021/05/14  コード作成ツール    自動作成
/// ****************************** Declarations ******************************
public partial class UseRoom
{
    #region  ★★★★★ Property ★★★★★
 
    #endregion
 
    #region  ★★★★★ Function ★★★★★
 
    /// <summary>
    /// 通常売上伝票の削除
    /// ※手配、備品の関連売上伝票除外
    /// ※パックの場合、子伝票も削除する
    /// </summary>
    /// <returns></returns>
    public bool RemoveSale(Sale item)
    {
        try
        {
            if (item.Pack)
            {
                List<Sale> childList = new List<Sale>();
                foreach (Sale child in SaleList)
                {
                    if (child.PackSaleID == item.SaleID) { childList.Add(child); }
                }
                foreach (var child in childList) { SaleList.Remove(child); }
            }
 
            //売上伝票削除
            SaleList.Remove(item);
            return true;
        }
        catch (Exception ex)
        {
            OperationLog.Instance.WriteLog($"{MethodInfo.GetCurrentMethod()}:{ex.Message}");
            return false;
        }
    }
  
    /// <summary>
    /// 部屋に売上伝票を追加
    /// </summary>
    /// <param name="item"></param>
    public void AddSale(Sale item)
    {
        item.Parent = this;
        SaleList.Add(item);
    }
 
    /// <summary>
    /// 科目より売上伝票を作成する
    /// 完全新規
    /// </summary>
    /// <param name="item"></param>
    /// <returns></returns>
    public Sale AddSaleByItem(int saleID, int taxRate, HotelPms.Data.Master.Item item)
    {
        return AddSaleByItem(saleID, taxRate, item, null);
    }
 
    /// <summary>
    /// 科目より売上伝票を作成する
    /// </summary>
    /// <param name="item"></param>
    /// <param name="orgSale"></param>
    /// <returns></returns>
    public Sale AddSaleByItem(int saleID, int taxRate, HotelPms.Data.Master.Item item, Sale? orgSale)
    {
        Sale sale = new()
        {
            ID = ID,
            DetailID = DetailID,
            UseDate = UseDate,
            SaleID = saleID,
            ReceiptID = 0,
            ItemID = item.ID,
            ItemName = item.Name,
            Price = item.Price,
            Amount = 1,
            ServiceIOType = item.ServiceIOType,           //サービス料区分
            ServiceRate = item.ServiceRate,
            TaxType = item.TaxType,                       //0.消費税 1.軽減税
            TaxIOType = item.TaxIOType,                   //消費税区分
            TaxRate = (decimal)taxRate,
            BathTaxIOType = item.BathTaxIOType,
            AccTaxIOType = item.AccTaxIOType,
            DiscountRate = item.DiscountRate,
            DiscountSummary = item.DiscountSummary,
            DiscountID = item.DiscountID,
            Pack = item.PackFlg,
            PackChild = false,
            PackSaleID = 0,
            PersonType = item.PersonType,
            PersonCount = item.PersonCount,
            InFemale = 0,
            UseType = item.UseType,                      //0.ルームチャージ  1.一人単価
            BaseAmount = 1,                              //一人単価時の基本数量(人数連動用)  
            PersonRef = false,                           //人数連動があるかどうか
            SrcType = 0,                                 //生成元 0.通常 1.PBX課金 2.会場料金 3.手配 4.貸出 5.手配貸出 
            FixturesID = string.Empty,
            ItemKind = item.Kind,                        //科目種別
 
            //インボイス制度:内訳計算必要???
            Summary = 0,
            ServiceSummary = 0,
            TaxSummary = 0,
            BathTaxSummary = 0,
            AccTaxSummary = 0,
            TotalSummary = 0,
        };
 
        if (sale.ItemKind == (int)EItemKind.StayBase || sale.ItemKind == (int)EItemKind.DayUseBase)
        {
            sale.BathTaxType = 0;    //0.固定 1.可変(マスタ参照)
            sale.BathTaxUnitPrice = 0;   //一人毎入湯税          
        }
 
        //旧情報を引き継ぐ
        if(orgSale == null)
        {
            sale.ReceiptItemName = item.ReceiptName;
            sale.ReceiptPrtType = item.ReceiptPrtType;
            sale.ReceiptPage = 1;
        }
        else
        {
            sale.ReceiptItemName = orgSale.ReceiptItemName;
            sale.ReceiptPrtType = orgSale.ReceiptPrtType;
            sale.ReceiptPage = orgSale.ReceiptPage;
            sale.FixturesID = orgSale.FixturesID;
        }
 
        //パックの場合、子科目の追加
        if(item.PackFlg) { sale.AddChild(); }
 
        //親UseRoom
        sale.Parent = this;
 
        //部屋の売上一覧に追加する
        SaleList.Add(sale);
        return sale;
    }
 
    #endregion
}