@asumano/worklip-typeorm-db 1.1.111 → 1.1.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,6 +49,7 @@ export declare class ServiceOrderStage {
49
49
  pay_rate: string | null;
50
50
  pay_amount: string | null;
51
51
  income_hours: string | null;
52
+ income_unit: number | null;
52
53
  income_rate: string | null;
53
54
  income_amount: string | null;
54
55
  payroll_updated_by: Associate | null;
@@ -241,10 +241,19 @@ __decorate([
241
241
  scale: 2,
242
242
  default: null,
243
243
  nullable: true,
244
- comment: "Horas que paga la aseguradora (baremo). NULL en particular: el ingreso se escribe directo.",
244
+ comment: "Horas o piezas que paga la aseguradora (según income_unit). NULL en particular: el ingreso se escribe directo.",
245
245
  }),
246
246
  __metadata("design:type", Object)
247
247
  ], ServiceOrderStage.prototype, "income_hours", void 0);
248
+ __decorate([
249
+ (0, typeorm_1.Column)({
250
+ type: "int",
251
+ default: null,
252
+ nullable: true,
253
+ comment: "Cómo paga la aseguradora la etapa.\n1: Por hora.\n3: Por pieza o trabajo.\nNULL: por hora (etapas de antes de sql/98).",
254
+ }),
255
+ __metadata("design:type", Object)
256
+ ], ServiceOrderStage.prototype, "income_unit", void 0);
248
257
  __decorate([
249
258
  (0, typeorm_1.Column)({
250
259
  type: "decimal",
@@ -252,7 +261,7 @@ __decorate([
252
261
  scale: 2,
253
262
  default: null,
254
263
  nullable: true,
255
- comment: "Valor hora de la aseguradora usado (carrocería o pintura).",
264
+ comment: "Valor hora de la aseguradora (carrocería o pintura) o valor por pieza escrito a mano.",
256
265
  }),
257
266
  __metadata("design:type", Object)
258
267
  ], ServiceOrderStage.prototype, "income_rate", void 0);
@@ -47,13 +47,14 @@ export interface IStagePayValues {
47
47
  */
48
48
  export declare const suggestStagePay: (rate: IAssociatePayRateShape | null | undefined, estimatedHours?: string | number | null | undefined) => IStagePayValues | null;
49
49
  export interface IStagePayrollValues extends IStagePayValues {
50
+ income_unit: TPayUnit | null;
50
51
  income_hours: number | null;
51
52
  income_rate: number | null;
52
53
  income_amount: number | null;
53
54
  }
54
55
  /**
55
56
  * DOC: Valida y completa el pago y el ingreso de una etapa. Los totales los calcula siempre el servidor:
56
- * pago = cantidad x valor; ingreso = horas x valor hora o, sin horas (particular), el escrito a mano.
57
+ * pago = cantidad x valor; ingreso = horas o piezas x valor o, sin cantidad (particular), el escrito a mano.
57
58
  */
58
59
  export declare const resolveStagePayroll: (input: any) => IStagePayrollValues | {
59
60
  error: "INVALID_PAYROLL";
@@ -99,14 +99,17 @@ const suggestStagePay = (rate, estimatedHours = null) => {
99
99
  exports.suggestStagePay = suggestStagePay;
100
100
  /**
101
101
  * DOC: Valida y completa el pago y el ingreso de una etapa. Los totales los calcula siempre el servidor:
102
- * pago = cantidad x valor; ingreso = horas x valor hora o, sin horas (particular), el escrito a mano.
102
+ * pago = cantidad x valor; ingreso = horas o piezas x valor o, sin cantidad (particular), el escrito a mano.
103
103
  */
104
104
  const resolveStagePayroll = (input) => {
105
105
  const invalid = { error: "INVALID_PAYROLL" };
106
106
  const unitRaw = input?.pay_unit;
107
107
  const hasUnit = !isEmpty(unitRaw);
108
+ const incomeUnitRaw = input?.income_unit;
108
109
  if (hasUnit && !(0, exports.isPayUnit)(unitRaw, exports.STAGE_PAY_UNITS))
109
110
  return invalid;
111
+ if (!isEmpty(incomeUnitRaw) && !(0, exports.isPayUnit)(incomeUnitRaw, exports.STAGE_PAY_UNITS))
112
+ return invalid;
110
113
  const quantity = hasUnit ? (0, exports.normalizePayrollQuantity)(input?.pay_quantity) : null;
111
114
  const rate = hasUnit ? (0, exports.normalizePayrollMoney)(input?.pay_rate) : null;
112
115
  const incomeHours = (0, exports.normalizePayrollQuantity)(input?.income_hours);
@@ -120,6 +123,8 @@ const resolveStagePayroll = (input) => {
120
123
  pay_quantity: quantity,
121
124
  pay_rate: rate,
122
125
  pay_amount: (0, exports.payrollLineAmount)(quantity, rate),
126
+ // DOC: Solo se guarda «por pieza»; por hora queda NULL, igual que las etapas de antes.
127
+ income_unit: Number(incomeUnitRaw) === exports.PAY_UNIT.PIECE ? exports.PAY_UNIT.PIECE : null,
123
128
  income_hours: incomeHours,
124
129
  income_rate: incomeRate,
125
130
  income_amount: incomeByHours ?? incomeManual,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asumano/worklip-typeorm-db",
3
- "version": "1.1.111",
3
+ "version": "1.1.112",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },