feat: Integrates ObjectBox for stock picking persistence
Enables offline capabilities and improved data access for stock picking records. API calls now prioritize local ObjectBox storage when offline and persist fetched data upon successful remote retrieval. Introduces comprehensive model-to-entity conversion logic for stock picking data and its related models. Updates UI components and state management to directly consume ObjectBox entities, optimizing data display and interaction. Adjusts ObjectBox entity schema for improved flexibility and adds utility getters.
This commit is contained in:
parent
1d15fd4d1c
commit
9dad7f9d9f
@ -1,3 +1,5 @@
|
||||
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
|
||||
import 'package:e_scan/backend/objectbox/objectbox_manager.dart';
|
||||
import 'package:e_scan/backend/schema/auth/auth_model.dart';
|
||||
import 'package:e_scan/backend/schema/stock_picking/stock_picking_model.dart';
|
||||
import 'package:e_scan/backend/schema/stock_picking/stock_picking_record_model.dart';
|
||||
@ -78,11 +80,14 @@ class ApiCalls {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Result<List<StockPickingRecordModel>, Error>>
|
||||
static Future<Result<List<StockPickingRecordEntity>, Error>>
|
||||
getAllStockPiking() async {
|
||||
try {
|
||||
final stockPickingRecords = objectboxManager.store
|
||||
.box<StockPickingRecordEntity>();
|
||||
if (!(await checkInternetConnexion())) {
|
||||
// return local data
|
||||
return Result.success(stockPickingRecords.getAll());
|
||||
}
|
||||
final response = await dioService.post(
|
||||
path: '/web/dataset/call_kw/stock.picking/web_search_read',
|
||||
@ -158,8 +163,13 @@ class ApiCalls {
|
||||
final data = response.data;
|
||||
if (data.containsKey('result')) {
|
||||
final result = StockPickingResponseModel.fromJson(data);
|
||||
final records = result.result?.records ?? <StockPickingRecordModel>[];
|
||||
return Result.success(records);
|
||||
final recordsModel =
|
||||
result.result?.records ?? <StockPickingRecordModel>[];
|
||||
// add data to local
|
||||
for (var rec in recordsModel) {
|
||||
rec.toEntity();
|
||||
}
|
||||
return Result.success(stockPickingRecords.getAll());
|
||||
} else {
|
||||
return Result.error(Error(data['error']));
|
||||
}
|
||||
@ -173,12 +183,17 @@ class ApiCalls {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Result<StockPickingRecordModel, Error>> getStockPikingById({
|
||||
static Future<Result<StockPickingRecordEntity, Error>> getStockPikingById({
|
||||
required int id,
|
||||
}) async {
|
||||
try {
|
||||
final stockPickingRecords = objectboxManager.store
|
||||
.box<StockPickingRecordEntity>();
|
||||
if (!(await checkInternetConnexion())) {
|
||||
// return local data
|
||||
final entity = stockPickingRecords.get(id);
|
||||
if (entity == null) return Result.error(Error('Not found'));
|
||||
return Result.success(entity);
|
||||
}
|
||||
final response = await dioService.post(
|
||||
path: '/web/dataset/call_kw/stock.picking/web_read',
|
||||
@ -295,9 +310,9 @@ class ApiCalls {
|
||||
if (data.containsKey('result')) {
|
||||
final datas = data['result'] as List;
|
||||
if (datas.isNotEmpty) {
|
||||
return Result.success(
|
||||
StockPickingRecordModel.fromJson(datas.first),
|
||||
);
|
||||
final recordModel = StockPickingRecordModel.fromJson(datas.first);
|
||||
final entity = recordModel.toEntity();
|
||||
return Result.success(entity);
|
||||
} else {
|
||||
return Result.error(Error('Data not found'));
|
||||
}
|
||||
|
@ -36,21 +36,21 @@ class StockPickingRecordEntity {
|
||||
final String? origin;
|
||||
final bool? useCreateLots;
|
||||
final bool? isLocked;
|
||||
final String? scheduledDate;
|
||||
final String? dateDeadline;
|
||||
final String? dateDone;
|
||||
final dynamic scheduledDate;
|
||||
final dynamic dateDeadline;
|
||||
final dynamic dateDone;
|
||||
|
||||
final String? productsAvailability;
|
||||
final String? productsAvailabilityState;
|
||||
final dynamic productsAvailability;
|
||||
final dynamic productsAvailabilityState;
|
||||
|
||||
final bool? jsonPopover;
|
||||
final bool? activityExceptionIcon;
|
||||
final bool? activityExceptionDecoration;
|
||||
final bool? showCheckAvailability;
|
||||
final bool? hasScrapMove;
|
||||
final bool? hasPackages;
|
||||
final bool? showNextPickings;
|
||||
final bool? pickingTypeEntirePacks;
|
||||
final dynamic jsonPopover;
|
||||
final dynamic activityExceptionIcon;
|
||||
final dynamic activityExceptionDecoration;
|
||||
final dynamic showCheckAvailability;
|
||||
final dynamic hasScrapMove;
|
||||
final dynamic hasPackages;
|
||||
final dynamic showNextPickings;
|
||||
final dynamic pickingTypeEntirePacks;
|
||||
|
||||
final ToOne<StockPickingCompanyEntity> companyId = ToOne();
|
||||
final ToOne<StockPickingPartnerEntity> partnerId = ToOne();
|
||||
@ -121,3 +121,11 @@ class MoveWithoutPackageEntity {
|
||||
final ToOne<ProductEntity> productId = ToOne();
|
||||
final ToOne<StockPickingRecordEntity> pickingRecord = ToOne();
|
||||
}
|
||||
|
||||
extension StockPickingRecordEntityExt on StockPickingRecordEntity {
|
||||
bool get isDone => state == "done";
|
||||
}
|
||||
|
||||
extension MoveWithoutPackageEntityExt on MoveWithoutPackageEntity {
|
||||
double get ecart => ((quantity ?? 0) - (productUomQty ?? 0));
|
||||
}
|
||||
|
@ -200,71 +200,6 @@
|
||||
"name": "isLocked",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "9:6827379535582901480",
|
||||
"name": "scheduledDate",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "10:370251402703013746",
|
||||
"name": "dateDeadline",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "11:388273829313485427",
|
||||
"name": "dateDone",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "12:8017891142234531346",
|
||||
"name": "productsAvailability",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "13:2254687830363854428",
|
||||
"name": "productsAvailabilityState",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "14:6345179288704462624",
|
||||
"name": "jsonPopover",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "15:5524107603050624969",
|
||||
"name": "activityExceptionIcon",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "16:6595911006479461694",
|
||||
"name": "activityExceptionDecoration",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "17:6060229724899750987",
|
||||
"name": "showCheckAvailability",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "18:2889425908429352139",
|
||||
"name": "hasScrapMove",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "19:934877054574553245",
|
||||
"name": "hasPackages",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "20:7012525525648469072",
|
||||
"name": "showNextPickings",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "21:4739641817802949530",
|
||||
"name": "pickingTypeEntirePacks",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "22:3555343810963543340",
|
||||
"name": "companyIdId",
|
||||
@ -342,7 +277,20 @@
|
||||
6084891210993334692,
|
||||
883454706727408240,
|
||||
7033704955625644592,
|
||||
1825580906382154543
|
||||
1825580906382154543,
|
||||
6827379535582901480,
|
||||
370251402703013746,
|
||||
388273829313485427,
|
||||
8017891142234531346,
|
||||
2254687830363854428,
|
||||
6345179288704462624,
|
||||
5524107603050624969,
|
||||
6595911006479461694,
|
||||
6060229724899750987,
|
||||
2889425908429352139,
|
||||
934877054574553245,
|
||||
7012525525648469072,
|
||||
4739641817802949530
|
||||
],
|
||||
"retiredRelationUids": [],
|
||||
"version": 1
|
||||
|
@ -244,84 +244,6 @@ final _entities = <obx_int.ModelEntity>[
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(9, 6827379535582901480),
|
||||
name: 'scheduledDate',
|
||||
type: 9,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(10, 370251402703013746),
|
||||
name: 'dateDeadline',
|
||||
type: 9,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(11, 388273829313485427),
|
||||
name: 'dateDone',
|
||||
type: 9,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(12, 8017891142234531346),
|
||||
name: 'productsAvailability',
|
||||
type: 9,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(13, 2254687830363854428),
|
||||
name: 'productsAvailabilityState',
|
||||
type: 9,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(14, 6345179288704462624),
|
||||
name: 'jsonPopover',
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(15, 5524107603050624969),
|
||||
name: 'activityExceptionIcon',
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(16, 6595911006479461694),
|
||||
name: 'activityExceptionDecoration',
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(17, 6060229724899750987),
|
||||
name: 'showCheckAvailability',
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(18, 2889425908429352139),
|
||||
name: 'hasScrapMove',
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(19, 934877054574553245),
|
||||
name: 'hasPackages',
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(20, 7012525525648469072),
|
||||
name: 'showNextPickings',
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(21, 4739641817802949530),
|
||||
name: 'pickingTypeEntirePacks',
|
||||
type: 1,
|
||||
flags: 0,
|
||||
),
|
||||
obx_int.ModelProperty(
|
||||
id: const obx_int.IdUid(22, 3555343810963543340),
|
||||
name: 'companyIdId',
|
||||
@ -452,6 +374,19 @@ obx_int.ModelDefinition getObjectBoxModel() {
|
||||
883454706727408240,
|
||||
7033704955625644592,
|
||||
1825580906382154543,
|
||||
6827379535582901480,
|
||||
370251402703013746,
|
||||
388273829313485427,
|
||||
8017891142234531346,
|
||||
2254687830363854428,
|
||||
6345179288704462624,
|
||||
5524107603050624969,
|
||||
6595911006479461694,
|
||||
6060229724899750987,
|
||||
2889425908429352139,
|
||||
934877054574553245,
|
||||
7012525525648469072,
|
||||
4739641817802949530,
|
||||
],
|
||||
retiredRelationUids: const [],
|
||||
modelVersion: 5,
|
||||
@ -772,23 +707,6 @@ obx_int.ModelDefinition getObjectBoxModel() {
|
||||
final originOffset = object.origin == null
|
||||
? null
|
||||
: fbb.writeString(object.origin!);
|
||||
final scheduledDateOffset = object.scheduledDate == null
|
||||
? null
|
||||
: fbb.writeString(object.scheduledDate!);
|
||||
final dateDeadlineOffset = object.dateDeadline == null
|
||||
? null
|
||||
: fbb.writeString(object.dateDeadline!);
|
||||
final dateDoneOffset = object.dateDone == null
|
||||
? null
|
||||
: fbb.writeString(object.dateDone!);
|
||||
final productsAvailabilityOffset =
|
||||
object.productsAvailability == null
|
||||
? null
|
||||
: fbb.writeString(object.productsAvailability!);
|
||||
final productsAvailabilityStateOffset =
|
||||
object.productsAvailabilityState == null
|
||||
? null
|
||||
: fbb.writeString(object.productsAvailabilityState!);
|
||||
fbb.startTable(27);
|
||||
fbb.addInt64(0, object.id);
|
||||
fbb.addOffset(1, priorityOffset);
|
||||
@ -798,19 +716,6 @@ obx_int.ModelDefinition getObjectBoxModel() {
|
||||
fbb.addOffset(5, originOffset);
|
||||
fbb.addBool(6, object.useCreateLots);
|
||||
fbb.addBool(7, object.isLocked);
|
||||
fbb.addOffset(8, scheduledDateOffset);
|
||||
fbb.addOffset(9, dateDeadlineOffset);
|
||||
fbb.addOffset(10, dateDoneOffset);
|
||||
fbb.addOffset(11, productsAvailabilityOffset);
|
||||
fbb.addOffset(12, productsAvailabilityStateOffset);
|
||||
fbb.addBool(13, object.jsonPopover);
|
||||
fbb.addBool(14, object.activityExceptionIcon);
|
||||
fbb.addBool(15, object.activityExceptionDecoration);
|
||||
fbb.addBool(16, object.showCheckAvailability);
|
||||
fbb.addBool(17, object.hasScrapMove);
|
||||
fbb.addBool(18, object.hasPackages);
|
||||
fbb.addBool(19, object.showNextPickings);
|
||||
fbb.addBool(20, object.pickingTypeEntirePacks);
|
||||
fbb.addInt64(21, object.companyId.targetId);
|
||||
fbb.addInt64(22, object.partnerId.targetId);
|
||||
fbb.addInt64(23, object.locationId.targetId);
|
||||
@ -853,46 +758,6 @@ obx_int.ModelDefinition getObjectBoxModel() {
|
||||
rootOffset,
|
||||
18,
|
||||
);
|
||||
final scheduledDateParam = const fb.StringReader(
|
||||
asciiOptimization: true,
|
||||
).vTableGetNullable(buffer, rootOffset, 20);
|
||||
final dateDeadlineParam = const fb.StringReader(
|
||||
asciiOptimization: true,
|
||||
).vTableGetNullable(buffer, rootOffset, 22);
|
||||
final dateDoneParam = const fb.StringReader(
|
||||
asciiOptimization: true,
|
||||
).vTableGetNullable(buffer, rootOffset, 24);
|
||||
final productsAvailabilityParam = const fb.StringReader(
|
||||
asciiOptimization: true,
|
||||
).vTableGetNullable(buffer, rootOffset, 26);
|
||||
final productsAvailabilityStateParam = const fb.StringReader(
|
||||
asciiOptimization: true,
|
||||
).vTableGetNullable(buffer, rootOffset, 28);
|
||||
final jsonPopoverParam = const fb.BoolReader().vTableGetNullable(
|
||||
buffer,
|
||||
rootOffset,
|
||||
30,
|
||||
);
|
||||
final activityExceptionIconParam = const fb.BoolReader()
|
||||
.vTableGetNullable(buffer, rootOffset, 32);
|
||||
final activityExceptionDecorationParam = const fb.BoolReader()
|
||||
.vTableGetNullable(buffer, rootOffset, 34);
|
||||
final showCheckAvailabilityParam = const fb.BoolReader()
|
||||
.vTableGetNullable(buffer, rootOffset, 36);
|
||||
final hasScrapMoveParam = const fb.BoolReader().vTableGetNullable(
|
||||
buffer,
|
||||
rootOffset,
|
||||
38,
|
||||
);
|
||||
final hasPackagesParam = const fb.BoolReader().vTableGetNullable(
|
||||
buffer,
|
||||
rootOffset,
|
||||
40,
|
||||
);
|
||||
final showNextPickingsParam = const fb.BoolReader()
|
||||
.vTableGetNullable(buffer, rootOffset, 42);
|
||||
final pickingTypeEntirePacksParam = const fb.BoolReader()
|
||||
.vTableGetNullable(buffer, rootOffset, 44);
|
||||
final object = StockPickingRecordEntity(
|
||||
id: idParam,
|
||||
priority: priorityParam,
|
||||
@ -902,19 +767,6 @@ obx_int.ModelDefinition getObjectBoxModel() {
|
||||
origin: originParam,
|
||||
useCreateLots: useCreateLotsParam,
|
||||
isLocked: isLockedParam,
|
||||
scheduledDate: scheduledDateParam,
|
||||
dateDeadline: dateDeadlineParam,
|
||||
dateDone: dateDoneParam,
|
||||
productsAvailability: productsAvailabilityParam,
|
||||
productsAvailabilityState: productsAvailabilityStateParam,
|
||||
jsonPopover: jsonPopoverParam,
|
||||
activityExceptionIcon: activityExceptionIconParam,
|
||||
activityExceptionDecoration: activityExceptionDecorationParam,
|
||||
showCheckAvailability: showCheckAvailabilityParam,
|
||||
hasScrapMove: hasScrapMoveParam,
|
||||
hasPackages: hasPackagesParam,
|
||||
showNextPickings: showNextPickingsParam,
|
||||
pickingTypeEntirePacks: pickingTypeEntirePacksParam,
|
||||
);
|
||||
object.companyId.targetId = const fb.Int64Reader().vTableGet(
|
||||
buffer,
|
||||
@ -1171,112 +1023,38 @@ class StockPickingRecordEntity_ {
|
||||
_entities[6].properties[7],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.scheduledDate].
|
||||
static final scheduledDate =
|
||||
obx.QueryStringProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[8],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.dateDeadline].
|
||||
static final dateDeadline = obx.QueryStringProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[9],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.dateDone].
|
||||
static final dateDone = obx.QueryStringProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[10],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.productsAvailability].
|
||||
static final productsAvailability =
|
||||
obx.QueryStringProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[11],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.productsAvailabilityState].
|
||||
static final productsAvailabilityState =
|
||||
obx.QueryStringProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[12],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.jsonPopover].
|
||||
static final jsonPopover = obx.QueryBooleanProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[13],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.activityExceptionIcon].
|
||||
static final activityExceptionIcon =
|
||||
obx.QueryBooleanProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[14],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.activityExceptionDecoration].
|
||||
static final activityExceptionDecoration =
|
||||
obx.QueryBooleanProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[15],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.showCheckAvailability].
|
||||
static final showCheckAvailability =
|
||||
obx.QueryBooleanProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[16],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.hasScrapMove].
|
||||
static final hasScrapMove =
|
||||
obx.QueryBooleanProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[17],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.hasPackages].
|
||||
static final hasPackages = obx.QueryBooleanProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[18],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.showNextPickings].
|
||||
static final showNextPickings =
|
||||
obx.QueryBooleanProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[19],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.pickingTypeEntirePacks].
|
||||
static final pickingTypeEntirePacks =
|
||||
obx.QueryBooleanProperty<StockPickingRecordEntity>(
|
||||
_entities[6].properties[20],
|
||||
);
|
||||
|
||||
/// See [StockPickingRecordEntity.companyId].
|
||||
static final companyId =
|
||||
obx.QueryRelationToOne<
|
||||
StockPickingRecordEntity,
|
||||
StockPickingCompanyEntity
|
||||
>(_entities[6].properties[21]);
|
||||
>(_entities[6].properties[8]);
|
||||
|
||||
/// See [StockPickingRecordEntity.partnerId].
|
||||
static final partnerId =
|
||||
obx.QueryRelationToOne<
|
||||
StockPickingRecordEntity,
|
||||
StockPickingPartnerEntity
|
||||
>(_entities[6].properties[22]);
|
||||
>(_entities[6].properties[9]);
|
||||
|
||||
/// See [StockPickingRecordEntity.locationId].
|
||||
static final locationId =
|
||||
obx.QueryRelationToOne<
|
||||
StockPickingRecordEntity,
|
||||
StockPickingLocationEntity
|
||||
>(_entities[6].properties[23]);
|
||||
>(_entities[6].properties[10]);
|
||||
|
||||
/// See [StockPickingRecordEntity.locationDestId].
|
||||
static final locationDestId =
|
||||
obx.QueryRelationToOne<
|
||||
StockPickingRecordEntity,
|
||||
StockPickingLocationEntity
|
||||
>(_entities[6].properties[24]);
|
||||
>(_entities[6].properties[11]);
|
||||
|
||||
/// See [StockPickingRecordEntity.pickingTypeId].
|
||||
static final pickingTypeId =
|
||||
obx.QueryRelationToOne<StockPickingRecordEntity, StockPickingTypeEntity>(
|
||||
_entities[6].properties[25],
|
||||
_entities[6].properties[12],
|
||||
);
|
||||
|
||||
/// see [StockPickingRecordEntity.moveLineIdsWithoutPackage]
|
||||
|
@ -1,7 +1,8 @@
|
||||
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
|
||||
import 'package:e_scan/backend/objectbox/objectbox_manager.dart';
|
||||
import 'package:e_scan/backend/schema/product/product_model.dart';
|
||||
import 'package:e_scan/utils/utils.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'stock_picking_record_model.freezed.dart';
|
||||
part 'stock_picking_record_model.g.dart';
|
||||
|
||||
@ -146,3 +147,108 @@ extension StockPickingRecordModelExt on StockPickingRecordModel {
|
||||
extension MoveWithoutPackageModelExt on MoveWithoutPackageModel {
|
||||
double get ecart => ((quantity ?? 0) - (productUomQty ?? 0));
|
||||
}
|
||||
|
||||
extension StockPickingRecordModelToEntity on StockPickingRecordModel {
|
||||
StockPickingRecordEntity toEntity() {
|
||||
final entity = StockPickingRecordEntity(
|
||||
id: id ?? 0,
|
||||
priority: priority,
|
||||
name: name,
|
||||
scheduledDate: scheduledDate,
|
||||
pickingTypeCode: pickingTypeCode,
|
||||
productsAvailabilityState: productsAvailabilityState,
|
||||
productsAvailability: productsAvailability,
|
||||
dateDeadline: dateDeadline,
|
||||
dateDone: dateDone,
|
||||
origin: origin,
|
||||
state: state,
|
||||
activityExceptionDecoration: activityExceptionDecoration,
|
||||
activityExceptionIcon: activityExceptionIcon,
|
||||
jsonPopover: jsonPopover,
|
||||
);
|
||||
|
||||
//toOne
|
||||
entity.partnerId.target = partnerId?.toEntity();
|
||||
entity.companyId.target = companyId?.toEntity();
|
||||
entity.locationId.target = locationId?.toEntity();
|
||||
entity.locationDestId.target = locationDestId?.toEntity();
|
||||
entity.pickingTypeId.target = pickingTypeId?.toEntity();
|
||||
|
||||
//toMany
|
||||
entity.moveLineIdsWithoutPackage.addAll(
|
||||
moveLineIdsWithoutPackage?.map((e) => e.toEntity()).nonNulls.toList() ??
|
||||
<MoveLineWithoutPackageEntity>[],
|
||||
);
|
||||
entity.moveIdsWithoutPackage.addAll(
|
||||
moveIdsWithoutPackage?.map((e) => e.toEntity()).nonNulls.toList() ??
|
||||
<MoveWithoutPackageEntity>[],
|
||||
);
|
||||
|
||||
objectboxManager.store.box<StockPickingRecordEntity>().put(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
extension StockPickingCompanyModelToEntity on StockPickingCompanyModel {
|
||||
StockPickingCompanyEntity toEntity() {
|
||||
final entity = StockPickingCompanyEntity(id: id ?? 0);
|
||||
objectboxManager.store.box<StockPickingCompanyEntity>().put(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
extension StockPickingPartnerModelToEntity on StockPickingPartnerModel {
|
||||
StockPickingPartnerEntity toEntity() {
|
||||
final entity = StockPickingPartnerEntity(
|
||||
id: id ?? 0,
|
||||
displayName: displayName,
|
||||
);
|
||||
objectboxManager.store.box<StockPickingPartnerEntity>().put(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
extension StockPickingLocationModelToEntity on StockPickingLocationModel {
|
||||
StockPickingLocationEntity toEntity() {
|
||||
final entity = StockPickingLocationEntity(
|
||||
id: id ?? 0,
|
||||
completeName: completeName,
|
||||
);
|
||||
objectboxManager.store.box<StockPickingLocationEntity>().put(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
extension StockPickingTypeModelToEntity on StockPickingTypeModel {
|
||||
StockPickingTypeEntity toEntity() {
|
||||
final entity = StockPickingTypeEntity(
|
||||
id: id ?? 0,
|
||||
displayName: displayName,
|
||||
);
|
||||
objectboxManager.store.box<StockPickingTypeEntity>().put(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
extension MoveLineWithoutPackageModelToEntity on MoveLineWithoutPackageModel {
|
||||
MoveLineWithoutPackageEntity toEntity() {
|
||||
final entity = MoveLineWithoutPackageEntity(
|
||||
id: id ?? 0,
|
||||
quantity: quantity,
|
||||
);
|
||||
objectboxManager.store.box<MoveLineWithoutPackageEntity>().put(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
extension MoveWithoutPackageModelToEntity on MoveWithoutPackageModel {
|
||||
MoveWithoutPackageEntity toEntity() {
|
||||
final entity = MoveWithoutPackageEntity(
|
||||
id: id ?? 0,
|
||||
quantity: quantity,
|
||||
productUomQty: productUomQty,
|
||||
);
|
||||
objectboxManager.store.box<MoveWithoutPackageEntity>().put(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,4 @@ export 'product_scanned_component.dart';
|
||||
export 'outline_button_component.dart';
|
||||
export 'quick_action_component.dart';
|
||||
export 'main_appbar_component.dart';
|
||||
export 'stock_picking_card_component.dart';
|
||||
export 'stock_picking_card_component.dart';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:e_scan/backend/schema/stock_picking/stock_picking_record_model.dart';
|
||||
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
|
||||
import 'package:e_scan/components/components.dart';
|
||||
import 'package:e_scan/pages/operation/reception/reception_details_page_model.dart';
|
||||
import 'package:e_scan/router/go_secure_router_builder.dart';
|
||||
@ -63,9 +63,9 @@ class _ReceptionDetailsPageState extends ConsumerState<ReceptionDetailsPage> {
|
||||
isDone: reception?.isDone == true,
|
||||
margin: EdgeInsets.symmetric(horizontal: 5),
|
||||
reference: reception?.name ?? '',
|
||||
from: reception?.locationId?.completeName,
|
||||
to: reception?.locationDestId?.completeName,
|
||||
contact: reception?.partnerId?.displayName,
|
||||
from: reception?.locationId.target?.completeName,
|
||||
to: reception?.locationDestId.target?.completeName,
|
||||
contact: reception?.partnerId.target?.displayName,
|
||||
origin: reception?.origin,
|
||||
status: reception?.state,
|
||||
),
|
||||
@ -83,12 +83,12 @@ class _ReceptionDetailsPageState extends ConsumerState<ReceptionDetailsPage> {
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
...reception?.moveIdsWithoutPackage
|
||||
?.map(
|
||||
.map(
|
||||
(move) => Card(
|
||||
color: AppTheme.of(context).primaryBackground,
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
move.productId?.displayName ?? '',
|
||||
move.productId.target?.displayName ?? '',
|
||||
style: TextStyle(color: Colors.black),
|
||||
),
|
||||
subtitle: Wrap(
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:e_scan/backend/api/api_calls.dart';
|
||||
import 'package:e_scan/backend/schema/stock_picking/stock_picking_record_model.dart';
|
||||
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
@ -39,7 +39,7 @@ class ReceptionDetailsPageModel
|
||||
@freezed
|
||||
abstract class ReceptionDetailsPageState with _$ReceptionDetailsPageState {
|
||||
const factory ReceptionDetailsPageState({
|
||||
StockPickingRecordModel? reception,
|
||||
StockPickingRecordEntity? reception,
|
||||
@Default(false) bool loading,
|
||||
}) = _ReceptionDetailsPageState;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ReceptionDetailsPageState implements DiagnosticableTreeMixin {
|
||||
|
||||
StockPickingRecordModel? get reception; bool get loading;
|
||||
StockPickingRecordEntity? get reception; bool get loading;
|
||||
/// Create a copy of ReceptionDetailsPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@ -52,11 +52,11 @@ abstract mixin class $ReceptionDetailsPageStateCopyWith<$Res> {
|
||||
factory $ReceptionDetailsPageStateCopyWith(ReceptionDetailsPageState value, $Res Function(ReceptionDetailsPageState) _then) = _$ReceptionDetailsPageStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
StockPickingRecordModel? reception, bool loading
|
||||
StockPickingRecordEntity? reception, bool loading
|
||||
});
|
||||
|
||||
|
||||
$StockPickingRecordModelCopyWith<$Res>? get reception;
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@ -72,23 +72,11 @@ class _$ReceptionDetailsPageStateCopyWithImpl<$Res>
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? reception = freezed,Object? loading = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
reception: freezed == reception ? _self.reception : reception // ignore: cast_nullable_to_non_nullable
|
||||
as StockPickingRecordModel?,loading: null == loading ? _self.loading : loading // ignore: cast_nullable_to_non_nullable
|
||||
as StockPickingRecordEntity?,loading: null == loading ? _self.loading : loading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
/// Create a copy of ReceptionDetailsPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$StockPickingRecordModelCopyWith<$Res>? get reception {
|
||||
if (_self.reception == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $StockPickingRecordModelCopyWith<$Res>(_self.reception!, (value) {
|
||||
return _then(_self.copyWith(reception: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +87,7 @@ class _ReceptionDetailsPageState with DiagnosticableTreeMixin implements Recepti
|
||||
const _ReceptionDetailsPageState({this.reception, this.loading = false});
|
||||
|
||||
|
||||
@override final StockPickingRecordModel? reception;
|
||||
@override final StockPickingRecordEntity? reception;
|
||||
@override@JsonKey() final bool loading;
|
||||
|
||||
/// Create a copy of ReceptionDetailsPageState
|
||||
@ -138,11 +126,11 @@ abstract mixin class _$ReceptionDetailsPageStateCopyWith<$Res> implements $Recep
|
||||
factory _$ReceptionDetailsPageStateCopyWith(_ReceptionDetailsPageState value, $Res Function(_ReceptionDetailsPageState) _then) = __$ReceptionDetailsPageStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
StockPickingRecordModel? reception, bool loading
|
||||
StockPickingRecordEntity? reception, bool loading
|
||||
});
|
||||
|
||||
|
||||
@override $StockPickingRecordModelCopyWith<$Res>? get reception;
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
@ -158,24 +146,12 @@ class __$ReceptionDetailsPageStateCopyWithImpl<$Res>
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? reception = freezed,Object? loading = null,}) {
|
||||
return _then(_ReceptionDetailsPageState(
|
||||
reception: freezed == reception ? _self.reception : reception // ignore: cast_nullable_to_non_nullable
|
||||
as StockPickingRecordModel?,loading: null == loading ? _self.loading : loading // ignore: cast_nullable_to_non_nullable
|
||||
as StockPickingRecordEntity?,loading: null == loading ? _self.loading : loading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of ReceptionDetailsPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$StockPickingRecordModelCopyWith<$Res>? get reception {
|
||||
if (_self.reception == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $StockPickingRecordModelCopyWith<$Res>(_self.reception!, (value) {
|
||||
return _then(_self.copyWith(reception: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
|
@ -1,4 +1,4 @@
|
||||
import 'package:e_scan/backend/schema/stock_picking/stock_picking_record_model.dart';
|
||||
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
|
||||
import 'package:e_scan/components/components.dart';
|
||||
import 'package:e_scan/pages/operation/reception/reception_page_model.dart';
|
||||
import 'package:e_scan/router/go_secure_router_builder.dart';
|
||||
@ -74,7 +74,6 @@ class _ReceptionPageState extends ConsumerState<ReceptionPage> {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
final id = reception.id;
|
||||
if (id == null) return;
|
||||
ReceptionDetailsRoute(
|
||||
receptionId: id,
|
||||
).push(context);
|
||||
@ -86,9 +85,14 @@ class _ReceptionPageState extends ConsumerState<ReceptionPage> {
|
||||
),
|
||||
isDone: reception.isDone == true,
|
||||
reference: reception.name ?? '',
|
||||
from: reception.locationId?.completeName,
|
||||
to: reception.locationDestId?.completeName,
|
||||
contact: reception.partnerId?.displayName,
|
||||
from:
|
||||
reception.locationId.target?.completeName,
|
||||
to: reception
|
||||
.locationDestId
|
||||
.target
|
||||
?.completeName,
|
||||
contact:
|
||||
reception.partnerId.target?.displayName,
|
||||
origin: reception.origin,
|
||||
status: reception.state,
|
||||
),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:e_scan/backend/api/api_calls.dart';
|
||||
import 'package:e_scan/backend/schema/stock_picking/stock_picking_record_model.dart';
|
||||
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
|
||||
import 'package:e_scan/backend/schema/user/user_struct.dart';
|
||||
import 'package:e_scan/services/secure_storage.dart';
|
||||
import 'package:e_scan/services/token_provider.dart';
|
||||
@ -60,8 +60,8 @@ class ReceptionPageModel extends StateNotifier<ReceptionPageState> {
|
||||
abstract class ReceptionPageState with _$ReceptionPageState {
|
||||
const factory ReceptionPageState({
|
||||
UserStruct? user,
|
||||
@Default(<StockPickingRecordModel>[])
|
||||
List<StockPickingRecordModel> receptions,
|
||||
@Default(<StockPickingRecordEntity>[])
|
||||
List<StockPickingRecordEntity> receptions,
|
||||
@Default(false) bool loadingReceptions,
|
||||
@Default(false) bool loadingUser,
|
||||
}) = _ReceptionPageState;
|
||||
|
@ -15,7 +15,7 @@ T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$ReceptionPageState implements DiagnosticableTreeMixin {
|
||||
|
||||
UserStruct? get user; List<StockPickingRecordModel> get receptions; bool get loadingReceptions; bool get loadingUser;
|
||||
UserStruct? get user; List<StockPickingRecordEntity> get receptions; bool get loadingReceptions; bool get loadingUser;
|
||||
/// Create a copy of ReceptionPageState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@ -52,7 +52,7 @@ abstract mixin class $ReceptionPageStateCopyWith<$Res> {
|
||||
factory $ReceptionPageStateCopyWith(ReceptionPageState value, $Res Function(ReceptionPageState) _then) = _$ReceptionPageStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
UserStruct? user, List<StockPickingRecordModel> receptions, bool loadingReceptions, bool loadingUser
|
||||
UserStruct? user, List<StockPickingRecordEntity> receptions, bool loadingReceptions, bool loadingUser
|
||||
});
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ class _$ReceptionPageStateCopyWithImpl<$Res>
|
||||
return _then(_self.copyWith(
|
||||
user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as UserStruct?,receptions: null == receptions ? _self.receptions : receptions // ignore: cast_nullable_to_non_nullable
|
||||
as List<StockPickingRecordModel>,loadingReceptions: null == loadingReceptions ? _self.loadingReceptions : loadingReceptions // ignore: cast_nullable_to_non_nullable
|
||||
as List<StockPickingRecordEntity>,loadingReceptions: null == loadingReceptions ? _self.loadingReceptions : loadingReceptions // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loadingUser: null == loadingUser ? _self.loadingUser : loadingUser // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
@ -98,12 +98,12 @@ $UserStructCopyWith<$Res>? get user {
|
||||
|
||||
|
||||
class _ReceptionPageState with DiagnosticableTreeMixin implements ReceptionPageState {
|
||||
const _ReceptionPageState({this.user, final List<StockPickingRecordModel> receptions = const <StockPickingRecordModel>[], this.loadingReceptions = false, this.loadingUser = false}): _receptions = receptions;
|
||||
const _ReceptionPageState({this.user, final List<StockPickingRecordEntity> receptions = const <StockPickingRecordEntity>[], this.loadingReceptions = false, this.loadingUser = false}): _receptions = receptions;
|
||||
|
||||
|
||||
@override final UserStruct? user;
|
||||
final List<StockPickingRecordModel> _receptions;
|
||||
@override@JsonKey() List<StockPickingRecordModel> get receptions {
|
||||
final List<StockPickingRecordEntity> _receptions;
|
||||
@override@JsonKey() List<StockPickingRecordEntity> get receptions {
|
||||
if (_receptions is EqualUnmodifiableListView) return _receptions;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_receptions);
|
||||
@ -148,7 +148,7 @@ abstract mixin class _$ReceptionPageStateCopyWith<$Res> implements $ReceptionPag
|
||||
factory _$ReceptionPageStateCopyWith(_ReceptionPageState value, $Res Function(_ReceptionPageState) _then) = __$ReceptionPageStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
UserStruct? user, List<StockPickingRecordModel> receptions, bool loadingReceptions, bool loadingUser
|
||||
UserStruct? user, List<StockPickingRecordEntity> receptions, bool loadingReceptions, bool loadingUser
|
||||
});
|
||||
|
||||
|
||||
@ -169,7 +169,7 @@ class __$ReceptionPageStateCopyWithImpl<$Res>
|
||||
return _then(_ReceptionPageState(
|
||||
user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as UserStruct?,receptions: null == receptions ? _self._receptions : receptions // ignore: cast_nullable_to_non_nullable
|
||||
as List<StockPickingRecordModel>,loadingReceptions: null == loadingReceptions ? _self.loadingReceptions : loadingReceptions // ignore: cast_nullable_to_non_nullable
|
||||
as List<StockPickingRecordEntity>,loadingReceptions: null == loadingReceptions ? _self.loadingReceptions : loadingReceptions // ignore: cast_nullable_to_non_nullable
|
||||
as bool,loadingUser: null == loadingUser ? _self.loadingUser : loadingUser // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
|
Loading…
x
Reference in New Issue
Block a user