add whatsapp contact button and prepayment/full payment badge
This commit is contained in:
@@ -37,6 +37,7 @@ type DeliveryRequest struct {
|
||||
Phone string `json:"phone" binding:"required"`
|
||||
AdditionalPhone *string `json:"additional_phone"`
|
||||
HasElevator bool `json:"has_elevator"`
|
||||
PaymentStatus string `json:"payment_status" binding:"omitempty,oneof=prepaid paid"`
|
||||
ServiceInfo *string `json:"service_info"`
|
||||
Comment string `json:"comment"`
|
||||
}
|
||||
@@ -107,6 +108,7 @@ func (h *Handler) CreateDelivery(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
normalizePaymentStatus(&req)
|
||||
|
||||
// Parse date from DD-MM-YYYY
|
||||
t, err := parseDate(req.Date)
|
||||
@@ -133,6 +135,7 @@ func (h *Handler) CreateDelivery(c *gin.Context) {
|
||||
Phone: req.Phone,
|
||||
AdditionalPhone: pgtype.Text{String: derefString(req.AdditionalPhone), Valid: req.AdditionalPhone != nil},
|
||||
HasElevator: req.HasElevator,
|
||||
PaymentStatus: req.PaymentStatus,
|
||||
ServiceInfo: pgtype.Text{String: derefString(req.ServiceInfo), Valid: req.ServiceInfo != nil},
|
||||
Comment: pgtype.Text{String: req.Comment, Valid: true},
|
||||
}
|
||||
@@ -158,6 +161,7 @@ func (h *Handler) UpdateDelivery(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
normalizePaymentStatus(&req)
|
||||
|
||||
id := c.Param("id")
|
||||
|
||||
@@ -196,6 +200,7 @@ func (h *Handler) UpdateDelivery(c *gin.Context) {
|
||||
Phone: req.Phone,
|
||||
AdditionalPhone: pgtype.Text{String: derefString(req.AdditionalPhone), Valid: req.AdditionalPhone != nil},
|
||||
HasElevator: req.HasElevator,
|
||||
PaymentStatus: req.PaymentStatus,
|
||||
ServiceInfo: pgtype.Text{String: derefString(req.ServiceInfo), Valid: req.ServiceInfo != nil},
|
||||
Comment: pgtype.Text{String: req.Comment, Valid: true},
|
||||
}); err != nil {
|
||||
@@ -308,3 +313,9 @@ func normalizeWarehouseRequestSources(req *DeliveryRequest) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func normalizePaymentStatus(req *DeliveryRequest) {
|
||||
if req.PaymentStatus == "" {
|
||||
req.PaymentStatus = "prepaid"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user