more club funtions, fix for team edit
This commit is contained in:
@@ -48,6 +48,30 @@ const Club = sequelize.define('Club', {
|
||||
allowNull: true,
|
||||
field: 'member_data_quality_requirements',
|
||||
comment: 'Configures which member fields are required for data quality checks'
|
||||
},
|
||||
outgoingInvoicePrefix: {
|
||||
type: DataTypes.STRING(24),
|
||||
allowNull: false,
|
||||
defaultValue: 'RE',
|
||||
field: 'outgoing_invoice_prefix'
|
||||
},
|
||||
outgoingInvoiceNextNumber: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 1,
|
||||
field: 'outgoing_invoice_next_number'
|
||||
},
|
||||
incomingInvoicePrefix: {
|
||||
type: DataTypes.STRING(24),
|
||||
allowNull: false,
|
||||
defaultValue: 'EI',
|
||||
field: 'incoming_invoice_prefix'
|
||||
},
|
||||
incomingInvoiceNextNumber: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 1,
|
||||
field: 'incoming_invoice_next_number'
|
||||
}
|
||||
}, {
|
||||
tableName: 'clubs',
|
||||
|
||||
109
backend/models/ClubInvoice.js
Normal file
109
backend/models/ClubInvoice.js
Normal file
@@ -0,0 +1,109 @@
|
||||
import { DataTypes } from 'sequelize';
|
||||
import sequelize from '../database.js';
|
||||
|
||||
const ClubInvoice = sequelize.define('ClubInvoice', {
|
||||
clubId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'club_id',
|
||||
},
|
||||
invoiceDirection: {
|
||||
type: DataTypes.STRING(16),
|
||||
allowNull: false,
|
||||
field: 'invoice_direction',
|
||||
},
|
||||
invoiceType: {
|
||||
type: DataTypes.STRING(32),
|
||||
allowNull: false,
|
||||
field: 'invoice_type',
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.STRING(32),
|
||||
allowNull: false,
|
||||
defaultValue: 'draft',
|
||||
},
|
||||
invoiceNumber: {
|
||||
type: DataTypes.STRING(64),
|
||||
allowNull: true,
|
||||
field: 'invoice_number',
|
||||
},
|
||||
externalReference: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
field: 'external_reference',
|
||||
},
|
||||
partyId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
field: 'party_id',
|
||||
},
|
||||
accountId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
field: 'account_id',
|
||||
},
|
||||
issuedOn: {
|
||||
type: DataTypes.DATEONLY,
|
||||
allowNull: true,
|
||||
field: 'issued_on',
|
||||
},
|
||||
dueOn: {
|
||||
type: DataTypes.DATEONLY,
|
||||
allowNull: true,
|
||||
field: 'due_on',
|
||||
},
|
||||
paidOn: {
|
||||
type: DataTypes.DATEONLY,
|
||||
allowNull: true,
|
||||
field: 'paid_on',
|
||||
},
|
||||
netAmountCents: {
|
||||
type: DataTypes.BIGINT,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
field: 'net_amount_cents',
|
||||
},
|
||||
taxAmountCents: {
|
||||
type: DataTypes.BIGINT,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
field: 'tax_amount_cents',
|
||||
},
|
||||
grossAmountCents: {
|
||||
type: DataTypes.BIGINT,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
field: 'gross_amount_cents',
|
||||
},
|
||||
currencyCode: {
|
||||
type: DataTypes.STRING(3),
|
||||
allowNull: false,
|
||||
defaultValue: 'EUR',
|
||||
field: 'currency_code',
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
documentId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
field: 'document_id',
|
||||
},
|
||||
createdByUserId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
field: 'created_by_user_id',
|
||||
},
|
||||
archivedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
field: 'archived_at',
|
||||
},
|
||||
}, {
|
||||
tableName: 'club_invoices',
|
||||
underscored: true,
|
||||
timestamps: true,
|
||||
});
|
||||
|
||||
export default ClubInvoice;
|
||||
49
backend/models/ClubInvoiceItem.js
Normal file
49
backend/models/ClubInvoiceItem.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { DataTypes } from 'sequelize';
|
||||
import sequelize from '../database.js';
|
||||
|
||||
const ClubInvoiceItem = sequelize.define('ClubInvoiceItem', {
|
||||
invoiceId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'invoice_id',
|
||||
},
|
||||
lineNo: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 1,
|
||||
field: 'line_no',
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false,
|
||||
},
|
||||
quantity: {
|
||||
type: DataTypes.DECIMAL(12, 2),
|
||||
allowNull: false,
|
||||
defaultValue: 1,
|
||||
},
|
||||
unitPriceCents: {
|
||||
type: DataTypes.BIGINT,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
field: 'unit_price_cents',
|
||||
},
|
||||
taxRate: {
|
||||
type: DataTypes.DECIMAL(5, 2),
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
field: 'tax_rate',
|
||||
},
|
||||
totalCents: {
|
||||
type: DataTypes.BIGINT,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
field: 'total_cents',
|
||||
},
|
||||
}, {
|
||||
tableName: 'club_invoice_items',
|
||||
underscored: true,
|
||||
timestamps: true,
|
||||
});
|
||||
|
||||
export default ClubInvoiceItem;
|
||||
75
backend/models/ClubInvoiceParty.js
Normal file
75
backend/models/ClubInvoiceParty.js
Normal file
@@ -0,0 +1,75 @@
|
||||
import { DataTypes } from 'sequelize';
|
||||
import sequelize from '../database.js';
|
||||
|
||||
const ClubInvoiceParty = sequelize.define('ClubInvoiceParty', {
|
||||
clubId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'club_id',
|
||||
},
|
||||
partyType: {
|
||||
type: DataTypes.STRING(32),
|
||||
allowNull: false,
|
||||
defaultValue: 'customer',
|
||||
field: 'party_type',
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: false,
|
||||
},
|
||||
contactName: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
field: 'contact_name',
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
},
|
||||
phone: {
|
||||
type: DataTypes.STRING(80),
|
||||
allowNull: true,
|
||||
},
|
||||
street: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
},
|
||||
postalCode: {
|
||||
type: DataTypes.STRING(24),
|
||||
allowNull: true,
|
||||
field: 'postal_code',
|
||||
},
|
||||
city: {
|
||||
type: DataTypes.STRING(120),
|
||||
allowNull: true,
|
||||
},
|
||||
countryCode: {
|
||||
type: DataTypes.STRING(2),
|
||||
allowNull: true,
|
||||
defaultValue: 'DE',
|
||||
field: 'country_code',
|
||||
},
|
||||
iban: {
|
||||
type: DataTypes.STRING(34),
|
||||
allowNull: true,
|
||||
},
|
||||
bic: {
|
||||
type: DataTypes.STRING(11),
|
||||
allowNull: true,
|
||||
},
|
||||
taxIdentifier: {
|
||||
type: DataTypes.STRING(64),
|
||||
allowNull: true,
|
||||
field: 'tax_identifier',
|
||||
},
|
||||
notes: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
}, {
|
||||
tableName: 'club_invoice_parties',
|
||||
underscored: true,
|
||||
timestamps: true,
|
||||
});
|
||||
|
||||
export default ClubInvoiceParty;
|
||||
@@ -75,6 +75,9 @@ import ClubRequestNote from './ClubRequestNote.js';
|
||||
import ClubSepaMandate from './ClubSepaMandate.js';
|
||||
import ClubPaymentClaim from './ClubPaymentClaim.js';
|
||||
import ClubAccount from './ClubAccount.js';
|
||||
import ClubInvoiceParty from './ClubInvoiceParty.js';
|
||||
import ClubInvoice from './ClubInvoice.js';
|
||||
import ClubInvoiceItem from './ClubInvoiceItem.js';
|
||||
import ClubTask from './ClubTask.js';
|
||||
import ClubTaskSuppression from './ClubTaskSuppression.js';
|
||||
import ClubRole from './ClubRole.js';
|
||||
@@ -484,6 +487,21 @@ ClubPaymentClaim.belongsTo(Member, { foreignKey: 'memberId', as: 'member', const
|
||||
Club.hasMany(ClubAccount, { foreignKey: 'clubId', as: 'accounts' });
|
||||
ClubAccount.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
|
||||
|
||||
Club.hasMany(ClubInvoiceParty, { foreignKey: 'clubId', as: 'invoiceParties' });
|
||||
ClubInvoiceParty.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
|
||||
|
||||
Club.hasMany(ClubInvoice, { foreignKey: 'clubId', as: 'invoices' });
|
||||
ClubInvoice.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
|
||||
ClubInvoice.belongsTo(ClubInvoiceParty, { foreignKey: 'partyId', as: 'party', constraints: false });
|
||||
ClubInvoiceParty.hasMany(ClubInvoice, { foreignKey: 'partyId', as: 'invoices' });
|
||||
ClubInvoice.belongsTo(ClubAccount, { foreignKey: 'accountId', as: 'account', constraints: false });
|
||||
ClubAccount.hasMany(ClubInvoice, { foreignKey: 'accountId', as: 'invoices' });
|
||||
User.hasMany(ClubInvoice, { foreignKey: 'createdByUserId', as: 'createdInvoices' });
|
||||
ClubInvoice.belongsTo(User, { foreignKey: 'createdByUserId', as: 'createdByUser', constraints: false });
|
||||
|
||||
ClubInvoice.hasMany(ClubInvoiceItem, { foreignKey: 'invoiceId', as: 'items' });
|
||||
ClubInvoiceItem.belongsTo(ClubInvoice, { foreignKey: 'invoiceId', as: 'invoice' });
|
||||
|
||||
Club.hasMany(ClubTask, { foreignKey: 'clubId', as: 'clubTasks' });
|
||||
ClubTask.belongsTo(Club, { foreignKey: 'clubId', as: 'club' });
|
||||
User.hasMany(ClubTask, { foreignKey: 'createdByUserId', as: 'createdClubTasks' });
|
||||
@@ -579,6 +597,9 @@ export {
|
||||
ClubSepaMandate,
|
||||
ClubPaymentClaim,
|
||||
ClubAccount,
|
||||
ClubInvoiceParty,
|
||||
ClubInvoice,
|
||||
ClubInvoiceItem,
|
||||
ClubTask,
|
||||
ClubTaskSuppression,
|
||||
ClubRole,
|
||||
|
||||
Reference in New Issue
Block a user