All checks were successful
Deploy production / deploy (push) Successful in 10m8s
132 lines
5.0 KiB
Python
132 lines
5.0 KiB
Python
import uuid
|
|
from decimal import Decimal
|
|
|
|
import django.core.validators
|
|
import django.db.models.deletion
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("finance", "0039_payrolloffcyclepayment"),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="PayrollBalanceAdjustment",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(
|
|
auto_created=True,
|
|
primary_key=True,
|
|
serialize=False,
|
|
verbose_name="ID",
|
|
),
|
|
),
|
|
(
|
|
"direction",
|
|
models.CharField(
|
|
choices=[
|
|
("company_owes", "Доплата сотруднику"),
|
|
("employee_owes", "Долг сотрудника"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"amount",
|
|
models.DecimalField(
|
|
decimal_places=2,
|
|
max_digits=19,
|
|
validators=[
|
|
django.core.validators.MinValueValidator(Decimal("0.01"))
|
|
],
|
|
),
|
|
),
|
|
("reason", models.CharField(blank=True, max_length=1000)),
|
|
(
|
|
"request_id",
|
|
models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
|
|
),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("voided_at", models.DateTimeField(blank=True, null=True)),
|
|
("void_reason", models.CharField(blank=True, max_length=1000)),
|
|
(
|
|
"employee",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
related_name="payroll_balance_adjustments",
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
(
|
|
"created_by",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
related_name="payroll_balance_adjustments_created",
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
(
|
|
"voided_by",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
related_name="payroll_balance_adjustments_voided",
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
(
|
|
"effective_period",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
related_name="balance_adjustments",
|
|
to="finance.payrollperiod",
|
|
),
|
|
),
|
|
(
|
|
"source_period",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.PROTECT,
|
|
related_name="referenced_balance_adjustments",
|
|
to="finance.payrollperiod",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"ordering": ["-effective_period__date_from", "-created_at", "-pk"],
|
|
"verbose_name": "Ручная корректировка остатка",
|
|
"verbose_name_plural": "Ручные корректировки остатков",
|
|
"constraints": [
|
|
models.CheckConstraint(
|
|
condition=models.Q(amount__gt=0),
|
|
name="balance_adjustment_positive",
|
|
),
|
|
models.CheckConstraint(
|
|
condition=models.Q(
|
|
direction__in=["company_owes", "employee_owes"]
|
|
),
|
|
name="balance_adjustment_direction",
|
|
),
|
|
models.CheckConstraint(
|
|
condition=(
|
|
models.Q(
|
|
voided_at__isnull=True,
|
|
voided_by__isnull=True,
|
|
void_reason="",
|
|
)
|
|
| models.Q(voided_at__isnull=False, voided_by__isnull=False)
|
|
),
|
|
name="balance_adjustment_void_consistent",
|
|
),
|
|
],
|
|
},
|
|
),
|
|
]
|