|
@@ -292,6 +292,7 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
pp.Set()
|
|
|
if pp.InvoiceType == fms.ContractInvoiceTypePreMake {
|
|
|
//开票走开票字段
|
|
|
+ pp.InvoiceId = v.ContractInvoiceId
|
|
|
pp.InvoiceDate = registerDate
|
|
|
pp.OriginAmount = r.Amount
|
|
|
pp.CurrencyUnit = r.CurrencyUnit
|
|
@@ -312,6 +313,7 @@ func (rg *PreRegisterController) Add(c *gin.Context) {
|
|
|
pp.SellerTeamName = sellerItem.TeamName
|
|
|
} else {
|
|
|
//到款
|
|
|
+ pp.ArriveId = v.ContractInvoiceId
|
|
|
pp.ArriveDate = registerDate
|
|
|
pp.ArriveOriginAmount = r.Amount
|
|
|
pp.ArriveCurrencyUnit = r.CurrencyUnit
|
|
@@ -433,6 +435,7 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
invoiceList := make([]*fms.ContractInvoice, 0)
|
|
|
+ ppList := make([]*fms.ContractPreRegister, 0)
|
|
|
for _, r := range req.List {
|
|
|
// 货币及汇率
|
|
|
rateList, e := fmsService.GetTodayCurrencyRateList()
|
|
@@ -494,6 +497,53 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
}
|
|
|
|
|
|
invoiceList = append(invoiceList, v)
|
|
|
+
|
|
|
+ //预登记列表
|
|
|
+ pp := &fms.ContractPreRegister{
|
|
|
+ ContractRegisterId: ob.ContractRegisterId,
|
|
|
+ CompanyName: req.CompanyName,
|
|
|
+ InvoiceType: req.RegisterType,
|
|
|
+ InvoiceDate: registerDate,
|
|
|
+ AdminId: int(adminInfo.AdminId),
|
|
|
+ AdminName: adminInfo.AdminName,
|
|
|
+ Remark: r.Remark,
|
|
|
+ ServiceProductId: r.ServiceProductId,
|
|
|
+ IsPrePay: 1,
|
|
|
+ StartDate: startDate,
|
|
|
+ EndDate: endDate,
|
|
|
+ TimeBase: base.TimeBase{},
|
|
|
+ }
|
|
|
+ pp.Set()
|
|
|
+ if pp.InvoiceType == fms.ContractInvoiceTypePreMake {
|
|
|
+ //开票走开票字段
|
|
|
+ pp.InvoiceDate = registerDate
|
|
|
+ pp.OriginAmount = r.Amount
|
|
|
+ pp.CurrencyUnit = r.CurrencyUnit
|
|
|
+ a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.OriginAmount/rate), 64)
|
|
|
+ pp.Amount = a
|
|
|
+
|
|
|
+ sellerItem := sellerMap[r.SellerId]
|
|
|
+ if sellerItem == nil {
|
|
|
+ resp.Fail("销售信息异常", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ pp.SellerId = sellerItem.SellerId
|
|
|
+ pp.SellerName = sellerItem.SellerName
|
|
|
+ pp.SellerGroupId = sellerItem.GroupId
|
|
|
+ pp.SellerGroupName = sellerItem.GroupName
|
|
|
+ pp.SellerTeamId = sellerItem.TeamId
|
|
|
+ pp.SellerTeamName = sellerItem.TeamName
|
|
|
+ } else {
|
|
|
+ //到款
|
|
|
+ pp.ArriveDate = registerDate
|
|
|
+ pp.ArriveOriginAmount = r.Amount
|
|
|
+ pp.ArriveCurrencyUnit = r.CurrencyUnit
|
|
|
+ a, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", pp.ArriveOriginAmount/rate), 64)
|
|
|
+ pp.ArriveAmount = a
|
|
|
+ }
|
|
|
+ ppList = append(ppList, pp)
|
|
|
+
|
|
|
}
|
|
|
invoiceUpdateCols := []string{
|
|
|
"CurrencyUnit", "Amount", "InvoiceDate", "AdminId", "AdminName", "Remark",
|
|
@@ -517,7 +567,7 @@ func (rg *PreRegisterController) Edit(c *gin.Context) {
|
|
|
// @Description 删除到款预登记
|
|
|
// @Param request body fms.ContractRegisterDelReq true "type json string"
|
|
|
// @Success 200 string "操作成功"
|
|
|
-// @router /contract/pre_pay/del [post]
|
|
|
+// @router /contract/pre_register/del [post]
|
|
|
func (rg *PreRegisterController) Del(c *gin.Context) {
|
|
|
req := new(fms.PreRegisterDelReq)
|
|
|
err := c.ShouldBind(&req)
|
|
@@ -570,3 +620,50 @@ func (rg *PreRegisterController) Del(c *gin.Context) {
|
|
|
|
|
|
resp.Ok("操作成功", c)
|
|
|
}
|
|
|
+
|
|
|
+// Detail
|
|
|
+// @Title 预登记记录详情
|
|
|
+// @Description 预登记记录详情
|
|
|
+// @Param request body fms.PreRegisterDetailReq true "type json string"
|
|
|
+// @Success 200 string "操作成功"
|
|
|
+// @router /contract/pre_register/detail [post]
|
|
|
+func (rg *PreRegisterController) Detail(c *gin.Context) {
|
|
|
+ req := new(fms.PreRegisterDetailReq)
|
|
|
+ err := c.ShouldBind(&req)
|
|
|
+ if err != nil {
|
|
|
+ errs, ok := err.(validator.ValidationErrors)
|
|
|
+ if !ok {
|
|
|
+ resp.FailData("参数解析失败", "Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ob := new(fms.ContractRegister)
|
|
|
+ item, e := ob.Fetch(req.ContractRegisterId)
|
|
|
+ if e != nil {
|
|
|
+ if e == utils.ErrNoRow {
|
|
|
+ resp.Fail("合同登记不存在或已被删除", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailMsg("获取合同登记失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ cond := `contract_register_id = ? AND invoice_type = ? `
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ pars = append(pars, req.ContractRegisterId, req.InvoiceType)
|
|
|
+ list, e := fms.GetContractInvoiceItemList(cond, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = fmt.Errorf("获取开票到款列表失败, Err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ respItem := fms.ContractPreRegisterDetail{
|
|
|
+ ContractRegister: item,
|
|
|
+ List: list,
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.OkData("获取成功", respItem, c)
|
|
|
+}
|