Browse Source

添加对账

animeic 1 year ago
parent
commit
179f840f2f
2 changed files with 39 additions and 0 deletions
  1. 34 0
      boxcost/api/bill.go
  2. 5 0
      boxcost/db/model/bill.go

+ 34 - 0
boxcost/api/bill.go

@@ -37,6 +37,40 @@ func Bill(r *GinRouter) {
 
 	// 审核单据
 	r.POSTJWT("/bill/purchase/review/:id", PurchaseReview)
+
+	// 对账单据
+	r.POSTJWT("/bill/record", BillRecord)
+}
+
+type BillRecordReq struct {
+	BillType string             `json:"billType"`
+	Id       primitive.ObjectID `json:"id"`
+}
+
+// 对账单据
+func BillRecord(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	var req BillRecordReq
+	err := c.ShouldBindJSON(&req)
+	if err != nil {
+		return nil, errors.New("参数错误!")
+	}
+	if req.Id.IsZero() {
+		return nil, errors.New("id错误!")
+	}
+	collection := ""
+	if req.BillType == "purchase" {
+		collection = repo.CollectionBillPurchase
+	} else if req.BillType == "produce" {
+		collection = repo.CollectionBillProduce
+	} else if req.BillType == "product" {
+		collection = repo.CollectionBillProduct
+	} else {
+		return nil, errors.New("订单类型错误!")
+	}
+	record := true
+	update := bson.M{"isRecord": &record}
+	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), collection, req.Id.Hex(), &update)
+
 }
 
 // 审核单据

+ 5 - 0
boxcost/db/model/bill.go

@@ -90,6 +90,7 @@ type PurchaseBill struct {
 	CompProduceName string `bson:"compProduceName,omitempty" json:"compProduceName"`
 	// 供应商备注
 	SupplierRemark string `bson:"supplierRemark,omitempty" json:"supplierRemark"`
+	IsRecord       *bool  `bson:"isRecord,omitempty" json:"isRecord"`
 }
 
 // 工艺生产数据
@@ -192,6 +193,8 @@ type ProduceBill struct {
 	CompProduceName string `bson:"compProduceName,omitempty" json:"compProduceName"`
 	// 供应商备注
 	SupplierRemark string `bson:"supplierRemark,omitempty" json:"supplierRemark"`
+
+	IsRecord *bool `bson:"isRecord,omitempty" json:"isRecord"`
 }
 
 // 成品采购单据
@@ -245,6 +248,8 @@ type ProductBill struct {
 	CompProduceName string `bson:"compProduceName,omitempty" json:"compProduceName"`
 	// 供应商备注
 	SupplierRemark string `bson:"supplierRemark,omitempty" json:"supplierRemark"`
+
+	IsRecord *bool `bson:"isRecord,omitempty" json:"isRecord"`
 }
 
 // 工艺生产数据