Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
SOD/models/payment.js

53 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-09-10 19:18:42 +02:00
"use strict";
let maxLength = 80;
function idGen() {
let id = "";
while (id.length < maxLength) {
let tmp = id + Math.random().toString(36).substring(2, 15);
if (tmp.length <= maxLength)
id = tmp;
else
break;
}
return id;
}
const {
Model
} = require("sequelize");
module.exports = (sequelize, DataTypes) => {
class Payment extends Model {
static associate(models) {
2020-09-11 10:58:12 +02:00
Payment.belongsTo(models.Order);
2020-09-10 19:18:42 +02:00
}
}
Payment.init({
shopReference: {
type: DataTypes.STRING(maxLength),
primaryKey: true,
defaultValue: idGen
},
date: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
2020-09-11 10:58:12 +02:00
},
status: {
type: DataTypes.BOOLEAN
},
amount: {
type: DataTypes.INTEGER
},
discount: {
type: DataTypes.INTEGER
},
transactionUuid: {
type: DataTypes.UUID,
2020-09-10 19:18:42 +02:00
}
}, {
sequelize,
modelName: "Payment",
});
return Payment;
};