1
0
forked from erp-dev/erp

feat: app verion && some field modify (printing & shipment)

This commit is contained in:
2026-07-08 20:36:51 +08:00
parent ddbf798665
commit 36e4bb6de6
32 changed files with 3465 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
"""
PrintingOrder API 测试
"""
from datetime import datetime
from datetime import datetime, timezone as dt_timezone
from django.test import TestCase
from django.db import connection
from django.conf import settings
@@ -260,6 +260,12 @@ class PrintingOrderAPITestCase(TestCase):
external_customer_id='KH00991',
external_customer_name='李泽柔',
external_employee_name='丽容',
external_raw={
'first_record': {
'BianHaoKD': '7.07',
'KdRiQi': '2026-07-06T21:48:58Z',
}
},
)
printing_models.PrintingOrder.objects.create(
merchant=self.merchant,
@@ -277,11 +283,65 @@ class PrintingOrderAPITestCase(TestCase):
self.assertEqual(item['external_customer_id'], 'KH00991')
self.assertEqual(item['external_customer_name'], '李泽柔')
self.assertEqual(item['external_employee_name'], '丽容')
self.assertEqual(item['bianhao_kd'], '7.07')
self.assertEqual(item['kd_riqi'], '2026-07-06T21:48:58Z')
detail = self.client.get(f'/api/v1/printing-orders/{order1.id}/')
self.assertEqual(detail.status_code, status.HTTP_200_OK)
self.assertEqual(detail.data['external_order_id'], 'KD20410611')
self.assertEqual(detail.data['external_customer_id'], 'KH00991')
self.assertEqual(detail.data['bianhao_kd'], '7.07')
self.assertEqual(detail.data['kd_riqi'], '2026-07-06T21:48:58Z')
def test_bianhao_kd_returns_null_without_external_order_id(self):
order = printing_models.PrintingOrder.objects.create(
merchant=self.merchant,
customer=self.customer,
fabric='普通订单',
width='150cm',
external_raw={'first_record': {'BianHaoKD': '7.07'}},
)
response = self.client.get(f'/api/v1/printing-orders/{order.id}/')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIsNone(response.data['bianhao_kd'])
self.assertIsNone(response.data['kd_riqi'])
def test_filter_and_order_by_kd_riqi(self):
older = printing_models.PrintingOrder.objects.create(
merchant=self.merchant,
customer=self.customer,
fabric='旧开单时间',
width='150cm',
external_order_id='KD-OLDER',
kd_riqi=datetime(2026, 7, 1, 10, 0, tzinfo=dt_timezone.utc),
)
newer = printing_models.PrintingOrder.objects.create(
merchant=self.merchant,
customer=self.customer,
fabric='新开单时间',
width='150cm',
external_order_id='KD-NEWER',
kd_riqi=datetime(2026, 7, 2, 10, 0, tzinfo=dt_timezone.utc),
)
printing_models.PrintingOrder.objects.create(
merchant=self.merchant,
customer=self.customer,
fabric='范围外开单时间',
width='150cm',
external_order_id='KD-OUTSIDE',
kd_riqi=datetime(2026, 7, 3, 10, 0, tzinfo=dt_timezone.utc),
)
response = self.client.get(
'/api/v1/printing-orders/?kd_riqi_from=2026-07-01&kd_riqi_to=2026-07-02&ordering=kd_riqi'
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
result_ids = [item['id'] for item in response.data['results']]
self.assertEqual(result_ids, [older.id, newer.id])
self.assertEqual(response.data['results'][0]['kd_riqi'], '2026-07-01T18:00:00+08:00')
def test_retrieve_printing_order(self):
"""测试获取订单详情"""